Releasing
이 콘텐츠는 아직 번역되지 않았습니다.
How the packages get to npm. The pipeline is built for three things:
- one maintainer
- a protected
main - no long-lived npm token anywhere
What is published
Section titled “What is published”| Package | Contents |
|---|---|
lumen-charts |
Re-exports @lumen-charts/core |
@lumen-charts/core |
The chart |
@lumen-charts/engine |
Data engine and worker entry |
@lumen-charts/react |
React binding |
@lumen-charts/vue |
Vue binding |
@lumen-charts/svelte |
Svelte binding |
@lumen-charts/solid |
Solid binding |
Versioning: all seven packages are released together under one version: a Changesets fixed group.
Not published: the example and the benchmark harness are private.
Package contents:
dist/(JavaScript, declarations, source maps) andsrc/, so that source maps and declaration maps resolve.README.md,LICENSE(MIT) and the changelog.
feature PR + changeset ──► main ──► (changesets pile up) │ pnpm version-packages ◄─────┘ on a branch, by the maintainer │ "version packages" PR ──► main ──► Release workflow plan: which versions are not on npm? publish: approve ► build, test, check, npm publish (OIDC, provenance), tag vX.Y.Z, GitHub release- Add a changeset. Every pull request that changes a package adds one with
pnpm changeset: a bump level and a line for the changelog. - Version the packages. To release, run
pnpm version-packageson a branch. It consumes the changesets, bumps every package to the next version, writes the changelogs and formats them. Open a pull request with the result.- Like every pull request, it needs a passing
verifycheck before it can merge.
- Like every pull request, it needs a passing
- Merge the version PR. The Release workflow (
.github/workflows/release.yml) runs on every push tomain. Its first job,plan, runsnode scripts/release.ts plan, which asks the registry which package versions are missing. A version is released only when all of these hold:- npm does not have it,
- it is not
0.0.0(never versioned), - no changesets are still pending (otherwise the version on
mainis not final).
- Approve and publish. When a release is due, the
publishjob waits for approval in thenpmenvironment. After approval it runs, in order:- build, tests and
pnpm release:check npm publishof each package, dependencies first: engine, core, then the rest- a
vX.Y.Ztag - a GitHub release with the changelog sections of that version
- build, tests and
Publishing a missing version again: run the workflow by hand (workflow_dispatch) after fixing what failed. Versions that are already on npm are skipped, so a partial publish can be finished this way.
Why not changesets/action
Section titled “Why not changesets/action”The usual setup lets changesets/action open the “version packages” pull request. It is not used here, for two reasons:
- A pull request opened with the workflow’s
GITHUB_TOKENdoes not trigger other workflows. Its requiredverifycheck would never run, and the protectedmaincould not take it. Working around that needs a GitHub App or a personal token. - It needs a repository setting turned on. Actions would have to be allowed to create pull requests, a setting that stays off.
Running pnpm version-packages by hand costs one command. Publishing still runs in CI, which is where the credentials and provenance matter.
Security
Section titled “Security”- No npm token. The publish job authenticates with npm trusted publishing. GitHub issues a short-lived OIDC token for this repository, this workflow file and the
npmenvironment, and npm accepts it only from that combination. Nothing can leak or expire, and npm attaches a provenance statement to every version. - Approval. The
npmenvironment accepts deployments only from protected branches, which meansmain, and requires a reviewer’s approval for every release. - Least privilege.
- The
planjob only reads. - The
publishjob getscontents: write(tag and release) andid-token: write(OIDC), nothing else. - The CI workflow’s token is read-only.
- The
- Publishing is off until npm is set up. The repository variable
NPM_PUBLISHmust betruefor thepublishjob to run. Until then,plannotes in the run summary which version is ready. - What reaches npm is checked on every pull request.
pnpm release:checkpacks every package as it would be published and fails on any of these:- a missing or differing license copy, or a missing README
- files other than
dist/,src/and the docs - export targets that do not exist
- source maps whose sources are not in the package
workspace:ranges left in the manifest- differing versions across the packages
One-time setup
Section titled “One-time setup”On npm
Section titled “On npm”-
Create the scope. Create the npm organization
lumen-charts(free for public packages); it owns the@lumen-chartsscope. Enable two-factor authentication for the account. -
First publish, from a local session. Trusted publishing is configured per package, on a package that exists:
Terminal window pnpm version-packages # in a PR: bump 0.0.0 to the first version, merge itgit switch main && git pullnpm login # with two-factor authenticationpnpm build && pnpm release:checkpnpm release:publish # publishes every package npm does not havegit tag v0.1.0 && git push origin v0.1.0A local publish has no provenance; only this first version lacks it.
-
Add the trusted publisher. For each of the seven packages: package settings → Publishing access → Trusted publisher → GitHub Actions, with:
- organization or user:
kjmin-dev - repository:
lumen-charts - workflow file:
release.yml - environment:
npm
npm 11.15 or later can do the same from the command line with
npm trust. - organization or user:
-
Disallow token publishing. In the same settings, set publishing access to Require two-factor authentication and disallow tokens. Trusted publishing keeps working, and a stolen token cannot publish.
On GitHub
Section titled “On GitHub”- The
npmenvironment already exists: deployments only from protected branches, approval bykjmin-dev. - Turn publishing on: set the repository variable
NPM_PUBLISHtotrue(Settings → Secrets and variables → Actions → Variables) once the trusted publishers are in place.
Commands
Section titled “Commands”| Command | What it does |
|---|---|
pnpm changeset |
Adds a changeset to the current branch |
pnpm version-packages |
Turns pending changesets into versions and changelogs |
pnpm release:check |
Packs every package and checks what npm would receive (after a build) |
pnpm release:plan |
Shows which versions npm does not have and whether a release is due |
pnpm release:publish |
Publishes those versions; add -- --dry-run to try it |
node scripts/release.ts notes <v> |
Release notes for version v, from the changelogs |
Prereleases: a version with a prerelease part, such as 0.2.0-beta.1 from changeset pre enter beta, is published under the next dist-tag instead of latest, and its GitHub release is marked as a prerelease.