Publish to npm from GitHub Actions.
Section: Release and deployment workflows
Publish an npm package
yaml
yaml
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}Explanation
Keep package publishing in a protected branch or tag workflow with tightly scoped permissions.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Release and deployment workflows
Create a GitHub release on tag push
Publish a release whenever a version tag is pushed.
Deploy only from main after tests
Gate deployments on successful CI from the main branch.