Skip to content

Commit 3146098

Browse files
author
Stefano Verna
committed
Release with changesets and the shared toolchain, not np
RELEASE.md for this family of repos prescribed a bare `np patch` - literally always patch, decided on release day, with no changelog coming out of it at all. Changesets moves that decision into the PR that makes the change, and writes the changelog from it. The release script is @datocms/release-toolchain, the same one the four monorepos run, installed by git tag and never published to npm. In a repo that is one package it tags vX.Y.Z, which is what np tagged too, so the tag history is continuous. Claude-Session: https://claude.ai/code/session_01XaYAhzmiJwysZeq1XC5xrQ
1 parent 5b27478 commit 3146098

5 files changed

Lines changed: 2092 additions & 7889 deletions

File tree

.changeset/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Changesets
2+
3+
This folder holds the pending release notes for the next version.
4+
5+
Whenever you change something worth mentioning in a release, run `npx changeset`
6+
and answer the two prompts (which packages, and whether it's a patch/minor/major).
7+
That writes a small markdown file here, which you commit along with your changes.
8+
9+
At release time `npm run release` consumes every pending file: it computes the
10+
resulting versions, updates the `package.json`s and the `CHANGELOG.md`s, and
11+
deletes the files.
12+
13+
## Which bump level?
14+
15+
- `patch` — bug fixes only. It's the clearest signal in semver ("nothing new,
16+
just a fix"), so we don't spend it on anything else.
17+
- `minor` — new public API surface.
18+
- `major` — public API was removed or renamed.
19+
20+
## Prereleases
21+
22+
`npm run release:next` publishes under the `next` dist-tag, leaving `latest`
23+
untouched. It works in two modes:
24+
25+
- **as-is** — the pending changesets produce a normal version (say `4.1.0`)
26+
which is published under `next` instead of `latest`;
27+
- **real prerelease versions** — run `npx changeset pre enter next` first and
28+
the same command produces `4.1.0-next.0`, `4.1.0-next.1`, … That mode is
29+
recorded in `.changeset/pre.json`, which you commit. Run
30+
`npx changeset pre exit` when the line is done.
31+
32+
Either way the GitHub release is marked as a prerelease, so it never becomes
33+
the repository's "Latest release".
34+
35+
`npm run release` refuses to run while `.changeset/pre.json` exists, so a
36+
forgotten pre mode can't quietly turn a real release into a prerelease.

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@4.0.0/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"access": "public",
6+
"baseBranch": "main",
7+
"fixed": [],
8+
"linked": [],
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,25 @@ reported it before it is released.
297297
Previews are throwaway: they are never published to npm, and the URL stops
298298
resolving after a while. Never commit one to a `package.json` that ships.
299299

300+
## Releasing (maintainers)
301+
302+
Every user-visible change needs a changeset: run `npx changeset` from the repo
303+
root in the same PR, pick the bump level (`patch` is for bug fixes only, new API
304+
surface is `minor`) and commit the file it writes under `.changeset/`. That is
305+
where the changelog entry comes from, and it is where the bump level is decided
306+
— not on release day. See [`.changeset/README.md`](.changeset/README.md).
307+
308+
To release, from an up-to-date, clean `main`, run `npm run release`. It
309+
builds and tests, applies the pending changesets — bumping the version and
310+
writing `CHANGELOG.md` — publishes to npm, and only then tags `vX.Y.Z`, pushes,
311+
and creates a GitHub release whose notes come straight from that changelog
312+
entry. An interrupted release is resumed by re-running it, never undone. Use
313+
`npm run release:next` for a prerelease under the `next` dist-tag.
314+
315+
The script is
316+
[`@datocms/release-toolchain`](https://github.com/datocms/release-toolchain),
317+
shared with every other DatoCMS repository and pinned here by tag.
318+
300319
## License
301320

302321
This project is licensed under the MIT License.

0 commit comments

Comments
 (0)