From 80d478d2c9b67c39a05963d5971e11b424dfc43a Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Fri, 25 Sep 2026 17:32:52 +0200 Subject: [PATCH] Upload release jars through Gitea's internal address The Cloudflare tunnel in front of git.selimaj.dev rejects the jar uploads with 413 Payload Too Large. Call the API at http://gitea:3000 instead, look the release up by tag, and add a workflow_dispatch trigger that builds a given tag and attaches the jars to its existing release. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/release.yml | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 560ad7e..bb1c8d5 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -4,13 +4,27 @@ name: Release # to it. mod_version in gradle.properties is the source of truth: the release # tag must match it (a leading "v" is allowed), so bump mod_version in a PR # before tagging the release. +# +# To (re)attach jars to an existing release, run this workflow manually with +# the release's tag. on: release: types: [published] + workflow_dispatch: + inputs: + tag: + description: Tag of the existing release to build and attach jars to + required: true permissions: contents: write +env: + TAG: ${{ github.event.release.tag_name || inputs.tag }} + # Gitea's internal address. Uploads bypass the Cloudflare tunnel, which + # rejects request bodies as large as the mod jars (413). + GITEA_API: http://gitea:3000/api/v1 + jobs: build: runs-on: ubuntu-latest @@ -18,11 +32,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: + ref: ${{ env.TAG }} submodules: true - name: Check tag matches mod_version - env: - TAG: ${{ github.event.release.tag_name }} run: | MOD_VERSION="$(sed -n 's/^mod_version=//p' gradle.properties | tr -d '[:space:]')" if [ "${TAG#v}" != "$MOD_VERSION" ]; then @@ -47,7 +60,7 @@ jobs: - name: Upload jars to the release env: TOKEN: ${{ secrets.GITEA_TOKEN }} - ASSETS_URL: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets + REPO: ${{ github.repository }} run: | shopt -s nullglob jars=(build/allJars/*.jar) @@ -56,11 +69,20 @@ jobs: exit 1 fi + # Look the release up by tag so manual runs work too. + RELEASE_ID="$(curl --fail-with-body -sS -H "Authorization: token $TOKEN" \ + "$GITEA_API/repos/$REPO/releases/tags/$TAG" \ + | grep -o '"id":[0-9]*' | head -n1 | cut -d: -f2)" + if [ -z "$RELEASE_ID" ]; then + echo "No release found for tag $TAG" >&2 + exit 1 + fi + for jar in "${jars[@]}"; do - echo "Uploading $(basename "$jar")" + echo "Uploading $(basename "$jar") to release $TAG ($RELEASE_ID)" curl --fail-with-body -sS -X POST \ -H "Authorization: token $TOKEN" \ -F "attachment=@$jar" \ - "$ASSETS_URL" + "$GITEA_API/repos/$REPO/releases/$RELEASE_ID/assets" echo done