From d7ad8d4cc89f7c0f1047f575f4398373eed83d7c Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 26 Apr 2026 15:57:30 +0200 Subject: [PATCH] Use Gitea release asset upload API --- .gitea/workflows/build.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index dee2666..1610d55 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -37,6 +37,7 @@ jobs: shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | set -euo pipefail @@ -44,15 +45,21 @@ jobs: api="${GITHUB_SERVER_URL}/api/v1" release_name="WorldHandler ${tag}" jar="$(find build/libs -maxdepth 1 -name '*neoforge*.jar' -print -quit)" + token="${GITEA_TOKEN:-${GITHUB_TOKEN:-}}" if [ -z "${jar}" ]; then echo "No NeoForge jar found in build/libs" >&2 exit 1 fi + if [ -z "${token}" ]; then + echo "No Gitea token available" >&2 + exit 1 + fi + release_json="$(mktemp)" if ! curl -fsS \ - -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Authorization: token ${token}" \ -H "Accept: application/json" \ "${api}/repos/${GITHUB_REPOSITORY}/releases/tags/${tag}" \ -o "${release_json}"; then @@ -60,7 +67,7 @@ jobs: python3 -c 'import json, os; print(json.dumps({"tag_name": os.environ["tag"], "target_commitish": os.environ["GITHUB_SHA"], "name": os.environ["release_name"], "body": "NeoForge 21.1.225 build for Minecraft 1.21.1.", "draft": False, "prerelease": False}))' > "${release_json}" curl -fsS \ -X POST \ - -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Authorization: token ${token}" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ --data-binary @"${release_json}" \ @@ -77,16 +84,15 @@ jobs: [ -z "${asset_id}" ] && continue curl -fsS \ -X DELETE \ - -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Authorization: token ${token}" \ "${api}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets/${asset_id}" done < assets-to-delete.txt curl -fsS \ -X POST \ - -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Authorization: token ${token}" \ -H "Accept: application/json" \ - -H "Content-Type: application/java-archive" \ - --data-binary @"${jar}" \ + -F "attachment=@${jar};type=application/java-archive" \ "${api}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=${asset_name}" - name: Publish jar to artifacts branch