fix(ci): changelog job creates release to avoid race with build jobs
Some checks failed
Test / rust-fmt-check (pull_request) Waiting to run
PR Review Automation / review (pull_request) Successful in 4m38s
Test / frontend-typecheck (pull_request) Successful in 1m22s
Test / rust-clippy (pull_request) Successful in 6m12s
Test / frontend-tests (pull_request) Successful in 1m13s
Test / rust-tests (pull_request) Has been cancelled

The changelog and build-* jobs all fan out from autotag in parallel.
Build jobs create the Gitea release with 'curl ... || true', but the
changelog job was trying to GET the release before any build job had
run, reliably failing with 'Could not find release for tag vX.Y.Z'.

Fix: changelog job owns release creation. It creates the release with
the git-cliff body if it does not exist, or patches the body if a
prior run already created it. Build jobs continue using their existing
create-or-skip + upload pattern unchanged.
This commit is contained in:
Shaun Arman 2026-05-31 15:57:26 -05:00
parent d3dfa41d83
commit cc99aa815b

View File

@ -140,7 +140,7 @@ jobs:
echo "=== Release body preview ===" echo "=== Release body preview ==="
cat /tmp/release_body.md cat /tmp/release_body.md
- name: Update Gitea release body - name: Create or update Gitea release
env: env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
RELEASE_TAG: ${{ needs.autotag.outputs.release_tag }} RELEASE_TAG: ${{ needs.autotag.outputs.release_tag }}
@ -148,18 +148,43 @@ jobs:
set -eu set -eu
TAG="${RELEASE_TAG}" TAG="${RELEASE_TAG}"
API="http://172.0.0.29:3000/api/v1/repos/$GITHUB_REPOSITORY" API="http://172.0.0.29:3000/api/v1/repos/$GITHUB_REPOSITORY"
RELEASE_ID=$(curl -sf "$API/releases/tags/$TAG" \ RELEASE_BODY=$(cat /tmp/release_body.md)
-H "Authorization: token $RELEASE_TOKEN" | jq -r '.id')
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then # Try to find an existing release for this tag
echo "ERROR: Could not find release for tag $TAG" RELEASE_ID=$(curl -s "$API/releases/tags/$TAG" \
exit 1 -H "Authorization: token $RELEASE_TOKEN" | jq -r '.id // empty')
fi
BODY=$(jq -n --rawfile note /tmp/release_body.md '{body: $note}') if [ -z "$RELEASE_ID" ]; then
curl -sf -X PATCH "$API/releases/$RELEASE_ID" \ # Release doesn't exist yet — create it with the changelog body.
# Build jobs run in parallel and rely on the release existing;
# creating it here ensures no race condition.
echo "Creating release $TAG..."
RELEASE_ID=$(jq -n \
--arg tag "$TAG" \
--arg name "TFTSR $TAG" \
--rawfile body /tmp/release_body.md \
'{tag_name: $tag, name: $name, body: $body, draft: false}' \
| curl -sf -X POST "$API/releases" \
-H "Authorization: token $RELEASE_TOKEN" \ -H "Authorization: token $RELEASE_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "$BODY" --data @- \
| jq -r '.id')
echo "✓ Release created (id=$RELEASE_ID)"
else
# Release already exists (e.g. re-run) — patch the body only
echo "Updating existing release $TAG (id=$RELEASE_ID)..."
jq -n --rawfile body /tmp/release_body.md '{body: $body}' \
| curl -sf -X PATCH "$API/releases/$RELEASE_ID" \
-H "Authorization: token $RELEASE_TOKEN" \
-H "Content-Type: application/json" \
--data @-
echo "✓ Release body updated" echo "✓ Release body updated"
fi
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
echo "ERROR: Failed to create or locate release for $TAG"
exit 1
fi
- name: Commit CHANGELOG.md to master - name: Commit CHANGELOG.md to master
env: env: