diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eaf72a3..4af0a5a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -464,58 +464,27 @@ jobs: # Push to current branch git push || true - # Sync updates.xml to main via PR (respects branch protection) - if [ "$CURRENT_BRANCH" != "main" ]; then - GA_TOKEN="${{ secrets.GA_TOKEN }}" - API="${GITEA_URL}/api/v1/repos/${{ github.repository }}" - PR_BRANCH="chore/update-xml-${VERSION}" + # Sync updates.xml to main via direct API + GA_TOKEN="${{ secrets.GA_TOKEN }}" + API="${GITEA_URL}/api/v1/repos/${{ github.repository }}" - # Create branch from main - curl -sf -X POST -H "Authorization: token ${GA_TOKEN}" \ + FILE_SHA=$(curl -sf -H "Authorization: token ${GA_TOKEN}" \ + "${API}/contents/updates.xml?ref=main" | jq -r '.sha // empty') + + if [ -n "$FILE_SHA" ]; then + CONTENT=$(base64 -w0 updates.xml) + curl -sf -X PUT -H "Authorization: token ${GA_TOKEN}" \ -H "Content-Type: application/json" \ - "${API}/branches" \ - -d "$(jq -n --arg name "$PR_BRANCH" '{new_branch_name: $name, old_branch_name: "main"}')" > /dev/null 2>&1 || true - - # Update updates.xml on the PR branch - FILE_SHA=$(curl -sf -H "Authorization: token ${GA_TOKEN}" \ - "${API}/contents/updates.xml?ref=${PR_BRANCH}" | jq -r '.sha // empty') - - if [ -n "$FILE_SHA" ]; then - 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} [skip ci]" \ - --arg branch "$PR_BRANCH" \ - '{content: $content, sha: $sha, message: $msg, branch: $branch}' - )" > /dev/null 2>&1 - - # Create and auto-merge PR - PR_NUM=$(curl -sf -X POST -H "Authorization: token ${GA_TOKEN}" \ - -H "Content-Type: application/json" \ - "${API}/pulls" \ - -d "$(jq -n \ - --arg title "chore: update updates.xml for ${VERSION} [skip ci]" \ - --arg head "$PR_BRANCH" \ - --arg base "main" \ - --arg body "Auto-generated by release workflow." \ - '{title: $title, head: $head, base: $base, body: $body}' - )" | jq -r '.number // empty') - - if [ -n "$PR_NUM" ]; then - curl -sf -X POST -H "Authorization: token ${GA_TOKEN}" \ - -H "Content-Type: application/json" \ - "${API}/pulls/${PR_NUM}/merge" \ - -d '{"Do":"merge","merge_message_field":"chore: update updates.xml for '"${VERSION}"' [skip ci]"}' > /dev/null 2>&1 \ - && echo "updates.xml synced to main via PR #${PR_NUM}" \ - || echo "PR #${PR_NUM} created — merge manually" - curl -sf -X DELETE -H "Authorization: token ${GA_TOKEN}" \ - "${API}/branches/${PR_BRANCH}" > /dev/null 2>&1 || true - fi - fi + "${API}/contents/updates.xml" \ + -d "$(jq -n \ + --arg content "$CONTENT" \ + --arg sha "$FILE_SHA" \ + --arg msg "chore: sync updates.xml ${STABILITY} ${VERSION} [skip ci]" \ + --arg branch "main" \ + '{content: $content, sha: $sha, message: $msg, branch: $branch}' + )" > /dev/null 2>&1 \ + && echo "updates.xml synced to main" \ + || echo "WARNING: failed to sync updates.xml to main" fi - name: Summary