Pre-merge cherry-pick flow for patch-labeled PRs - #151
Merged
Conversation
- scripts/patch-release.js: read version baseline from origin/<release> ref instead of the working tree (which is usually main and ahead of the release branch, producing a wrong target version). - .github/workflows/cherry-pick-patch.yml: rewritten to a pre-merge flow. On `labeled`/`synchronize` (re)create cherry-pick/<release>/pr-<N> off the release branch, cherry-pick the PR commits, dispatch integration tests on success, commit conflict markers and @-mention Claude on failure. On merge, fast-forward into the release branch. On unlabel, tear down. - .github/workflows/report-cherry-pick-tests.yml: workflow_run listener that updates a sticky comment on the original PR with pass/fail when Integration Tests on a cherry-pick branch finish. Gated on head_repository == repository to block fork spoofing. - .github/scripts/upsert-sticky-comment.js: shared sticky-comment upsert helper keyed by marker string. scripts/patch-release.js was reformatted by prettier (2-space → tabs); the semantic change is the readPackageVersion(ref) addition and its two callers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
Reviewed; no blockers found. |
This was referenced May 18, 2026
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.
Summary
Two changes to the patch-release pipeline:
Bug fix in
scripts/patch-release.js: the script computed the next-version target by readingpackage.jsonfrom the working tree (typicallymain), so the proposed version was based onmain's version, not the release branch's. Now reads viagit show origin/<release>:package.jsonso the target is calculated against the correct baseline.New pre-merge cherry-pick flow (replaces the post-merge flow):
pull_requestlabeledpatch(and onsynchronizewhile labeled): create/resetcherry-pick/<release>/pr-<N>off the release branch, cherry-pick the PR commits, force-push.integration-tests.yamlworkflow against that branch. A sticky comment on the original PR links the run.@claudeto suggest a resolution patch as a comment (no auto-push).unlabeled: delete the branch and mark the sticky cancelled.closed && merged: re-pick from the final merge SHA and fast-forward into the release branch.report-cherry-pick-tests.yml) listens toworkflow_runcompletion for Integration Tests and updates the same sticky comment with pass/fail.This means patch test results show up on the original PR — no separate cherry-pick PR — and we get a pre-merge signal on whether the change is safe against the release branch.
Where to focus review
.github/workflows/cherry-pick-patch.yml— the main logic. Branches handled in theCherry-pickstep: open PR (merge_base..HEAD) vs merged PR (merge commit with-m 1if it's a true merge).IS_MERGEDis driven by the API'smergedfield, not the event action, so labeling an already-merged PR still triggers the fast-forward into the release branch.report-cherry-pick-tests.yml— gated onhead_repository.full_name == github.repositoryso a fork can't spoof acherry-pick/...branch name to inject comments. PR number is parsed from the branch name.upsert-sticky-comment.js— passes the comment body via stdin (-f body=@-) to avoid shell-escape issues with the multi-line markdown body.scripts/patch-release.js— the diff looks huge because prettier converted 2-space indentation to tabs. The only semantic change is the newreadPackageVersion(ref)function (around L186) and its two callers passingorigin/${RELEASE_BRANCH}(around L280-281).Things to verify before relying on it
@claudein a sticky comment expectingclaude-mention.ymlto pick it up. If that workflow ignores comments authored bygithub-actions[bot], the suggestion won't fire; we'd need to call the reusable directly instead.gh workflow runfollowed by short polling for the run id is best-effort — theworkflow_runreporter is the source of truth, so a missed initial link is cosmetic.🤖 Generated by Claude Opus 4.7 (1M context).