From b09e295a3a0578653e96b9530e270a9790778751 Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Tue, 1 Sep 2026 12:44:27 +0800 Subject: [PATCH] ci: make release-creation race-safe across parallel jobs Linux and Windows both ensure the release exists in parallel; a job can GET 404 (not yet created) then POST 422 (the other job won the race), leaving its release id empty so its assets never upload. Add || true to the create and a fallback re-fetch of the release id by tag when the create fails, so both jobs upload reliably. --- .gitea/workflows/release.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index a8c01bb..6bbd2f7 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -146,7 +146,13 @@ jobs: REL_ID=$(curl -fsS -X POST -H "$AUTH" -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"Gridline ${TAG#v}\",\"body\":\"${BODY}\",\"draft\":true}" \ "${API}/releases" \ - | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) + | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) + fi + if [ -z "$REL_ID" ]; then + # A parallel job may have created the release between our GET and + # POST (create returns 422). Re-fetch by tag and upload to it. + REL_ID=$(curl -fsS -H "$AUTH" "${API}/releases/tags/${TAG}" \ + | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) fi BUNDLE="${GITHUB_WORKSPACE}/desktop/src-tauri/target/release/bundle" @@ -257,7 +263,13 @@ jobs: REL_ID=$(curl -fsS -X POST -H "$AUTH" -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"Gridline ${TAG#v}\",\"body\":\"${BODY}\",\"draft\":true}" \ "${API}/releases" \ - | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) + | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) + fi + if [ -z "$REL_ID" ]; then + # A parallel job may have created the release between our GET and + # POST (create returns 422). Re-fetch by tag and upload to it. + REL_ID=$(curl -fsS -H "$AUTH" "${API}/releases/tags/${TAG}" \ + | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) fi BUNDLE="${GITHUB_WORKSPACE}/desktop/src-tauri/target/release/bundle" -- 2.54.0