Skip to content

Commit edf1aa4

Browse files
Add one-command release process via npm version hooks
preversion checks: on main, clean tree, up to date with remote postversion: pushes commit + tag, triggering the CI release workflow Releasing is now: npm version patch|minor|major Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e83072f commit edf1aa4

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ npm run build # compile to dist/
159159
npm run dev # run directly with tsx (no build step)
160160
```
161161

162+
## Releasing
163+
164+
```bash
165+
npm version patch # bug fix (0.1.0 → 0.1.1)
166+
npm version minor # feature (0.1.0 → 0.2.0)
167+
npm version major # breaking (0.1.0 → 1.0.0)
168+
```
169+
170+
Checks that you're on a clean, up-to-date main branch, bumps the version, commits, tags, and pushes. CI publishes to npm.
171+
162172
## Built by
163173

164174
[Spacetime Technology](https://github.com/spacetime-technology)

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
],
1313
"scripts": {
1414
"prepare": "husky",
15+
"preversion": "bash scripts/prerelease.sh",
16+
"postversion": "git push --follow-tags origin main",
1517
"prepublishOnly": "npm run build",
1618
"build": "tsc -p tsconfig.build.json",
1719
"dev": "tsx src/index.ts",

‎scripts/prerelease.sh‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
branch=$(git branch --show-current)
5+
[ "$branch" = "main" ] || { echo "error: on branch '$branch', must be on main"; exit 1; }
6+
7+
[ -z "$(git status --porcelain)" ] || { echo "error: working tree is dirty — commit or stash first"; exit 1; }
8+
9+
git fetch origin main --quiet
10+
[ "$(git rev-parse HEAD)" = "$(git rev-parse origin/main)" ] || { echo "error: not up to date with origin/main — pull first"; exit 1; }
11+
12+
echo "checks passed"

0 commit comments

Comments
 (0)