From 2da529fb759e1c0165fb30ff3af52c7e5beaf295 Mon Sep 17 00:00:00 2001 From: Shaun Arman Date: Sun, 12 Apr 2026 22:06:21 -0500 Subject: [PATCH] =?UTF-8?q?fix(ci):=20use=20Gitea=20file=20API=20to=20push?= =?UTF-8?q?=20CHANGELOG.md=20=E2=80=94=20eliminates=20non-fast-forward=20r?= =?UTF-8?q?ejection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git push origin HEAD:master fails when master advances between the job's fetch and its push. Replace with PUT /repos/.../contents/CHANGELOG.md which atomically updates the file on master regardless of HEAD position. --- .gitea/workflows/auto-tag.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/auto-tag.yml b/.gitea/workflows/auto-tag.yml index 5979c2a8..68fe05c4 100644 --- a/.gitea/workflows/auto-tag.yml +++ b/.gitea/workflows/auto-tag.yml @@ -135,14 +135,24 @@ jobs: RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} run: | set -eu - git add CHANGELOG.md - if git diff --staged --quiet; then - echo "No changelog changes" - else - TAG=$(git describe --tags --abbrev=0) - git commit -m "chore: update CHANGELOG.md for ${TAG} [skip ci]" - git push origin HEAD:master - fi + API="http://172.0.0.29:3000/api/v1/repos/$GITHUB_REPOSITORY" + TAG=$(git describe --tags --abbrev=0) + # Get current file SHA from master (required by API if the file already exists) + CURRENT_SHA=$(curl -sf "$API/contents/CHANGELOG.md?ref=master" \ + -H "Authorization: token $RELEASE_TOKEN" | jq -r '.sha // empty') + # Base64-encode the generated file (no line wrapping) + CONTENT=$(base64 -w 0 CHANGELOG.md) + # PUT atomically updates (or creates) the file on master — no fast-forward needed + curl -sf -X PUT "$API/contents/CHANGELOG.md" \ + -H "Authorization: token $RELEASE_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{ + \"message\": \"chore: update CHANGELOG.md for ${TAG} [skip ci]\", + \"content\": \"$CONTENT\", + \"sha\": \"$CURRENT_SHA\", + \"branch\": \"master\" + }" + echo "✓ CHANGELOG.md committed to master" - name: Upload CHANGELOG.md as release asset env: