A minimal example package demonstrating npm Trusted Publishing with OIDC (OpenID Connect).
This package serves as a reference implementation for setting up npm Trusted Publishing, enabling secure package publishing without storing npm tokens in CI/CD environments.
- Token-less Publishing: Publishes to npm using OIDC authentication instead of long-lived tokens
- GitHub Actions Integration: Automated release workflow with GitHub Actions
- Provenance Attestation: Automatically generates cryptographic attestations for package builds
- Secure Release Process: Two-step release process with PR review before publishing
Creates a release pull request with version bump and auto-generated release notes.
Trigger: Manual workflow dispatch with version type selection (patch/minor/major)
Steps:
- Bumps package version
- Generates release notes from previous release
- Creates a draft PR with release changes
Automatically publishes to npm when a release PR is merged.
Trigger:
- When PR with
Type: Releaselabel is merged - Manual workflow dispatch with specific version
Steps:
- Checks if release tag already exists (idempotency)
- Publishes package to npm with provenance
- Creates GitHub Release
- Comments on PR with release status
- npm account with 2FA enabled
- GitHub repository
- Node.js LTS version
- Go to your package settings on npmjs.com
- Navigate to the "Trusted Publisher" section
- Add GitHub Actions configuration:
- Organization/User: Your GitHub username or org
- Repository: Repository name
- Workflow filename:
release.yml - Environment (optional): Leave empty
-
Enable GitHub Actions PR creation:
- Go to Settings → Actions → General
- Enable "Allow GitHub Actions to create and approve pull requests"
-
Add release label:
- Create a label named
Type: Releasein your repository
- Create a label named
-
Add workflows:
- Copy the workflow files from
.github/workflows/to your repository
- Copy the workflow files from
- Go to Actions → Create Release PR
- Select version type (patch/minor/major)
- Review and edit the generated PR
- Merge the PR to trigger automatic publishing
You can also trigger a release manually:
- Go to Actions → Release
- Enter the version to publish
- Run the workflow
- No npm tokens in CI: Uses temporary OIDC tokens instead
- Provenance generation: Cryptographically verifiable build attestations
- Token publishing disabled: After setup, disable token-based publishing in npm settings
- Required 2FA: Enforces two-factor authentication for all maintainers
- npm CLI version 11.5.1 or higher (for OIDC support)
- GitHub-hosted runners (self-hosted runners not currently supported)
- Public repository (private repos cannot generate provenance)
MIT