Skip to content

Commit 0884f5e

Browse files
committed
ci: let the release pull request merge itself on a cadence switch
Changesets keeps one release pull request open and rewrites it as changesets land, so how often that pull request is merged is what decides the version sequence. Left to accumulate it collapses a backlog into a single bump — which is how nineteen changesets became one version and the numbers in between never existed. `AUTO_MERGE_RELEASE_PR` picks the cadence. Set to `true`, the release pull request merges itself once its required checks pass, so one merge to main is one release and the version tracks each change. Unset, nothing changes and a maintainer merges it when a release is wanted. This is not a blanket auto-merge: it only ever targets the changesets-authored branch, the repository still requires its status checks, and a major bump is gated on the pull request that introduces the changeset — so an unattended release cannot rename the major version on its own. The step never fails the run, because a version pull request left open costs a manual merge while a failure here would block npm, the Marketplace and the CDN behind it. CONTRIBUTING now states the bump levels and both cadences, so the version sequence is a documented choice rather than a side effect of merge timing.
1 parent 496169d commit 0884f5e

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,39 @@ jobs:
180180
fi
181181
echo "Cut ${tag} at ${GITHUB_SHA} (desktop ${prev} -> ${curr})."
182182
183+
# Release cadence switch. With this on, the version PR merges itself once
184+
# every required check passes, so one merge to main becomes one release
185+
# and the version tracks each change instead of collapsing a backlog of
186+
# changesets into a single jump. Turn it off to go back to releasing by
187+
# hand: `gh variable set AUTO_MERGE_RELEASE_PR --body false`.
188+
#
189+
# This is deliberately not a blanket auto-merge. It only ever targets the
190+
# changesets-authored branch, the repository requires its status checks
191+
# before any merge, and a major bump is gated separately on the pull
192+
# request that introduces the changeset — so an unattended release can
193+
# still never rename the major version on its own.
194+
#
195+
# Never fail the release over this: a version PR that stays open costs a
196+
# manual merge, while a failure here would block npm, the Marketplace and
197+
# the CDN behind it.
198+
- name: Enable auto-merge on the version PR
199+
if: steps.changesets.outputs.published != 'true' && vars.AUTO_MERGE_RELEASE_PR == 'true'
200+
continue-on-error: true
201+
env:
202+
GH_TOKEN: ${{ steps.release-bot.outputs.token }}
203+
run: |
204+
set -uo pipefail
205+
pr=$(gh pr list --head changeset-release/main --state open --json number --jq '.[0].number' || true)
206+
if [ -z "$pr" ] || [ "$pr" = "null" ]; then
207+
echo "::notice::No open version PR; nothing to auto-merge."
208+
exit 0
209+
fi
210+
if gh pr merge "$pr" --squash --auto; then
211+
echo "Auto-merge armed on #${pr}; it lands when its required checks pass."
212+
else
213+
echo "::warning::Could not arm auto-merge on #${pr}. Merge it by hand to cut the release."
214+
fi
215+
183216
- name: Request CodeRabbit review on version PR
184217
if: steps.changesets.outputs.published != 'true'
185218
env:

CONTRIBUTING.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@ This repo uses [changesets](https://github.com/changesets/changesets) to manage
8080
- Generate one with `pnpm changeset` and follow the prompts (which packages are touched, which bump level).
8181
- For repo-specific conventions on package selection and bump levels, see `.changeset/README.md`. When working in this repo with coding agents, use the `gen-changesets` skill.
8282

83+
### Bump levels
84+
85+
| Level | Use for | Example |
86+
| --- | --- | --- |
87+
| `patch` | A fix, or a small addition to something that already exists | `2.1.2``2.1.3` |
88+
| `minor` | A capability a user could not reach before | `2.1.3``2.2.0` |
89+
| `major` | A break: something that worked stops working, or works differently | `2.2.0``3.0.0` |
90+
91+
Prefer one changeset per pull request. A pull request that needs several is usually several releases wearing one hat, and the changelog cannot attribute the changes afterwards.
92+
93+
A `major` needs a maintainer's sign-off: the `changeset-policy` workflow fails a pull request that adds one unless it carries the `breaking-change-approved` label. A major renames the release and breaks every pinned install, and an npm publish cannot be taken back — so it is a decision, never a side effect of a large branch.
94+
95+
### Release cadence
96+
97+
Changesets keeps a `ci: release packages` pull request open on `main` and rewrites it as changesets land. Merging it cuts exactly one release, so how often it is merged is what decides the version sequence:
98+
99+
- Merged per change, versions follow each change: `2.1.2`, `2.1.3`, `2.1.4`, `2.2.0`.
100+
- Left to accumulate, a backlog collapses into one bump and the numbers in between never exist.
101+
102+
The repository variable `AUTO_MERGE_RELEASE_PR` chooses between the two. Set to `true`, the release pull request merges itself once its required checks pass, giving one release per change. Unset or `false`, a maintainer merges it when a release is wanted.
103+
83104
## Pull Requests
84105

85106
Every PR opens with the [PR template](.github/pull_request_template.md). PR titles must follow [Conventional Commits](#commit-convention); CI runs `pnpm lint`, `pnpm typecheck`, and `pnpm test` on every PR. Update user-facing docs in `docs/` when behavior changes — use the `gen-docs` skill when working with coding agents.

0 commit comments

Comments
 (0)