Skip to content

chore(release): key changeset-released ledger by target branch - #12201

Merged
zkochan merged 1 commit into
mainfrom
release-pr-ledger-detection
Jun 4, 2026
Merged

zkochan merged 1 commit into
mainfrom
release-pr-ledger-detection

Conversation

@zkochan

@zkochan zkochan commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

Problem

Releases now land via a PR from an ad-hoc branch (new-release, release2, bump-versions, …) rather than a commit pushed straight to the target branch. __utils__/scripts/src/bump.ts keyed the .changeset-released ledger off git rev-parse --abbrev-ref HEAD — the current branch — so every release scattered into a new per-PR file instead of accumulating in main.txt. No correctness bug (the wrapper reads the union of all *.txt), but the ledger fragmented into 9 stray files.

Changes

  • bump.ts: new exported releaseBranchToTarget() recovers the target from a release-pr/<target> branch name (slashes preserved, e.g. release-pr/release/11.1 → release-11.1.txt); a bare name is its own target. Applied to both the detected branch and RELEASE_BRANCH. Renamed detectCurrentBranch → detectReleaseBranch. Added 4 tests (all 20 pass).
  • .github/workflows/create-release-pr.yml (new): manually-dispatched workflow with a target input (default main). Checks out release-pr/<target>, runs pnpm bump, commits chore(release): <version>, force-pushes, and opens/reuses a PR against the target. The branch convention makes the ledger key itself automatically.
  • Ledger cleanup: removed the 9 accumulated .txt files. Verified safe — zero overlap with the 11 pending changesets, and no live branch (release-fix, release/11.1) reintroduces an already-released changeset on a normal merge (confirmed via merge-base). The mechanism is kept and self-heals: the next release writes a fresh main.txt.
  • README: documents the release-pr/<target> convention.

Notes

  • The workflow uses secrets.UPDATE_LOCKFILE_TOKEN (the existing write+PR PAT, so the release PR triggers CI). Swap for a dedicated release secret if preferred.
  • No changeset: @pnpm/scripts is private and .github isn't published.

Written by an agent (Claude Code, claude-opus-4-8).

Summary by CodeRabbit

  • New Features

    • Added automated GitHub Actions workflow to create and update release pull requests with configurable target branch selection and automatic version bumping.
  • Documentation

    • Enhanced release workflow documentation with guidance on release branch naming conventions and target branch resolution.
  • Chores

    • Cleared internal release tracking records.

Releases now land via a PR from an ad-hoc branch rather than a commit
pushed straight to the target, so `bump.ts` keyed the ledger off the
ephemeral PR branch and scattered each release into its own file instead
of accumulating in `main.txt`.

Recover the target from a `release-pr/<target>` branch name, add a
manually-dispatched workflow that creates such a PR, and drop the
accumulated per-PR ledger files (verified inert: no overlap with pending
changesets, no live branch reintroduces a released changeset on merge).
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a19d3cf-d71d-470a-98be-d1652419dd8b

📥 Commits

Reviewing files that changed from the base of the PR and between 8e5e764 and b6697bb.

📒 Files selected for processing (13)
  • .changeset-released/README.md
  • .changeset-released/bump-versions.txt
  • .changeset-released/main.txt
  • .changeset-released/new-release.txt
  • .changeset-released/release-11-2-1.txt
  • .changeset-released/release-11-2-2.txt
  • .changeset-released/release-11-2.txt
  • .changeset-released/release-11-5-1.txt
  • .changeset-released/release-11.0.txt
  • .changeset-released/release2.txt
  • .github/workflows/create-release-pr.yml
  • __utils__/scripts/src/bump.ts
  • __utils__/scripts/test/bump.ts
💤 Files with no reviewable changes (9)
  • .changeset-released/release2.txt
  • .changeset-released/release-11-5-1.txt
  • .changeset-released/release-11-2.txt
  • .changeset-released/release-11-2-1.txt
  • .changeset-released/main.txt
  • .changeset-released/release-11.0.txt
  • .changeset-released/new-release.txt
  • .changeset-released/release-11-2-2.txt
  • .changeset-released/bump-versions.txt
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: windows-latest / Node.js 22.13.0 / Test
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Follow Standard Style with trailing commas, preferring functions over classes, and declaring functions after they are used (relying on hoisting)
Use a single options object instead of multiple parameters when a function needs more than two or three arguments
Follow Import Order: Standard libraries first, then external dependencies (alphabetically), then relative imports
Write self-documenting code where function names, parameters, and types explain what a function does without requiring prose comments
Do not write comments that restate what the code already says; refactor via renaming, splitting helpers, or restructuring instead
Do not repeat documentation at call sites that already exists in JSDoc on the callee; update JSDoc once for all call sites to benefit
Use JSDoc only for a function's contract (preconditions, postconditions, edge cases, why the function exists), not for re-narrating the body
Do not record past implementation shape, refactor history, or 'the previous code did X' framing in code; use git log and git blame instead
Write comments only when: the reason for code is non-obvious (hidden invariant, workaround for known bug, deliberate exception), or the right name doesn't fit (temporary technical constraint)

Files:

  • __utils__/scripts/test/bump.ts
  • __utils__/scripts/src/bump.ts
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-25T12:36:42.202Z
Learning: User-visible changes (CLI flags, defaults, environment variables, lockfile/manifest/state-file formats, error codes/messages, log emissions, store layout, hook semantics) in pnpm must be mirrored to pacquet in the same PR
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pnpr/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:24.797Z
Learning: Use Conventional Commits with 'pnpr' as the scope in commit messages (e.g., feat(pnpr): ..., fix(pnpr): ...)
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Reference the upstream pnpm commit/PR when porting code from pnpm in commit messages
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-25T12:36:42.202Z
Learning: Version pnpm CLI patch for bug fixes, internal refactors, and changes that don't require documentation; minor for new features/settings that should be documented; major for breaking changes
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Match how the same feature is implemented in the TypeScript pnpm CLI — any change in pacquet must match pnpm's behavior, logic, edge cases, config resolution, error messages, file/lockfile formats, and existing tests
📚 Learning: 2026-05-25T12:36:42.202Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-25T12:36:42.202Z
Learning: Create a changeset file in .changeset directory for changes affecting published packages, with explicit version bump types (patch, minor, major)

Applied to files:

  • .changeset-released/README.md
📚 Learning: 2026-05-29T18:03:15.372Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Match how the same feature is implemented in the TypeScript pnpm CLI — any change in pacquet must match pnpm's behavior, logic, edge cases, config resolution, error messages, file/lockfile formats, and existing tests

Applied to files:

  • __utils__/scripts/test/bump.ts
📚 Learning: 2026-05-25T12:36:42.202Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-25T12:36:42.202Z
Learning: Applies to **/*.test.{ts,tsx} : Use util.types.isNativeError() instead of instanceof Error for error type checking in Jest tests

Applied to files:

  • __utils__/scripts/test/bump.ts
📚 Learning: 2026-05-20T21:18:56.391Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11778
File: pacquet/crates/resolving-local-resolver/tests/resolve.rs:365-372
Timestamp: 2026-05-20T21:18:56.391Z
Learning: In `pacquet/crates/resolving-local-resolver/tests/resolve.rs`, the test `fail_when_resolving_from_not_existing_directory_an_injected_dependency` intentionally uses `injected: false`. The test is a verbatim port of the upstream pnpm TypeScript test (resolving/local-resolver/test/index.ts at ef87f3ccff). The `injected` flag only affects the file/link protocol choice for plain directory paths; when the `file:` scheme is explicit in the bare specifier, the flag has no effect on the resolution code path. The misleading test name is inherited from upstream.

Applied to files:

  • __utils__/scripts/test/bump.ts
📚 Learning: 2026-05-29T18:03:15.372Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Applies to pacquet/**/tests/**/*.rs : Port relevant pnpm tests to Rust tests whenever they translate when porting behavior from pnpm

Applied to files:

  • __utils__/scripts/test/bump.ts
📚 Learning: 2026-05-29T18:03:15.372Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Applies to pacquet/**/*.rs : Tests are documentation — do not duplicate test scenarios, edge cases, failure modes, or worked examples in prose when they are already captured by tests

Applied to files:

  • __utils__/scripts/test/bump.ts
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.

Applied to files:

  • __utils__/scripts/test/bump.ts
  • __utils__/scripts/src/bump.ts
📚 Learning: 2026-05-25T12:36:42.202Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-25T12:36:42.202Z
Learning: User-visible changes (CLI flags, defaults, environment variables, lockfile/manifest/state-file formats, error codes/messages, log emissions, store layout, hook semantics) in pnpm must be mirrored to pacquet in the same PR

Applied to files:

  • __utils__/scripts/src/bump.ts
  • .github/workflows/create-release-pr.yml
📚 Learning: 2026-05-25T12:36:42.202Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-05-25T12:36:42.202Z
Learning: Always explicitly include 'pnpm' in changeset files with appropriate version bump (patch, minor, or major)

Applied to files:

  • __utils__/scripts/src/bump.ts
🔇 Additional comments (17)
.changeset-released/README.md (1)

23-29: LGTM!

__utils__/scripts/src/bump.ts (3)

29-46: LGTM!


116-126: LGTM!


132-132: LGTM!

__utils__/scripts/test/bump.ts (1)

14-14: LGTM!

Also applies to: 18-34

.github/workflows/create-release-pr.yml (12)

1-9: LGTM!


11-13: LGTM!


15-19: LGTM!


21-24: LGTM!


26-32: LGTM!


39-51: LGTM!


53-57: LGTM!


59-66: LGTM!


68-71: LGTM!


73-82: LGTM!


84-105: LGTM!


34-37: ⚡ Quick win

Confirm pnpm/setup’s runtime input and value format.
In .github/workflows/create-release-pr.yml (lines 34-37), the workflow uses pnpm/setup@b1cac37306e39c21283b9dd6cb0ac288fb35ba6b with runtime: [email protected]. GitHub API lookups for pnpm/setup and pnpm/action-setup timed out in this environment, so the action’s existence and whether it defines/supports a runtime input (with node@... syntax) is unconfirmed. Confirm from the action’s action.yml/README that runtime is supported and the value format is correct.


📝 Walkthrough

Walkthrough

This PR implements automated release PR creation for pnpm. It introduces a new GitHub Actions workflow that manually triggers release PR preparation, a branch normalization helper to map ephemeral release-pr/<target> branch names to their actual targets for ledger keying, and documentation explaining the naming convention.

Changes

Release PR Automation with Branch Normalization

Layer / File(s) Summary
Branch-to-target normalization contract and tests
__utils__/scripts/src/bump.ts, __utils__/scripts/test/bump.ts
Defines RELEASE_PR_PREFIX and exports releaseBranchToTarget(branch: string) to strip release-pr/ prefixes and normalize branch names for ledger keying. Jest tests validate prefix stripping, slash preservation, passthrough of non-prefixed branches, and error handling for malformed input.
Bump script branch detection integration
__utils__/scripts/src/bump.ts
Replaces detectCurrentBranch() with detectReleaseBranch(), which respects RELEASE_BRANCH environment override, detects detached HEAD, and normalizes the selected branch via releaseBranchToTarget() before recording consumed changesets to the .changeset-released/<target>.txt ledger.
Create Release PR workflow automation
.github/workflows/create-release-pr.yml
Introduces create-release-pr.yml workflow triggered manually with a target input (default main). Sets up repository write permissions, per-target concurrency control, checks out code, installs pnpm/Node, prepares the release-pr/<target> branch from the target tip, runs pnpm bump, commits and force-pushes updates when changes exist, and creates a release PR only if one is not already open.
Release workflow documentation
.changeset-released/README.md
Documents the release-pr/<target> naming convention, explains how the bump wrapper detects and normalizes the target branch, describes the RELEASE_BRANCH environment variable override, and clarifies changeset version failure rollback behavior.

Sequence Diagram

sequenceDiagram
  participant User
  participant Workflow as create-release-pr.yml
  participant BumpScript as pnpm bump
  participant Git
  participant GitAPI as GitHub API
  User->>Workflow: Trigger with target=main
  Workflow->>Git: Fetch target, create release-pr/main
  Workflow->>BumpScript: Run pnpm bump
  BumpScript->>BumpScript: detectReleaseBranch() → normalize to main
  BumpScript->>BumpScript: Update .changeset-released/main.txt
  Workflow->>Git: Commit and force-push release-pr/main
  Workflow->>GitAPI: Check for existing PR
  alt No PR exists
    Workflow->>GitAPI: Create PR: release-pr/main → main
  else PR exists
    Workflow->>Workflow: Skip PR creation
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • pnpm/pnpm#11479: Modifies __utils__/scripts/src/bump.ts to resolve RELEASE_BRANCH for ledger keying, directly overlapping with the branch normalization logic in this PR.
  • pnpm/pnpm#11817: Adds entries to .changeset-released/release-11-2-2.txt that this PR deletes, creating a direct conflict on the same ledger file.

Poem

🐰 Release branches dance in release-pr/ style,
A workflow swift, normalization's guile—
Strip the prefix, find the target true,
Automated PRs sprouting, tried and new!
Let changesets version, let ledgers sing,
What a release revolution this brings! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: keying the changeset-released ledger by target branch instead of PR branch names, which is the core problem being solved.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch release-pr-ledger-detection

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zkochan
zkochan marked this pull request as ready for review June 4, 2026 21:06
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Review Summary by Qodo

Key changeset-released ledger by target branch via release-pr workflow

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Recover release target from release-pr/ branch naming convention
• Add releaseBranchToTarget() function to extract target from PR branch names
• Create manually-dispatched workflow to generate release PRs with correct branch naming
• Clean up 9 accumulated per-PR ledger files that fragmented release history
• Update documentation explaining the release-PR branch naming convention
Diagram
flowchart LR
  A["Release PR Branch<br/>release-pr/target"] -->|"releaseBranchToTarget()"| B["Extract Target<br/>main, release/11.1"]
  B -->|"branchToFilename()"| C["Ledger File<br/>main.txt, release-11.1.txt"]
  D["create-release-pr.yml<br/>Workflow"] -->|"Creates branch"| A
  D -->|"Runs pnpm bump"| E["Consolidate<br/>Changesets"]
  E -->|"Writes to"| C

Loading

Grey Divider

File Changes

1. __utils__/scripts/src/bump.ts ✨ Enhancement +23/-4

Add release branch target detection logic

utils/scripts/src/bump.ts


2. __utils__/scripts/test/bump.ts 🧪 Tests +19/-0

Add tests for releaseBranchToTarget function

utils/scripts/test/bump.ts


3. .changeset-released/README.md 📝 Documentation +7/-1

Document release-pr branch naming convention

.changeset-released/README.md


View more (10)
4. .changeset-released/bump-versions.txt 🐞 Bug fix +0/-17

Remove accumulated per-PR ledger file

.changeset-released/bump-versions.txt


5. .changeset-released/main.txt 🐞 Bug fix +0/-37

Remove accumulated per-PR ledger file

.changeset-released/main.txt


6. .changeset-released/new-release.txt 🐞 Bug fix +0/-10

Remove accumulated per-PR ledger file

.changeset-released/new-release.txt


7. .changeset-released/release-11-2-1.txt 🐞 Bug fix +0/-3

Remove accumulated per-PR ledger file

.changeset-released/release-11-2-1.txt


8. .changeset-released/release-11-2-2.txt 🐞 Bug fix +0/-2

Remove accumulated per-PR ledger file

.changeset-released/release-11-2-2.txt


9. .changeset-released/release-11-2.txt 🐞 Bug fix +0/-11

Remove accumulated per-PR ledger file

.changeset-released/release-11-2.txt


10. .changeset-released/release-11-5-1.txt 🐞 Bug fix +0/-8

Remove accumulated per-PR ledger file

.changeset-released/release-11-5-1.txt


11. .changeset-released/release-11.0.txt 🐞 Bug fix +0/-22

Remove accumulated per-PR ledger file

.changeset-released/release-11.0.txt


12. .changeset-released/release2.txt 🐞 Bug fix +0/-9

Remove accumulated per-PR ledger file

.changeset-released/release2.txt


13. .github/workflows/create-release-pr.yml ✨ Enhancement +105/-0

Add workflow to create release PRs with target branch

.github/workflows/create-release-pr.yml


Grey Divider

Qodo Logo

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