Skip to content

Releasing ​

Every public package (@plinthjs/* and create-plinthjs-app) is published by the Release workflow on GitHub Actions. Nobody needs to run npm publish locally.

Day to day ​

  1. Make your change and add a changeset:
    bash
    pnpm changeset        # pick "patch" for 0.1.x fixes; all packages move together
  2. Commit and push to main (or merge a PR).
  3. The workflow opens a "chore(release): version packages" PR that bumps the versions and writes the changelogs.
  4. Merge that PR. The workflow builds and publishes every package version that is not on npm yet, one at a time, then tags and creates GitHub releases.

Typecheck, lint, format and tests run in the separate CI workflow (.github/workflows/ci.yml) on every pull request and push, in parallel with the release.

Re-running the workflow is always safe: versions already on npm are skipped.

How publishing is authenticated ​

The workflow uses npm trusted publishing (OIDC). GitHub proves to npm that the publish comes from .github/workflows/release.yml in this repo, so there is no npm token or OTP.

npm only lets you register a trusted publisher on a package that already exists, so a brand-new package needs its very first publish by hand, once (see below). After that it is released by the workflow like every other package.

One-time setup ​

  1. Trust the workflow on every package that is already on npm. Locally, logged in as the owning account (npm whoami must print plinthjs), npm >= 11.15:
    bash
    pnpm release:trust
    npm asks you to approve in the browser (a passkey is enough). Packages that are not on npm yet are listed as skipped. A trust entry must be used by a successful workflow publish within 2 days, or it expires; if it does, run the command again.
  2. First publish of a brand-new package. Build it, then publish it once by hand and trust it:
    bash
    pnpm --filter <package> build
    cd packages/<package> && npm publish --access public   # approve in the browser
    cd ../.. && pnpm release:trust
    The next release publishes its following version through the workflow.

There is no npm token in the repository settings, and none should be added.

Locking down publishing (optional, after the first successful release) ​

Once a release has gone out through the workflow, disallow tokens on every package so that only the workflow (trusted publishing) or a 2FA-approved manual publish can release them:

bash
node scripts/harden-packages.mjs --dry-run   # list what would change
pnpm release:harden                          # apply (approve in the browser with your passkey)

This sets each package to "Require two-factor authentication and disallow tokens". The workflow keeps working because trusted publishing does not use tokens. Packages that are not on npm yet are skipped; publish them once, run pnpm release:trust, then run this again.

Checking what would be published ​

bash
pnpm release:dry

npm account notes ​

  • Never sign in with a 2FA recovery code: npm suspends the account (read-only) for 72 hours, and every publish fails with E404 until it lifts.
  • Use an authenticator app for 2FA so local commands can take --otp=<code>.

Released under the MIT License.