Skip to content

Stop the release reporting failure when the changeset PR is already green - #191

Merged
brentrager merged 1 commit into
mainfrom
fix/release-automerge
Aug 20, 2026
Merged

Stop the release reporting failure when the changeset PR is already green#191
brentrager merged 1 commit into
mainfrom
fix/release-automerge

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

Problem

The last step of every release run is:

gh pr merge "$PR_NUMBER" --auto --squash

GitHub refuses to enable auto-merge on a PR that is already mergeable:

GraphQL: Pull request is in clean status (enablePullRequestAutoMerge)

So the release run reports failure after it has already versioned, published, and tagged successfully. That is the worst kind of red — everything shipped, the status says it didn't, and people learn to ignore the badge.

Seen live on run 32404388603: Guard, Typecheck, Lint, Test, Build, Format, Version Update 🦋 all ✅ — then Auto-Merge Changeset PR ❌ and the run is failed.

Why now

This was unreachable by accident of timing. PR checks took ~20 minutes, so the changeset PR was always still pending when this step ran and --auto had something to queue behind. Retiring the log-viewer crate (#180) cut PR checks to ~2 minutes, so the changeset PR is now routinely green first and the race inverted.

Fix

Fall back to a plain --squash when --auto is refused — but only after confirming the PR is actually green.

BUCKETS=$(gh pr checks "$PR_NUMBER" --json bucket --jq '[.[].bucket] | join(" ")' || echo "")
if [[ -z "$BUCKETS" ]] || [[ -n "$(tr ' ' '\n' <<<"$BUCKETS" | grep -vx -e pass -e skipping)" ]]; then
  echo "::error::Changeset PR #$PR_NUMBER is not green ([$BUCKETS]); refusing to merge."
  exit 1
fi
gh pr merge "$PR_NUMBER" --squash

It deliberately does not use gh pr checks --required. This repo has no required checks configured, so --required returns an empty list, the grep finds nothing, and it reads as green — a guard that checks the wrong thing and fails open on a merge. An empty bucket list is therefore treated as not green.

Truth table, run locally against the exact expression:

buckets result
pass MERGE
pass pass MERGE
skipping pass MERGE
(empty) REFUSE
pass fail REFUSE
pass pending REFUSE

🤖 Generated with Claude Code

https://claude.ai/code/session_0152bbE1veqfG1SVJdyLCBxC

…reen

The last step of every release run does `gh pr merge --auto --squash`, and
GitHub refuses to ENABLE auto-merge on a PR that is already mergeable:

  GraphQL: Pull request is in clean status (enablePullRequestAutoMerge)

So the whole release run goes red after it has already versioned, published, and
tagged successfully — the worst kind of red, because it trains everyone to
ignore the status.

This was unreachable until now only by accident of timing: PR checks took ~20
minutes, so the changeset PR was always still pending when this step ran.
Retiring the log-viewer crate cut them to ~2 minutes, so the PR is now routinely
green first and the race inverted.

Falls back to a plain `--squash` when `--auto` is refused, but only after
confirming every check is pass/skipping. Note it does NOT use
`gh pr checks --required`: this repo has no required checks configured, so that
returns an empty list and would read as green — a guard that checks the wrong
thing. An empty bucket list is treated as NOT green, so it fails closed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0152bbE1veqfG1SVJdyLCBxC
@changeset-bot

changeset-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a99faf5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@brentrager
brentrager merged commit 3da9740 into main Aug 20, 2026
1 check passed
@brentrager
brentrager deleted the fix/release-automerge branch August 20, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant