Skip to content

refactor: share is-release-pr check between changelog updates and stale closer - #9685

Draft
cryptodev-2s wants to merge 23 commits into
mainfrom
chore/share-is-release-pr-action
Draft

refactor: share is-release-pr check between changelog updates and stale closer#9685
cryptodev-2s wants to merge 23 commits into
mainfrom
chore/share-is-release-pr-action

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Explanation

Shares release PR detection between changelog updates and the stale release closer.

  • Extracts .github/actions/is-release-pr (merge-base + MetaMask/action-is-release)
  • update-changelogs and close-stale-release-prs both use it
  • Stale closer still prefilters release/*, then only closes PRs confirmed as releases (root version bump + RELEASE_COMMIT_PREFIX)

Stacked on #9655 for review with @mcmire.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes release automation and which PRs can be auto-closed; mis-detection could close the wrong PR or miss stale ones, but logic is aligned with existing changelog release checks.

Overview
Centralizes release PR detection in a new composite action .github/actions/is-release-pr (PR metadata, checkout head, merge-base, MetaMask/action-is-release). update-changelogs drops its inline steps and calls this action instead, wiring job outputs from the action’s head-sha / merge-base outputs.

The stale release closer gains a two-stage pipeline: paginated listing of open same-repo release/* PRs, then a matrix job that runs the shared action and uploads confirmed PR numbers as artifacts. The close job only runs close-stale-release-prs.mts when that list is non-empty, passing RELEASE_PR_NUMBERS. The script no longer discovers release PRs by branch name alone—it fetches each listed PR and applies fork/skip-label guards before staleness close.

Docs (releasing.md) note that auto-close uses the same release check as changelogs, not only release/* branch naming.

Reviewed by Cursor Bugbot for commit 7c54446. Bugbot is set up for automated code reviews on this repo. Configure here.

cryptodev-2s and others added 22 commits July 24, 2026 17:33
Abandoned release/* PRs block others from starting new releases; close them, delete the branch, and document the escape-hatch label.
Re-fetch each PR before acting, close before commenting, and continue on per-PR failures so a merge race or failed close cannot leave a misleading comment or abort the whole run.
Wrap per-PR pulls.get and GraphQL merge-queue lookups in try/catch so one transient failure does not abort the rest of the stale-close loop.
Abort if updated_at, head SHA/ref, labels, staleness, or merge-queue state changed after the earlier refresh so a late push is not discarded.
Compare the complete label set on the final pre-close refresh, and re-fetch the branch ref immediately before deleteRef so a late push is not discarded.
Post the stale-close comment only after the delete attempt so it reports whether the branch was removed, skipped due to a tip move, or failed to delete.
…tants

Move the github-script body to .github/scripts and replace env-parsed STALE_HOURS/EXEMPT_LABEL with script constants, per review feedback.
…c lint

Break the script into named functions for eligibility, merge-state, close, delete, and comment, and satisfy jsdoc/require-param-description.
Use SKIP_LABEL and a single stale duration, rename helpers/vars, detect forks via head.repo.fork, and simplify the close comment to only call out branch-delete failures.
…ckages

Replace the github-script CJS entrypoint with an executable tsx script that uses @actions/github and @actions/core, and fetch PR eligibility via a single GraphQL snapshot query.
Rename to .mts so TypeScript treats the file as ESM and can import the ESM-only @actions packages, unblocking lint:tsc.
Rename commentOnPull to commentOnPullRequest, and stop describing intentional tip-move skips as failed branch deletions.
One GraphQL eligibility check plus tip verification before delete is enough for this cron job.
Extract the update-changelogs release check into a reusable action and use it to confirm candidates before auto-closing stale release PRs.
@cryptodev-2s
cryptodev-2s requested a review from a team as a code owner July 28, 2026 16:41
Comment thread .github/workflows/close-stale-release-prs.yml Fixed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 869c4b3. Configure here.

Comment thread .github/workflows/close-stale-release-prs.yml
Comment thread .github/workflows/close-stale-release-prs.yml Outdated
Comment thread .github/workflows/close-stale-release-prs.yml
Paginate candidate discovery, keep unique artifact filenames, continue closing after partial matrix failures, and pass PR numbers via env.
@cryptodev-2s cryptodev-2s reopened this Jul 29, 2026
@cryptodev-2s
cryptodev-2s marked this pull request as draft July 29, 2026 16:45
Base automatically changed from chore/close-stale-release-prs to main July 29, 2026 18:44
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