ci: use Gitea API for releases (softprops/action-gh-release targets GitHub, fails on Gitea with 405)
This commit is contained in:
@@ -6,6 +6,11 @@ on:
|
|||||||
tags: ['v*']
|
tags: ['v*']
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
|
# Ensure the job token can create releases and upload assets.
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
releases: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -42,11 +47,27 @@ jobs:
|
|||||||
|
|
||||||
- name: Publish release on version tag
|
- name: Publish release on version tag
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
# softprops/action-gh-release works on Gitea Actions: it uses the
|
# Gitea-native release: softprops/action-gh-release targets GitHub's API
|
||||||
# automatically-provided GITHUB_TOKEN to create a Release for the tag
|
# and fails on Gitea (405). Instead we call the Gitea API directly with
|
||||||
# and attaches the supplied files.
|
# the runner-provided GITHUB_TOKEN and GITHUB_API_URL.
|
||||||
uses: softprops/action-gh-release@v2
|
env:
|
||||||
with:
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
files: dist/*.zip
|
run: |
|
||||||
name: ${{ github.ref_name }}
|
set -euo pipefail
|
||||||
generate_release_notes: true
|
REPO="${{ github.repository }}"
|
||||||
|
TAG="${{ github.ref_name }}"
|
||||||
|
API="${GITHUB_API_URL:-https://git.ranio.xyz/api/v1}"
|
||||||
|
# Create the release for the tag
|
||||||
|
RELEASE_JSON=$(curl -sS -X POST \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"body\":\"ISMIS Helper ${TAG}\"}" \
|
||||||
|
"${API}/repos/${REPO}/releases")
|
||||||
|
RELEASE_ID=$(echo "${RELEASE_JSON}" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||||
|
# Attach both zips as release assets
|
||||||
|
for f in dist/*.zip; do
|
||||||
|
curl -sS -X POST \
|
||||||
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||||
|
-F "attachment=@${f}" \
|
||||||
|
"${API}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$(basename "${f}")"
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user