Skip to content

fix(release): a release merged in one push with other PRs publishes at its own commit - #8077

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/publish-release-in-batched-push
Nov 17, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/publish-release-in-batched-push

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

A stable release that the merge queue lands in one push together with other PRs now publishes. It publishes at its own merge commit, not at the push's last commit.

Why

The merge queue can merge several queued PRs in one push to main. GitHub runs publish.yml once for that push, with github.sha set to the push's last commit. The release check looked only at that commit's PR. When the release PR's commit was not last, the run found no release PR, printed "merges no release PR; nothing to publish", and skipped every job after it. v0.9.62 (#8075) merged that way, in one push with #8073, so it never reached npm. Rerunning that run can't help: it has the same last commit and the old workflow file.

How

In .github/workflows/publish.yml, "Find the release this push publishes" now:

  • reads every commit the push brought (compare/<before>...<after>). A push that created the branch (before all zeros) reads only its last commit, as before.
  • looks up each commit's PRs and keeps the merged release/vX.Y.Z PR from this repo whose merge commit is that commit. Exactly one is still required.
  • outputs that commit as sha. Every later job already checks out, verifies, tags and publishes EXPECTED_RELEASE_SHA (needs.release-source.outputs.sha), so the release ships exactly the reviewed release commit, without the PRs merged after it in the same push.
  • fails if any commit in the push reads as a release commit (chore: release v…) but GitHub hasn't linked it to its PR yet, where it used to check only the last commit's subject. It also fails if the push has more commits than the compare API lists. A rerun recovers either case.

The tag path is unchanged.

Test plan

fails without the fix: "a push to main publishes only the merge of exactly one approved release PR from this repo" in scripts/publish-workflow.test.mjs fails with main's publish.yml (test-only commit fd84cab4) in 3 of 3 runs. Its new case is a push of a release commit followed by another PR's commit.

  • New cases:
    • the release found below the tip and published at its own commit;
    • an unlinked release commit below the tip fails;
    • a push longer than the compare API lists fails;
    • a push that created the branch reads only its last commit.
  • At the head (ecbeec23), node --test scripts/publish-workflow.test.mjs passes 26 of 26 tests, 3 runs in a row (Node 24, Linux).
  • Each part removed in turn: publishing the tip's sha, skipping the unlinked-release check, dropping the commit-count check. Each makes that test fail.
  • Not run: a real batched release. v0.9.62 is recovered by releasing again once this is on main.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at ecbeec2. No blockers.

Correctness

  • release-source now reads every commit in compare/<before>...<after> and outputs the release PR's own merge commit as sha.
  • Every later job uses that sha, not github.sha. All four checkouts use ref: ${{ env.EXPECTED_RELEASE_SHA }}, three re-check it with git rev-parse HEAD, and the tag, GitHub Release and receipt all use the same commit. The only remaining github.sha reads are the tag-path check and the step's own SHA.
  • The queue squashes (merge_method: SQUASH), so main is linear and the compare list is complete and oldest-first.

Checked against the GitHub API:

  • There is no publish run for fbcdf4ca; run 44104887657 for 72925380 covered both commits.
  • A 300-commit compare lists 250 commits with total_commits: 300, and the guard catches that.
  • A backward range returns behind with 0 commits, which reads as nothing to publish.
  • An unknown before fails closed under bash -e.
  • An all-zeros before falls back to the tip, as before.

Security

  • The PR filters are unchanged, just applied per commit: merged_at, base main, merge_commit_sha == commit, head repo equal to this repo (so a fork's release/v… branch is excluded), and the ref regex.
  • The approval gate applies to whichever PR is selected.
  • There's no injection path. Subjects pass through jq @tsv + read and are only used in [[ =~ ]], and BEFORE/HEAD_MESSAGE come in through env.

Verified

  • node --test scripts/publish-workflow.test.mjs passes 26/26.
  • Mutation: outputting the tip sha fails the release-below-the-tip test.
  • Both commits are signed. CI: 0 failed.

Recovery: this PR can't publish fbcdf4ca itself. Later runs only read their own push range, and there is no dispatch trigger. Re-cutting 0.9.62 also won't work, because release-only-diff --verify requires a version change. So the path is a normal release/v0.9.63 after this lands, and its notes should say 0.9.62 was never published. npm latest will go from 0.9.61 to 0.9.63, and releases/v0.9.62.md describes a version that doesn't exist on npm.

Nits (non-blocking)

  • Nothing tests release commits in two different commits of one push. Keeping only the last release found passes all 26 tests. The code handles that case, and a temporary test I wrote catches the mutation.
  • :112 says "$SHA is the merge of more than one release PR". It should be "the push to $SHA …".
  • The body says "A rerun recovers either case", but a rerun can't recover the more-than-250-commits case, because it sees the same push.

Need from author: nothing.
— Rames

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 9b565c8 Nov 17, 2026
68 checks passed
@miguel-heygen
miguel-heygen deleted the fix/publish-release-in-batched-push branch November 17, 2026 15:39
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.

2 participants