Automate releases with semantic-release
semantic-release removes manual version bumps entirely. It reads your commit history, figures out the right semantic version, generates release notes, publishes to npm, creates a GitHub release, and commits the changelog back — all from CI. The behavior is driven by .releaserc.json, and this builder produces a correct, ordered configuration.
How it works
The branches array lists which branches are allowed to trigger a release, typically main for stable plus channels like next for pre-releases. tagFormat controls the git tag, defaulting to v${version}.
The plugins array is an ordered pipeline, and order is the most important detail. commit-analyzer runs first to compute the next version from Conventional Commit messages — fix means patch, feat means minor, BREAKING CHANGE means major. release-notes-generator then renders notes. Optional plugins follow: changelog writes CHANGELOG.md, npm publishes the package, and github creates the release. The git plugin must come last so it commits the updated package.json and changelog back with a [skip ci] message to avoid an infinite loop.
Tips and notes
- Keep
gitas the final plugin in the array, always. - Supply
NPM_TOKENandGITHUB_TOKENas CI secrets — never in the config. - Disable the npm plugin for apps that release but should not publish a package.
- Pair this with a commitlint config so every commit is parseable.