Skip to content

Commit e0ad825

Browse files
cloudwebrtcclaude
andcommitted
ci: only accept next-rc/promote while at an rc; validate kept changesets
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent dfc6dea commit e0ad825

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎.changeset/README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ Mixing stable and rc types for one package, or combining `promote` with
3232
anything else, is rejected. Only rc types are allowed on branches other than
3333
`main`.
3434

35+
While a package is at an rc (e.g. `1.6.0.rc1`), only `next-rc` and `promote`
36+
are accepted for it, so fixes land in the next rc and the planned `1.6.0` still
37+
ships. Any other type would skip it (`patch` would release `1.6.1`). To move
38+
to a different version line, use the Manual Version Bump workflow below.
39+
3540
## How releases happen
3641

3742
1. Every PR is checked by the **Changeset** workflow; invalid changesets fail
@@ -54,3 +59,8 @@ bump type. It opens a `release/<prefix>-v<version>` PR without reading any
5459
changeset; merging it publishes the same way as a changeset release PR.
5560
It doesn't touch `.changeset/`, so changesets kept from rc releases stay until
5661
that package's next changeset stable release.
62+
63+
The two flows don't know about each other: a manual bump doesn't close an open
64+
`Release: ...` changeset PR for the same package (or the other way round), and
65+
both change that package's version, so once one merges the other conflicts.
66+
Close the stale one before merging.

‎.github/changesets.py‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
Supported bump types: patch, minor, major, patch-rc, minor-rc, major-rc,
1313
next-rc, promote. When several changesets touch the same package, the
1414
largest bump wins (an explicit X-rc wins over next-rc). Mixing stable and
15-
rc bumps, or combining promote with anything else, is an error.
15+
rc bumps, or combining promote with anything else, is an error. While a
16+
package is at an rc, only next-rc and promote are accepted for it.
1617
1718
Changesets used by an rc release are kept and recorded in .changeset/pre.json
1819
(package -> file names) instead of being deleted, so later runs skip them. The
@@ -101,6 +102,13 @@ def validate(package: str, kind: str) -> None:
101102
raise click.ClickException(f"{package}: next-rc requires an rc version (got {cur})")
102103
if kind == "promote" and not cur.is_prerelease:
103104
raise click.ClickException(f"{package}: promote requires a pre-release (got {cur})")
105+
# Any other bump would move past the rc's planned stable version, e.g.
106+
# patch on 1.4.0.rc1 releases 1.4.1 and 1.4.0 never ships.
107+
if cur.is_prerelease and kind not in ("next-rc", "promote"):
108+
raise click.ClickException(
109+
f"{package}: {kind} is not allowed while at pre-release {cur}; "
110+
"use next-rc or promote (or the Manual Version Bump workflow)"
111+
)
104112

105113

106114
def apply(package: str, kind: str) -> None:
@@ -153,9 +161,6 @@ def kept_entries(names: list[str], package: str, repo: str | None) -> list[str]:
153161
entries = []
154162
for name in names:
155163
path = CHANGESET_DIR / name
156-
if not path.exists():
157-
click.echo(f"warning: kept changeset {path} is missing", err=True)
158-
continue
159164
bumps, summary = parse_changeset(path)
160165
if summary and package in bumps:
161166
entries.append(f"`{bumps[package]}` {summary}{changeset_origin(path, repo)}")
@@ -190,6 +195,17 @@ def kept_entries(names: list[str], package: str, repo: str | None) -> list[str]:
190195
def main(rc_only: bool, notes: pathlib.Path | None, repo: str | None, check: bool) -> None:
191196
pre: dict[str, list[str]] = json.loads(PRE_STATE.read_text()) if PRE_STATE.exists() else {}
192197
kept = {name for names in pre.values() for name in names}
198+
# A kept changeset still owes its entry to the stable release notes.
199+
missing = sorted(name for name in kept if not (CHANGESET_DIR / name).exists())
200+
if missing:
201+
raise click.ClickException(
202+
f"changesets kept from rc releases are missing: {missing} "
203+
f"(restore them, or remove them from {PRE_STATE} on purpose)"
204+
)
205+
# Parse them now too, so a broken kept changeset fails the PR check
206+
# instead of the stable release.
207+
for name in sorted(kept):
208+
parse_changeset(CHANGESET_DIR / name)
193209
files = sorted(
194210
p
195211
for p in CHANGESET_DIR.glob("*.md")

0 commit comments

Comments
 (0)