From 653f50099162d3e5a2e214db8a20f63a0f287103 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 23:02:36 +0000 Subject: [PATCH] fix(release): fail the release step on GitHub API errors A rate-limited release listing printed its error body, the loop word-split it into release ids, and `|| true` hid every failed delete. The old floating release survived, a duplicate draft was created, and upload-assets failed with "release not found" (Ruby 4.0.6 rebuild). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f4b2cfc..b8d53fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -150,13 +150,21 @@ jobs: TARGET="$(git rev-parse --verify HEAD)" - # Delete ALL existing floating releases matching this version (handles orphaned releases) - for release_id in $(gh api repos/${{ github.repository }}/releases --paginate --jq ".[] | select(.name == \"${VERSION}\" or .tag_name == \"${VERSION}\") | .id"); do + # Delete ALL existing floating releases matching this version (handles orphaned releases). + # List into a variable first so an API error (e.g. a rate limit) fails the step under + # `bash -e`; looping over the output directly word-splits the error body into "ids". + release_ids=$(gh api repos/${{ github.repository }}/releases --paginate --jq ".[] | select(.name == \"${VERSION}\" or .tag_name == \"${VERSION}\") | .id") + for release_id in $release_ids; do echo "Deleting release $release_id" - gh api -X DELETE "repos/${{ github.repository }}/releases/$release_id" || true + gh api -X DELETE "repos/${{ github.repository }}/releases/$release_id" done - # Also delete the tag if it exists - gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/${VERSION}" 2>/dev/null || true + # Also delete the tag if it exists; only a missing ref is ignored + if ! out=$(gh api -X DELETE "repos/${{ github.repository }}/git/refs/tags/${VERSION}" 2>&1); then + if ! grep -qE 'HTTP (404|422)' <<<"$out"; then + echo "$out" + exit 1 + fi + fi # Create floating release (e.g., 3.4.5) — always updated to latest build gh release create "${VERSION}" \