diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 4e31792..e23d683 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -6,6 +6,11 @@ on: tags: ['v*'] pull_request: +# Ensure the job token can create releases and upload assets. +permissions: + contents: write + releases: write + jobs: build: runs-on: ubuntu-latest @@ -42,11 +47,27 @@ jobs: - name: Publish release on version tag if: startsWith(github.ref, 'refs/tags/v') - # softprops/action-gh-release works on Gitea Actions: it uses the - # automatically-provided GITHUB_TOKEN to create a Release for the tag - # and attaches the supplied files. - uses: softprops/action-gh-release@v2 - with: - files: dist/*.zip - name: ${{ github.ref_name }} - generate_release_notes: true + # Gitea-native release: softprops/action-gh-release targets GitHub's API + # and fails on Gitea (405). Instead we call the Gitea API directly with + # the runner-provided GITHUB_TOKEN and GITHUB_API_URL. + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + 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