Basic npm Package Release with semantic-release
Set up semantic-release for a standard npm package with automated versioning, release notes, npm publishing, and GitHub releases. The minimal config for most projects.
Detailed Explanation
Setting Up semantic-release for an npm Package
The most common semantic-release configuration uses four core plugins to automate the entire release process for an npm package.
Minimal Configuration
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
]
}
How Each Plugin Works
commit-analyzer reads your git commits since the last release and determines whether the next release should be a major, minor, or patch version based on the Conventional Commits format.
release-notes-generator creates human-readable release notes grouped by commit type (Features, Bug Fixes, etc.).
npm updates the
versionfield in package.json and publishes the package to the npm registry.github creates a GitHub Release with the generated release notes and tags the commit.
Commit Format
semantic-release expects commits following the Conventional Commits specification:
| Commit Message | Release Type |
|---|---|
fix: correct typo in README |
Patch (0.0.x) |
feat: add dark mode support |
Minor (0.x.0) |
feat!: redesign API endpoints |
Major (x.0.0) |
BREAKING CHANGE: remove v1 API |
Major (x.0.0) |
CI Configuration
This config works with any CI system. For GitHub Actions, you need to set the GITHUB_TOKEN and NPM_TOKEN environment variables as secrets.
Use Case
Open-source library maintainers who want fully automated versioning and publishing to npm. Every merge to main automatically determines the correct version bump, publishes to npm, and creates a GitHub release.
Try It — Semantic Release Config Builder
Related Topics
Automatic Changelog Generation with semantic-release
Basic Configuration
GitHub Release with Uploaded Assets
Advanced Configuration
Prerelease Branch Configuration for semantic-release
Basic Configuration
Custom Commit Type Release Rules for semantic-release
Advanced Configuration
Using conventionalcommits Preset with semantic-release
Plugin Configuration