Skip to content

Commit 105d54d

Browse files
bmuenzenmeyerclaude
andcommitted
ci: adopt Changesets for versioning and publishing
Replace the bespoke package.json-diff publish flow with Changesets so releases produce a CHANGELOG.md, git tags, and GitHub Releases. - Add @changesets/cli + @changesets/changelog-github and changeset, changeset:version, and release scripts - Add .changeset config (changelog-github, public access, main base) - Replace publish.yml with release.yml using changesets/action, keeping npm OIDC trusted publishing and the Slack notification - Document the changeset and release flow in CONTRIBUTING.md Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8851110 commit 105d54d

8 files changed

Lines changed: 1574 additions & 164 deletions

File tree

.changeset/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool
4+
that works with multi-package repos, or single-package repos to help you version and publish your
5+
code. You can find the full documentation for it
6+
[in our repository](https://github.com/changesets/changesets)
7+
8+
We have a quick list of common questions to get you started engaging with this project in
9+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/adopt-changesets.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@node-core/doc-kit': patch
3+
---
4+
5+
Adopt Changesets for releases: versioning and publishing are now driven by changeset files, which
6+
produce a `CHANGELOG.md`, git tags, and GitHub Releases.

.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@3.1.4/schema.json",
3+
"changelog": ["@changesets/changelog-github", { "repo": "nodejs/doc-kit" }],
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/workflows/publish.yml

Lines changed: 0 additions & 104 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release
2+
3+
# This workflow drives releases with Changesets.
4+
#
5+
# On every push to `main` it runs `changesets/action`, which behaves in one of two ways:
6+
# * If there are pending changeset files, it opens/updates a "Version Packages" PR that bumps the
7+
# version and writes CHANGELOG.md.
8+
# * If there are no pending changesets (i.e. the "Version Packages" PR was just merged), it runs
9+
# `changeset publish`, which publishes to npm (via npm OIDC trusted publishing), creates the git
10+
# tag, and cuts a GitHub Release.
11+
12+
on:
13+
push:
14+
# For security reasons, this should never be set to anything but `main`
15+
branches: [main]
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write # commit the version bump, push the git tag, create the GitHub Release
25+
pull-requests: write # open/update the "Version Packages" PR
26+
# For npm OIDC (https://docs.npmjs.com/trusted-publishers)
27+
id-token: write
28+
steps:
29+
- name: Harden Runner
30+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
31+
with:
32+
# `audit` (not `block`) because the publish step reaches many endpoints (npm registry,
33+
# sigstore provenance, the GitHub API, git push, Slack); a wrong allowlist would break a
34+
# release. Egress is still recorded for review.
35+
egress-policy: audit
36+
37+
- name: Checkout repository
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
39+
with:
40+
# Changesets needs full history (and credentials) to push the version branch and tags.
41+
fetch-depth: 0
42+
43+
- name: Setup environment
44+
uses: nodejs/web-team/actions/setup-environment@9f3c83af227d721768d9dbb63009a47ed4f4282f
45+
with:
46+
use-version-file: true
47+
registry-url: 'https://registry.npmjs.org'
48+
49+
- name: Install dependencies
50+
run: npm ci
51+
52+
- name: Create Release Pull Request or Publish
53+
id: changesets
54+
uses: changesets/action@a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d # v1.9.0
55+
with:
56+
version: node --run changeset:version
57+
publish: node --run release
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: Notify
62+
if: steps.changesets.outputs.published == 'true'
63+
uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # 2.3.3
64+
env:
65+
SLACK_COLOR: '#43853D'
66+
SLACK_ICON: https://github.com/nodejs.png?size=48
67+
SLACK_TITLE: ':rocket: Package Published: @node-core/doc-kit'
68+
SLACK_MESSAGE: |
69+
:package: *Package*: `@node-core/doc-kit` (<https://www.npmjs.com/package/@node-core/doc-kit|View on npm>)
70+
:bust_in_silhouette: *Published by*: ${{ github.triggering_actor }}
71+
:octocat: *Commit*: <https://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>
72+
SLACK_USERNAME: nodejs-bot
73+
SLACK_CHANNEL: nodejs-web-infra-alerts
74+
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}

CONTRIBUTING.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Thank you for your interest in contributing to the `@node-core/doc-kit` project!
1010
- [Running the Tool Locally](#running-the-tool-locally)
1111
- [Development Workflow](#development-workflow)
1212
- [Making Changes](#making-changes)
13+
- [Adding a Changeset](#adding-a-changeset)
1314
- [Submitting Your Changes](#submitting-your-changes)
1415
- [Writing Tests](#writing-tests)
1516
- [Test File Organization](#test-file-organization)
@@ -22,6 +23,7 @@ Thank you for your interest in contributing to the `@node-core/doc-kit` project!
2223
- [Code Quality](#code-quality)
2324
- [Linting and Formatting](#linting-and-formatting)
2425
- [Pre-commit Hooks](#pre-commit-hooks)
26+
- [Releasing](#releasing)
2527
- [Commit Guidelines](#commit-guidelines)
2628
- [Developer's Certificate of Origin 1.1](#developers-certificate-of-origin-11)
2729

@@ -151,6 +153,34 @@ The steps below will give you a general idea of how to prepare your local enviro
151153
node --run lint
152154
```
153155

156+
### Adding a Changeset
157+
158+
This project uses [Changesets][] to manage versioning, the changelog, and npm releases. Any change
159+
that affects published behaviour should include a changeset so it shows up in `CHANGELOG.md` and
160+
triggers a release.
161+
162+
1. **Create a changeset**
163+
164+
```bash
165+
node --run changeset
166+
```
167+
168+
You'll be prompted for the bump type and a short summary:
169+
- **patch** — bug fixes and other backwards-compatible changes
170+
- **minor** — new, backwards-compatible features
171+
- **major** — breaking changes
172+
173+
The summary becomes the changelog entry, so write it for users of the package.
174+
175+
2. **Commit the generated file**
176+
177+
This writes a Markdown file under `.changeset/`. Commit it alongside your code changes so it
178+
lands with your Pull Request.
179+
180+
> [!NOTE]
181+
> Changes that don't affect the published package (e.g. tests, CI, or internal docs) don't need a
182+
> changeset. See [Releasing](#releasing) for what happens to changesets after they're merged.
183+
154184
### Submitting Your Changes
155185

156186
1. **Add and commit your changes**
@@ -303,6 +333,21 @@ You can bypass pre-commit hooks if necessary (not recommended):
303333
git commit -m "describe your changes" --no-verify
304334
```
305335

336+
## Releasing
337+
338+
Releases are automated with [Changesets][] and require no manual version bumps — maintainers never
339+
edit the `version` field in `package.json` by hand.
340+
341+
When changesets land on `main`, the [`Release` workflow](.github/workflows/release.yml) opens (or
342+
updates) a **"Version Packages"** Pull Request that consumes the pending changeset files, bumps the
343+
version in `package.json`, and writes the corresponding `CHANGELOG.md` entries.
344+
345+
To ship a release, a maintainer merges that "Version Packages" PR. The same workflow then:
346+
347+
- publishes `@node-core/doc-kit` to npm (via [npm trusted publishing][] — no token required),
348+
- creates the matching `v<x.y.z>` git tag, and
349+
- cuts a GitHub Release from the changelog.
350+
306351
## Commit Guidelines
307352

308353
This project follows the [Conventional Commits][] specification.
@@ -327,6 +372,8 @@ By contributing to this project, I certify that:
327372
with this project or the open source license(s) involved.
328373
```
329374

375+
[Changesets]: https://github.com/changesets/changesets
330376
[Conventional Commits]: https://www.conventionalcommits.org/
331377
[Git]: https://git-scm.com/downloads
332378
[Husky]: https://typicode.github.io/husky/
379+
[npm trusted publishing]: https://docs.npmjs.com/trusted-publishers

0 commit comments

Comments
 (0)