Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| 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}`); | ||
| } |
There was a problem hiding this comment.
🔴 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.
The release script pushed version commits directly to protected
main, so releases failed after creating a local commit and tag.bun run releasenow opens a version-bump PR. After merging and pulling main,bun run release -- --finalizecreates 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--resumeretries 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 typecheckbun build src/cli.ts --outdir dist --target node --format esmbun run build