Commit 5782ff9
authored
Split-job release workflow + --mode assertion flag (#91)
## Summary
- Adds `--expect-mode <version-pr|publish>` to `bumpy ci release` for
asserting the detected release mode (errors instead of silently
smart-routing when the runtime state doesn't match what the job
expects). Cannot be combined with `--auto-publish`.
- Restructures the project's own release workflow into three jobs: a
low-privilege `plan` job gating a `version-pr` job (PR-write creds only)
and a `publish` job (`environment: publish`, `id-token: write` for npm
trusted publishing).
- Rewrites [docs/github-actions.md](docs/github-actions.md) to lead with
the split-job workflow + setup steps. The single-job version is kept as
a simplified alternative.
## Why
Without a split, every push to main runs a job with `id-token: write`
(or `NPM_TOKEN` in env) — even when the workflow is only updating the
Version Packages PR. The split scopes those credentials to the publish
job only and lets the npm trusted publisher be pinned to a specific
GitHub Environment so rogue workflow files in the repo can't request a
valid OIDC token.
The `--expect-mode` flag turns the split's implicit `if:` gate into an
explicit runtime assertion: if the publish job somehow runs while bump
files are still present (a race, weird merge, or someone manually
re-triggers it), it fails fast instead of silently falling into the
version-pr code path.
## Setup required after merge
1. **Pin the npm trusted publisher to environment `publish`** on each
package's npmjs.com settings → Trusted Publishers → GitHub Actions.
_(Already done.)_
2. **(Optional) Create the `publish` environment manually** in repo
Settings → Environments and restrict deployment branches to `main` only.
This is cheap defense in depth — auto-create works too if you skip this.
_(Already done.)_
The new docs framing makes the split clearer:
- **Required setup**: npm trusted publisher pinning + `BUMPY_GH_TOKEN`.
That's it.
- **Optional hardening**: branch restriction on the environment
(recommended), required reviewers (usually redundant with `npmStaged:
true`).
## Notable internals
- `ReleaseOptions.mode: 'auto-publish' | 'version-pr'` renamed to
`autoPublish: boolean` — cleaner CLI-flag-to-internal mapping. New
`assertMode?: 'version-pr' | 'publish'` field carries the assertion. The
only caller is [packages/bumpy/src/cli.ts](packages/bumpy/src/cli.ts).
- `ciReleaseCommand` now computes `detectedMode` once and consolidates
the two near-identical "fall through to publish" branches.
- Auto-publish mode flagged as not recommended in the docs (loses the
review step + can't compose with the split-job pattern).
- The user-facing flag is `--expect-mode` (reads natural in YAML); the
internal field stays `assertMode` (technically accurate at the code
level).
## Test plan
- [x] `bun run check` — typecheck + format clean
- [x] `bun run test` — 225 tests pass
- [ ] Manual: confirm the new release workflow runs end-to-end on the
next merge to main (will exercise the `plan` → `version-pr` path here,
since this PR itself ships with a bump file)
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent afd465b commit 5782ff9
7 files changed
Lines changed: 261 additions & 133 deletions
File tree
- .bumpy
- .github/workflows
- docs
- packages/bumpy/src
- commands
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
36 | | - | |
| 34 | + | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
47 | 55 | | |
48 | | - | |
49 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
50 | 62 | | |
51 | 63 | | |
52 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
175 | | - | |
176 | 174 | | |
177 | 175 | | |
178 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
| |||
0 commit comments