Publishing Packages
Every published package under packages/** has a .release-it.json. A release bumps the version, commits, tags as
<package>@<version>, pushes, creates the GitHub release and publishes to npm. @frigear-nu/base is published as source (a Nuxt layer has no build step, so its release-it config has no
after:bump hook). @frigear-nu/eslint-config is published as plain ESM source too. @frigear-nu/cli is private and not published.
Requirements
- Node.js and pnpm as in Local development.
- Push access to the repository, and a clean working tree (
requireCleanWorkingDiris on). - A package that is registered for npm Trusted Publishing (see Trusted publishing).
Release a package
Run from the repository root:
pnpm install
cd packages/<your-package>
pnpm exec release-it <patch|minor|major|premajor|preminor|prepatch|prerelease>
The package's release-it config builds after the bump (after:bump) and then runs scripts/npm-publish.sh once the
GitHub release exists (after:release).
If the release fails because of authentication, the version commit and tag are already pushed. Resume only the npm publish:
bash ../../scripts/npm-publish.sh
The packages also have a release npm script (changelogen and npm publish) left over from the module starter. This
guide uses release-it instead.
Release from GitHub Actions
The Release workflow (.github/workflows/release.yml) does the same from the Actions tab. It takes two inputs:
| Input | Values | Purpose |
|---|---|---|
package | all or a folder under packages/ | What to release. all releases every package in the workflow's list with the same increment. |
increment | major, minor, patch (default), premajor, preminor, prepatch, prerelease | Passed to release-it. |
The jobs run in this order:
- verify builds the package's workspace dependencies and runs its tests, one runner per package, in parallel. Nothing is pushed or published.
- release versions the packages that passed one at a time (each pushes a commit and tag to the branch), using
scripts/release-package.shwith release-it's hooks off. It then builds them once and publishes them to npm up to four at a time (scripts/publish-released.sh).
A failing package does not stop the others but fails the run. If a version was tagged but never reached npm, running the workflow again publishes it without cutting a new version. Only one release runs at a time.
Trusted publishing
Publishing uses npm Trusted Publishing (OIDC), so no npm token is stored.
The workflow's release job has id-token: write to mint the token. Each package must have the repository and the
release.yml workflow registered as a trusted publisher on npmjs.com.
scripts/npm-publish.sh packs the package with pnpm pack, so workspace:* dependencies become real version ranges,
then publishes the tarball with npm publish --provenance --access public. It uses the npm CLI because pnpm does not
implement Trusted Publishing yet, and --provenance is needed because npm's token exchange otherwise fails for scoped
monorepo packages.
Add a new package
- Give it a
.release-it.json: copy a sibling's and change the package name and tag. - Add it to the
packagechoices and to thealllist in thepreparejob ofrelease.yml. Keep the two in sync. - Register it as a trusted publisher on npmjs.com.