fix(release): close superseded old-version release PRs - #20
Merged
Conversation
The dedupe in the open-pr job was keyed on the release/<version> head branch, so a version bump while a release PR stood (a feat landing during a fix series) opened a second PR and left the old-version PR open forever, even though its recorded base could never again be the branch head. Seen live as notetweet_obsidian PRs #52 (0.6.7) and #53 (0.7.0), which required manual triage. After creating or refreshing the standing PR, the script now lists open bot-authored PRs in the release/<version> namespace, verifies the same machine-generated provenance the branch-overwrite path requires, and closes each superseded PR with an explanatory comment before deleting its branch. Non-generated PRs in the namespace are left open with a warning; a bot PR whose branch commit fails provenance fails the run loudly for manual triage. The new test extracts the real open-pr github-script from the workflow and executes it against a mocked GitHub API, covering fresh creation, same-version refresh, supersede, the non-generated skip, and the tampered-branch rejection.
chhoumann
marked this pull request as ready for review
July 12, 2026 21:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 1 (release-prepare) promises exactly one standing release PR, but its dedupe was keyed on the
release/<version>head branch. When the planned version changed while a release PR stood - afeat:landing during a fix series bumps 0.6.7 to 0.7.0 - the workflow opened a new PR on a new branch and left the old-version PR open forever. The stale PR could never merge again (its recorded base can never again be the branch head), so it was pure noise requiring manual triage. Seen live as notetweet_obsidian #52 (0.6.7) and #53 (0.7.0), open simultaneously.After creating or refreshing the standing PR, the open-pr script now enumerates open PRs in the
release/<semver>namespace targeting the default branch and, for each one other than the standing PR:The "different version" criterion (rather than "lower version") is deliberate: the current run plans from the verified current default-branch head, so its version is authoritative in both directions, including a revert that shrinks the planned version.
An alternative was a single fixed branch (structurally duplicate-proof), but the branch name is load-bearing: release-validate derives the version from the merged PR's head ref, and consumer
release-triggerstubs filter onstartsWith(head.ref, 'release/'). Supersede-on-prepare fixes the invariant without breaking the forensic contract or any consumer stub. This also heals existing repos: the next prepare run in a consumer closes any stale PR already sitting open.Since the orchestration lives in an inline github-script block, the new test (
scripts/release-prepare-pr.test.mjs) extracts that script from the workflow YAML and executes it against a mocked GitHub API - the shipped code is what runs under test. It covers fresh creation, same-version refresh, supersede, the non-generated skip, and the tampered-branch rejection.Review focus: the provenance ladder in the supersede loop mirrors the existing branch-overwrite checks; confirm the fail-loud choice for tampered bot branches (versus skip-with-warning) matches the pipeline's philosophy.