Skip to content

Commit 0433753

Browse files
committed
docs: document release bump levels and the prerelease identifier
The release process was undocumented outside of a one-line usage comment, and the prerelease identifier is the part a maintainer has to get right: it selects the npm dist-tag consumers install from, and lerna silently defaults it to "alpha". Adds a CONTRIBUTING.md with the release and prerelease commands, following the structure used in the runner and pytest-codspeed repos, and expands the usage header of release.sh with the bump levels and worked examples.
1 parent db901f8 commit 0433753

2 files changed

Lines changed: 70 additions & 16 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Contributing
2+
3+
## Releasing a New Version
4+
5+
To create a new version, run:
6+
7+
```bash
8+
./scripts/release.sh patch # Increment PATCH component (e.g., 1.2.3 -> 1.2.4)
9+
./scripts/release.sh minor # Increment MINOR component (e.g., 1.2.3 -> 1.3.0)
10+
./scripts/release.sh major # Increment MAJOR component (e.g., 1.2.3 -> 2.0.0)
11+
```
12+
13+
All packages share a single version, bumped in lockstep by `lerna version`.
14+
15+
### Prereleases
16+
17+
A new prerelease series is started by passing the version explicitly, and
18+
continued with `prerelease`, which keeps the identifier it already has (the
19+
label between the `-` and the counter):
20+
21+
```bash
22+
./scripts/release.sh 5.8.0-beta.0 # 5.7.1 -> 5.8.0-beta.0
23+
./scripts/release.sh prerelease # 5.8.0-beta.0 -> 5.8.0-beta.1
24+
```
25+
26+
The identifier becomes the npm dist-tag, so a prerelease is installed only by
27+
asking for it:
28+
29+
```bash
30+
pnpm add @codspeed/vitest-plugin@beta
31+
```
32+
33+
`latest` keeps pointing at the most recent stable release, and `^5` never
34+
resolves to a prerelease.
35+
36+
### What happens
37+
38+
1. **`scripts/release.sh`**:
39+
- Refuses to run outside `main` or with a dirty working tree
40+
- Runs `lerna version`, which bumps every package, commits, creates a signed
41+
`vX.Y.Z` tag and pushes it
42+
43+
2. **CI release workflow** (`.github/workflows/release.yml`):
44+
- Triggered automatically when the tag is pushed
45+
- Builds the native addon prebuilds for linux-arm and darwin-arm
46+
- Builds the libraries
47+
- Publishes to npm via OIDC trusted publishing, under the dist-tag derived
48+
from the tag's prerelease identifier (`latest` for a plain `vX.Y.Z` tag)
49+
- Creates a draft GitHub release, flagged as a prerelease when the version
50+
has a prerelease identifier

‎scripts/release.sh‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/bin/bash
2-
# Usage: ./scripts/release.sh <major|minor|patch|premajor|preminor|prepatch|prerelease> [preid]
2+
#
3+
# Usage: ./scripts/release.sh <version>
4+
#
5+
# version major | minor | patch stable release
6+
# prerelease next prerelease of the current version,
7+
# keeping its identifier
8+
# X.Y.Z-<id>.N explicit version, used to start a new
9+
# prerelease series
10+
#
11+
# The identifier of a prerelease version (e.g. "beta" in 5.8.0-beta.0) becomes
12+
# the npm dist-tag the release workflow publishes under, so consumers opt in
13+
# with `pnpm add @codspeed/core@beta` while `latest` keeps pointing at the last
14+
# stable release.
15+
#
16+
# ./scripts/release.sh patch 5.7.1 -> 5.7.2 (dist-tag latest)
17+
# ./scripts/release.sh 5.8.0-beta.0 5.7.1 -> 5.8.0-beta.0 (dist-tag beta)
18+
# ./scripts/release.sh prerelease 5.8.0-beta.0 -> 5.8.0-beta.1 (dist-tag beta)
319
set -ex
420

521
# Fail if not on main
@@ -8,24 +24,12 @@ if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
824
exit 1
925
fi
1026

11-
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
12-
echo "Usage: ./release.sh <major|minor|patch|premajor|preminor|prepatch|prerelease> [preid]"
27+
if [ $# -ne 1 ]; then
28+
echo "Usage: ./release.sh <major|minor|patch|prerelease|X.Y.Z-id.N>"
1329
exit 1
1430
fi
1531

16-
# lerna defaults the prerelease identifier to "alpha"; the dist-tag the release
17-
# workflow publishes under is derived from it, so it must be spelled out for
18-
# any other channel.
19-
PREID=()
20-
if [ $# -eq 2 ]; then
21-
if [[ ! "$2" =~ ^[a-z][a-z0-9-]*$ || "$2" == "latest" ]]; then
22-
echo "Invalid prerelease identifier: '$2' (expected e.g. alpha, beta, rc)"
23-
exit 1
24-
fi
25-
PREID=(--preid "$2")
26-
fi
27-
2832
# Fail if there are any unstaged changes left
2933
git diff --exit-code
3034

31-
pnpm lerna version "$1" "${PREID[@]}" --force-publish --no-private --sign-git-tag
35+
pnpm lerna version "$1" --force-publish --no-private --sign-git-tag

0 commit comments

Comments
 (0)