A GitHub template for projects that publish to npm, with:
- OIDC trusted publishing — no
NPM_TOKENsecret; the workflow auths to npm via GitHub Actions' OIDC identity, configured per-package and per-workflow. - npm provenance — every published version carries a verifiable build attestation linking the artifact to this repo + the exact workflow run.
@next→@latestpromotion — every PR merge publishes a@nextpre-release automatically; you promote to@latestmanually through a reviewer-gated workflow when the version is ready for general consumption.
Out of the box:
semantic-releasereads conventional-commit history on every push tomain, determines the version, publishes to npm under@next, and creates a GitHub pre-release.- A manual
promoteworkflow that moves the same artifact from@nextto@lateston npm and converts the GitHub pre-release into the latest release. Gated by theproductionenvironment (required reviewer approval). auto-merge.ymlenables auto-merge on every non-draft PR so the publish chain closes without human intervention until the promote gate.- Conventional-commits → semver bump, with rules documented in
CLAUDE.md.
- Click Use this template on GitHub (or
gh repo create <new-name> --template fntemplate/npm --public). - Run
claim-npm.ps1to claim the npm package name with a placeholder0.0.0publish (idempotent — re-running on an already-claimed package is safe). - Run
setup-gh.ps1to merge template files into your repo, configure branch protection + theproductionenvironment, set repo-level merge settings (squash-only, PR title/body squash, linear history, auto-merge, auto-delete-branch), and register GitHub Actions as a trusted publisher on the npm package. - Add the
AUTOMERGE_PATsecret manually (Settings → Secrets and variables → Actions → New repository secret). Classic PAT withrepoworkflowscopes. PAT — notGITHUB_TOKEN— because GitHub suppresses workflow triggers forGITHUB_TOKEN-actored events, which would prevent the post-mergepushfrom triggeringpublish-next.
- Fill in the
lint,test, andbuildsteps in.github/workflows/ci.yml'sverifyjob, and the correspondingnpm runscripts inpackage.json. - Commit a
feat:change on a branch and open a PR. Auto-merge enables; whenverifygoes green it merges;publish-nextruns;@nextships. - When ready, go to Actions → "CI" → "Run workflow", approve the
productionenvironment gate, and@latestupdates.
| File | Role |
|---|---|
ci.yml |
verify (lint/test/build), publish-next (semantic-release on push to main), promote (workflow_dispatch, @next → @latest, gated) |
auto-merge.yml |
Enables auto-merge on every non-draft PR |
CLAUDE.md— conventions / discipline (branch policy, TDD, commit conventions, release flow)claim-npm.ps1— claim the npm package name (run first, before configuring GitHub)setup-gh.ps1— configure GitHub repo settings, branch protection, environment, and npm trusted publisher (run second).releaserc.json— semantic-release config