🚀 Release npm package with npm run push-release-commit command
📦 Autogenerate Github release page
🔧 Publish NPM in GitHub Actions by release-it
🔐 OIDC Trusted Publishing (no NPM_TOKEN needed)
npm run push-release-commit- Node.js 20.0.0 or higher
npx @laststance/npm-publish-tool@latest init # generate .release-it.json/.github/workflows/release.yml, add `push-release-commit` npm script in package.json
npm install -D @laststance/npm-publish-tool # install `push-release-commit` script fileIn late 2025, the Shai-Hulud worm attack compromised 1,150+ npm packages by stealing NPM_TOKEN secrets from repositories. The attack:
- Affected 20+ million weekly downloads
- Caused ~$50M in cryptocurrency theft
- Was the first self-replicating worm in the JavaScript ecosystem
npm's response: OIDC Trusted Publishing (GA July 2025) eliminates long-lived tokens entirely. This tool now uses OIDC by default - no NPM_TOKEN needed.
OIDC only works after your package exists on npm. For the first publish:
npm publish --access public- Go to npmjs.com → Your Package → Settings
- Scroll to "Trusted Publishing" section
- Click "Add GitHub Actions"
- Fill in:
Field Value Owner Your GitHub username or org (e.g., laststance)Repository Your repo name (e.g., my-package)Workflow release.ymlEnvironment (leave empty) - Click "Add Trusted Publisher"
For maximum security, after enabling OIDC:
- Go to Package Settings → Publishing Access
- Select "Require two-factor authentication and disallow tokens"
This completely disables token-based publishing while OIDC continues working.
Only one secret is needed now:
GITHUB_TOKEN: Automatically provided by GitHub Actions (no setup needed)
Note:
NPM_TOKENis no longer required with OIDC Trusted Publishing.
┌─────────────────────────────────────────────────────────────┐
│ OIDC Trusted Publishing │
├─────────────────────────────────────────────────────────────┤
│ │
│ GitHub Actions npmjs.com │
│ ┌───────────┐ ┌───────────┐ │
│ │ release. │ ──── OIDC Token ────► │ Package │ │
│ │ yml │ (short-lived) │ Registry │ │
│ └───────────┘ └───────────┘ │
│ │ │ │
│ │ id-token: write │ Verify: │
│ │ permission │ - owner │
│ ▼ │ - repo │
│ Cryptographic │ - workflow │
│ Identity ▼ │
│ ✅ Publish! │
│ + Provenance │
└─────────────────────────────────────────────────────────────┘
Update the .github/workflows/release.yml file with your own build steps.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT © Ryota Murakami
- release-it - The underlying release automation tool
- npm OIDC Trusted Publishing - Official npm documentation

