Skip to content

ci(release): respect gh api exit code when probing for existing release - #7

Merged
IsraelAraujo70 merged 1 commit into
mainfrom
ci/release-workflow-tag-detect-fix
Apr 29, 2026
Merged

IsraelAraujo70 merged 1 commit into
mainfrom
ci/release-workflow-tag-detect-fix

Conversation

@IsraelAraujo70

Copy link
Copy Markdown
Owner

Summary

Fix a silent failure in release.yml discovered while cutting v0.1.2: the build matrix received releaseId: null and skipped all uploads, leaving an empty release behind.

Root cause

gh api writes the 404 JSON body (not just an exit code) to stdout. The previous probe:

existing=\$(gh api "...releases/tags/\$TAG" 2>/dev/null || echo '')
if [ -n "\$existing" ]; then ...

set existing to {"message":"Not Found",...} whenever the release didn't exist yet, took the wrong "already exists" branch, and propagated release_id=null downstream.

Fix

if existing=\$(gh api "...releases/tags/\$TAG" 2>/dev/null); then ... else ... fi

Now we only treat it as "exists" when the API actually returned 200.

Test plan

  • Tag v0.1.2 again after merging — the Prepare release step should print Created release <id> for v0.1.2, builds upload, finalize promotes out of draft.

🤖 Generated with Claude Code

`gh api` writes the 404 JSON body to stdout (not just stderr), so the
previous `existing=$(... 2>/dev/null || echo '')` pattern would set
`existing` to `{"message":"Not Found",...}` whenever the release didn't
exist yet. The script then took the "already exists" branch with
`release_id=null`, the build matrix received `releaseId: null` and
silently skipped uploads, and the finalize step blew up trying to PATCH
release id `null`.

Use `if existing=$(gh api ...); then` instead, which only enters the
"exists" branch when the API call actually returned 200.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@IsraelAraujo70
IsraelAraujo70 merged commit 863947b into main Apr 29, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🔍 PR checks

Type: ci
Areas: area/ci

⏭️ Merging will not trigger a release

ci: is non-functional, no release.

Auto-generated by pr-checks.yml. Edit the PR title to change the verdict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant