Pushing Tags to NPM
This guide explains how to publish your package versions to npmjs.com by pushing git tags.
Quick Startโ
1. Create and Push a Git Tagโ
# Create a version tag (e.g., v2.1.16)
git tag v2.1.16
# Push the tag to GitHub
git push origin v2.1.16
2. Automatic Publishingโ
When you push a tag matching the pattern v* (e.g., v2.1.16), the GitHub Actions workflow automatically:
- โ Runs all tests and linting
- โ Builds the project
- โ Verifies package structure
- โ Publishes to npmjs.com
- โ
Sets appropriate npm dist-tags (
latestfor stable,betafor prereleases) - โ Creates/updates GitHub release
How It Worksโ
Workflow Triggerโ
The .github/workflows/publish.yml workflow is triggered when:
- Tag push: Any tag matching
v*pattern is pushed to GitHub - Manual dispatch: You can manually trigger via GitHub Actions UI
- Workflow call: Called from other workflows
Version Detectionโ
The workflow automatically:
- Extracts version from the git tag (removes
vprefix) - Updates
package.jsonversion if needed - Publishes with the correct npm dist-tag
NPM Dist-Tagsโ
- Stable versions (e.g.,
v2.1.16): Published withlatesttag - Prerelease versions (e.g.,
v2.1.16-beta.1): Published withbetatag
Examplesโ
Publishing a Patch Versionโ
# Current version: 2.1.15
git tag v2.1.16
git push origin v2.1.16