|
12 | 12 | Supported bump types: patch, minor, major, patch-rc, minor-rc, major-rc, |
13 | 13 | next-rc, promote. When several changesets touch the same package, the |
14 | 14 | 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. |
16 | 17 |
|
17 | 18 | Changesets used by an rc release are kept and recorded in .changeset/pre.json |
18 | 19 | (package -> file names) instead of being deleted, so later runs skip them. The |
@@ -101,6 +102,13 @@ def validate(package: str, kind: str) -> None: |
101 | 102 | raise click.ClickException(f"{package}: next-rc requires an rc version (got {cur})") |
102 | 103 | if kind == "promote" and not cur.is_prerelease: |
103 | 104 | 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 | + ) |
104 | 112 |
|
105 | 113 |
|
106 | 114 | def apply(package: str, kind: str) -> None: |
@@ -153,9 +161,6 @@ def kept_entries(names: list[str], package: str, repo: str | None) -> list[str]: |
153 | 161 | entries = [] |
154 | 162 | for name in names: |
155 | 163 | path = CHANGESET_DIR / name |
156 | | - if not path.exists(): |
157 | | - click.echo(f"warning: kept changeset {path} is missing", err=True) |
158 | | - continue |
159 | 164 | bumps, summary = parse_changeset(path) |
160 | 165 | if summary and package in bumps: |
161 | 166 | 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]: |
190 | 195 | def main(rc_only: bool, notes: pathlib.Path | None, repo: str | None, check: bool) -> None: |
191 | 196 | pre: dict[str, list[str]] = json.loads(PRE_STATE.read_text()) if PRE_STATE.exists() else {} |
192 | 197 | 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) |
193 | 209 | files = sorted( |
194 | 210 | p |
195 | 211 | for p in CHANGESET_DIR.glob("*.md") |
|
0 commit comments