Trusted Publishing Admin Runbook
One-time setup and release operations for npm Trusted Publishing with GitHub Actions, integrated with Changesets.
This runbook is for npm/package admins and repository admins who manage release security and publication settings.
Preflight (must match repository state)
Section titled “Preflight (must match repository state)”Verify these files before setting publishers on npmjs.com:
.github/workflows/release.yml- runs
pnpm run release:stage - workflow permissions include
id-token: write - no
NODE_AUTH_TOKEN/NPM_TOKENin publish env
- runs
package.json- includes
version: changeset version && pnpm install --lockfile-only - includes
release:stagescript
- includes
.changeset/config.jsonbaseBranchismainfixedincludes[@modyra/*]so versions stay coherent
If any of these checks fail, stop and align the repo first.
Step 1: Configure npm Trusted Publisher
Section titled “Step 1: Configure npm Trusted Publisher”Repeat for each package under @modyra/*:
- Open package on npmjs.com.
- Go to Package Settings, then Trusted Publishing (or Publishing Provider).
- Select provider: GitHub Actions.
- Fill fields exactly:
- Organization/User: your GitHub org or user
- Repository:
modyra - Workflow filename:
release.yml - Environment name: leave empty unless your workflow uses GitHub Environments
- Allowed actions: enable
npm stage publish
- Save.
Notes:
- Field values are case-sensitive.
- Trusted publishing supports GitHub-hosted runners only.
- Each package has one trusted publisher configuration at a time.
Step 2: Changesets release flow (what to expect)
Section titled “Step 2: Changesets release flow (what to expect)”This repo is Changesets-driven:
- Contributors add a changeset file under
.changeset/for user-facing changes. - A maintainer creates/updates the “Version Packages” PR by running
pnpm changeset versionand committing the result. - When the “Version Packages” PR is merged, the release workflow runs full checks.
- The workflow runs
pnpm run release:stage, which executes:node scripts/publish-workspace.mjs --stagenode scripts/publish-angular.mjs --stage
- Artifacts are staged, not immediately public.
- A maintainer approves stage with 2FA (
npm stage approveor npmjs.com UI).
Why manual PR creation: organization policy disables GitHub Actions PR creation/approval with GITHUB_TOKEN.
Step 3: Post-setup verification
Section titled “Step 3: Post-setup verification”Run these checks after first staged release:
- CI release job succeeds without npm token secrets.
- npm shows staged releases for all
@modyra/*packages. - Stage approval publishes all packages at the same version.
- Package metadata shows provenance attestation when supported.
Useful checks:
npm view @modyra/core versionnpm view @modyra/angular versionStep 4: Harden security after first success
Section titled “Step 4: Harden security after first success”After confirming OIDC trusted publishing works:
- Remove
NPM_TOKENfrom repository secrets (if still present). - In npm package settings, restrict token-based publish access.
- Keep 2FA enforced for maintainers approving staged releases.
Troubleshooting
Section titled “Troubleshooting”If publish fails with ENEEDAUTH or OIDC-related auth errors:
- Re-check trusted publisher fields for exact match (
modyra,release.yml). - Confirm release is running in
.github/workflows/release.yml(not via a different caller workflow). - Confirm workflow still has
permissions: id-token: write. - Confirm runner is GitHub-hosted.
If only some packages publish:
- Verify trusted publisher exists for each
@modyra/*package. - Re-run the same release; publisher scripts are idempotent and fail on version mismatch by design.