Automate versions with semantic-release
Let semantic-release pick the next version from commit messages, tag it, publish to npm and write release notes. Needs Node.js 22 or newer.
Instead of choosing version numbers by hand, semantic-release reads your commit messages and decides. A fix: commit is a patch, feat: is a minor, and a commit with BREAKING CHANGE: in its body is a major.
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
]
}Run it from CI after the tests pass:
npx semantic-release[semantic-release] › ✔ Published release 1.1.0 on default channelThe last line is the outcome when a feat: commit landed since the previous tag. With only docs: or chore: commits, it prints that there are no relevant changes and publishes nothing. The commit rules are in the semantic-release docs.
This puts the release decision in the commit message, so a vague message like "update stuff" causes no release at all. Pair it with a commit lint check.
The tool needs a token with push rights to the repository. In CI, use the platform's token, and keep full history, since it reads the tags.