Skip to content

fix(release): use pull requests for version bumps - #37

Open
nimarb wants to merge 1 commit into
mainfrom
nimarc/release-via-pr
Open

nimarb wants to merge 1 commit into
mainfrom
nimarc/release-via-pr

Conversation

@nimarb

@nimarb nimarb commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

The release script pushed version commits directly to protected main, so releases failed after creating a local commit and tag. bun run release now opens a version-bump PR. After merging and pulling main, bun run release -- --finalize creates a draft pinned to the checked commit.

Both required GitHub Actions checks must succeed. Branch pushes exclude tags, commits include only package.json, failed commits restore the original branch, and --resume retries a failed push or PR creation. Finalization reuses matching drafts and rejects conflicting tags. The docs distinguish GitHub staging approval from npm publication approval.

Validation:

  • bun test: 133 passed, including protected-remote, commit-failure recovery, staged/unstaged work preservation, CI, and draft retry tests.
  • bun run typecheck
  • bun build src/cli.ts --outdir dist --target node --format esm
  • bun run build

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T18:04:29.277860Z af0b627 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment on lines +66 to +72
const result = await run("gh", ["pr", "list", "--head", branch, "--base", "main", "--state", "all", "--json", "url,state,headRefOid"], { capture: true });
const pulls = JSON.parse(result.stdout) as { url: string; state: string; headRefOid: string }[];
if (pulls.length > 1) throw new Error(`Multiple release PRs for ${branch}; inspect them before retrying.`);
const existing = pulls[0];
if (existing && (existing.headRefOid !== head || existing.state === "CLOSED")) {
throw new Error(`Release PR conflicts with this commit: ${existing.url}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 A maintainer whose earlier release PR for a version was closed can never prepare that version again. The run fails only after the bump is committed, and the suggested --resume fails the same way. resumeReleasePullRequest lists PRs with --state all and throws for any CLOSED PR or one whose headRefOid differs from the new commit. prepareReleasePullRequest reaches this check only after git commit and onCommitted(). Fix: before switching or committing, detect a conflicting or closed PR for the branch. Then either ignore closed PRs when creating a fresh one, or fail early with guidance that does not point to --resume.

Why this was flagged

Trigger: a release PR for nimarc/release-vX.Y.Z was opened by bun run release and later closed, for example because PR CI failed and a fix went to main. The maintainer deletes the stale branch and reruns bun run release --version X.Y.Z. prepareReleasePullRequest (scripts/release-workflow.ts:28-41) creates the branch, commits package.json and calls onCommitted(), so releaseCommitted becomes true. It then calls resumeReleasePullRequest. That function runs gh pr list --head <branch> --state all (line 66), finds the CLOSED PR, and throws "Release PR conflicts with this commit" (lines 70-71). The catch in scripts/release.ts:706 prints "Retry with bun run release -- --resume". --resume runs the same check and always throws, and deleting the remote branch does not remove a closed PR from --state all. On the base branch there was no PR step, so this dead end did not exist. Now that version cannot be released through the script, and the maintainer is left with a stranded local commit on the release branch.

Verification: Trigger: a release PR from nimarc/release-vX.Y.Z was opened and then closed, and the maintainer reruns bun run release for the same version. In scripts/release-workflow.ts:28-41, prepareReleasePullRequest commits before calling resumeReleasePullRequest, whose lines 70-72 throw for a CLOSED PR. resumeRelease (release.ts:554-561) hits the same check, so it fails every time.

This branch has not been deployed

No deployments
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