diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4886f8e..a402916 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -392,16 +392,30 @@ jobs: # Push to current branch git push || true - # Also push updates.xml to main (where the update server reads from) + # Also update updates.xml on main via Gitea API (git push blocked by branch protection) if [ "$CURRENT_BRANCH" != "main" ]; then - git fetch origin main - git checkout main - git checkout "$CURRENT_BRANCH" -- updates.xml - git add updates.xml - git commit -m "chore: update ${STABILITY} channel to ${VERSION} on main [skip ci]" \ - --author="gitea-actions[bot] " || true - git push origin main || true - git checkout "$CURRENT_BRANCH" + GA_TOKEN="${{ secrets.GA_TOKEN }}" + API="${GITEA_URL}/api/v1/repos/${{ github.repository }}" + + # Get current file SHA on main (required for update) + FILE_SHA=$(curl -sf -H "Authorization: token ${GA_TOKEN}" \ + "${API}/contents/updates.xml?ref=main" | jq -r '.sha // empty') + + if [ -n "$FILE_SHA" ]; then + # Base64-encode the updates.xml content + CONTENT=$(base64 -w0 updates.xml) + + curl -sf -X PUT -H "Authorization: token ${GA_TOKEN}" \ + -H "Content-Type: application/json" \ + "${API}/contents/updates.xml" \ + -d "$(jq -n \ + --arg content "$CONTENT" \ + --arg sha "$FILE_SHA" \ + --arg msg "chore: update ${STABILITY} channel to ${VERSION} on main [skip ci]" \ + --arg branch "main" \ + '{content: $content, sha: $sha, message: $msg, branch: $branch}' + )" > /dev/null && echo "updates.xml synced to main via API" || echo "WARNING: failed to sync updates.xml to main" + fi fi - name: Summary