Skip to content

Commit 8e57e45

Browse files
CHORE: Added release scripts and avoided double CI issue in CI
1 parent d11f38c commit 8e57e45

4 files changed

Lines changed: 31 additions & 17 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616

1717
jobs:
1818
ci:
19+
if: github.event_name != 'push' || !contains(github.event.head_commit.message, '[release]')
1920
runs-on: ubuntu-latest
2021
strategy:
2122
matrix:

WORKFLOWS.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This document describes the GitHub Actions workflows and common development proc
77
### CI (`.github/workflows/ci.yml`)
88

99
Runs on every push to `main` and on pull requests (ignoring docs/website/markdown changes).
10+
Release bump commits created by the `release:*` scripts are skipped so tagging a version does not run CI twice.
1011

1112
- Tests against Node 20 and 22
1213
- Steps: `npm ci``lint``test``build``publint``attw`
@@ -34,19 +35,21 @@ Runs when `website/` or `docs/` files change on `main`, or via manual dispatch.
3435

3536
2. Bump the version:
3637
```sh
37-
npm version patch # bug fixes (0.1.1 → 0.1.2)
38-
npm version minor # new features (0.1.1 → 0.2.0)
39-
npm version major # breaking changes (0.1.1 → 1.0.0)
38+
npm run release:patch # bug fixes (0.1.1 → 0.1.2)
39+
npm run release:minor # new features (0.1.1 → 0.2.0)
40+
npm run release:major # breaking changes (0.1.1 → 1.0.0)
4041
```
41-
This updates `package.json`, creates a git commit, and creates a `v*` tag.
42+
This updates `package.json`, creates a `[release]` git commit, and creates a `v*` tag.
4243

4344
3. Push the commit and tag:
4445
```sh
45-
git push && git push --tags
46+
git push --follow-tags
4647
```
4748

4849
4. The **Publish** Action triggers automatically, runs all checks, and publishes to npm.
4950

5051
5. Monitor the run at https://github.com/PredictabilityAtScale/promptopskit/actions to confirm it succeeds.
5152

52-
That's it — three commands: `npm version`, `git push`, `git push --tags`.
53+
We keep the push outside the `release:*` scripts so the remote-changing step stays explicit and reviewable.
54+
55+
That's it — two commands: `npm run release:*`, `git push --follow-tags`.

docs/publishing.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,35 @@
33
## The Only Two Commands You Need
44

55
```powershell
6-
npm version patch # or minor or major
6+
npm run release:patch # or release:minor / release:major
77
git push --follow-tags
88
# done. go get a coffee.
99
```
1010

1111
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.
1212

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+
1315
---
1416

1517
## Wait, Which Version Bump Do I Use?
1618

1719
| Command | When to use it | Example |
1820
|----------------------|-----------------------------------------------------|------------------|
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 |
2224

2325
## What Happens Behind the Scenes
2426

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`)
2628
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
3235

3336
## How Trusted Publishing Works
3437

@@ -59,7 +62,7 @@ git add -A
5962
git commit -m "describe what you changed"
6063
```
6164

62-
Then try `npm version patch` again.
65+
Then try `npm run release:patch` again.
6366

6467
### Publish workflow didn't trigger
6568

@@ -87,6 +90,10 @@ git push origin v0.0.X
8790

8891
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.
8992

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+
9097
## Do NOT
9198

9299
- Run `npm publish` manually from your laptop

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@
9292
"test:watch": "vitest",
9393
"lint": "tsc --noEmit",
9494
"clean": "rimraf dist",
95+
"release:patch": "npm version patch -m \"chore(release): %s [release]\"",
96+
"release:minor": "npm version minor -m \"chore(release): %s [release]\"",
97+
"release:major": "npm version major -m \"chore(release): %s [release]\"",
9598
"prepublishOnly": "npm run lint && npm run test && npm run build"
9699
},
97100
"keywords": [

0 commit comments

Comments
 (0)