|
3 | 3 | ## The Only Two Commands You Need |
4 | 4 |
|
5 | 5 | ```powershell |
6 | | -npm version patch # or minor or major |
| 6 | +npm run release:patch # or release:minor / release:major |
7 | 7 | git push --follow-tags |
8 | 8 | # done. go get a coffee. |
9 | 9 | ``` |
10 | 10 |
|
11 | 11 | That's it. The GitHub Action does the rest — lint, test, build, publish to npm via **Trusted Publishing** (OIDC). No tokens, no OTP, no manual publish. |
12 | 12 |
|
| 13 | +We keep `git push --follow-tags` as a separate command on purpose. `npm run release:*` only makes the local version commit and tag. The actual push is a remote side effect, so keeping it explicit gives you one last chance to inspect the commit, confirm the branch and remote, and avoid a script silently publishing from the wrong place. |
| 14 | + |
13 | 15 | --- |
14 | 16 |
|
15 | 17 | ## Wait, Which Version Bump Do I Use? |
16 | 18 |
|
17 | 19 | | Command | When to use it | Example | |
18 | 20 | |----------------------|-----------------------------------------------------|------------------| |
19 | | -| `npm version patch` | Bug fixes, typos, small tweaks | 0.0.1 → 0.0.2 | |
20 | | -| `npm version minor` | New features that don't break existing usage | 0.0.2 → 0.1.0 | |
21 | | -| `npm version major` | Breaking changes (renamed exports, removed options) | 0.1.0 → 1.0.0 | |
| 21 | +| `npm run release:patch` | Bug fixes, typos, small tweaks | 0.0.1 → 0.0.2 | |
| 22 | +| `npm run release:minor` | New features that don't break existing usage | 0.0.2 → 0.1.0 | |
| 23 | +| `npm run release:major` | Breaking changes (renamed exports, removed options) | 0.1.0 → 1.0.0 | |
22 | 24 |
|
23 | 25 | ## What Happens Behind the Scenes |
24 | 26 |
|
25 | | -1. `npm version patch` bumps the version in `package.json` and creates a git commit + tag (`v0.0.2`) |
| 27 | +1. `npm run release:patch` bumps the version in `package.json` and creates a git commit + tag (`v0.0.2`) |
26 | 28 | 2. `git push --follow-tags` pushes the commit and tag to GitHub |
27 | | -3. The `v*` tag triggers the **Publish** workflow (`.github/workflows/publish.yml`) |
28 | | -4. The workflow runs lint → test → build → publint → attw → `npm publish` |
29 | | -5. npm authenticates via **OIDC Trusted Publishing** — no secrets needed |
30 | | -6. Provenance attestation is generated automatically |
31 | | -7. The package appears on npm |
| 29 | +3. The release commit includes `[release]`, so the normal **CI** workflow skips that version-bump commit |
| 30 | +4. The `v*` tag triggers the **Publish** workflow (`.github/workflows/publish.yml`) |
| 31 | +5. The workflow runs lint → test → build → publint → attw → `npm publish` |
| 32 | +6. npm authenticates via **OIDC Trusted Publishing** — no secrets needed |
| 33 | +7. Provenance attestation is generated automatically |
| 34 | +8. The package appears on npm |
32 | 35 |
|
33 | 36 | ## How Trusted Publishing Works |
34 | 37 |
|
@@ -59,7 +62,7 @@ git add -A |
59 | 62 | git commit -m "describe what you changed" |
60 | 63 | ``` |
61 | 64 |
|
62 | | -Then try `npm version patch` again. |
| 65 | +Then try `npm run release:patch` again. |
63 | 66 |
|
64 | 67 | ### Publish workflow didn't trigger |
65 | 68 |
|
@@ -87,6 +90,10 @@ git push origin v0.0.X |
87 | 90 |
|
88 | 91 | If you add or change the publish workflow and tag in the same push, GitHub may not pick up the workflow. Always push the workflow change to `main` first, then create the tag. |
89 | 92 |
|
| 93 | +## Why CI Does Not Re-Run On Release Bumps |
| 94 | + |
| 95 | +The version bump created by `npm run release:patch` uses a commit message that includes `[release]`. The CI workflow checks for that marker and skips the branch-push run for that commit, while the tag push still triggers the publish workflow. |
| 96 | + |
90 | 97 | ## Do NOT |
91 | 98 |
|
92 | 99 | - Run `npm publish` manually from your laptop |
|
0 commit comments