This page releases one package two times: a first release, then a patch release after a change. The examples type bump. In your project, type bunx bump or use your package.json script.
Start at 0.0.0
Give a new package the version 0.0.0. bump reads it as a package that was never released:
{
"name": "app",
"version": "0.0.0",
"type": "module",
"devDependencies": {
"bump": "^1.0.0"
}
}Add a file, and commit your files. bump works only on committed history, and a release needs a clean tree:
echo 'export const hello = () => "hello";' > index.js
git add -A
git commit -m "feat: hello"Preview the release
Add --dryrun to see the release. bump does every check and writes nothing:
$ bump minor --dryrun
BUMP 0.0.0 → 0.1.0 (first)
DONE Dry run; no files were writtenThe BUMP line shows the old version, the new version, and the reason. The reason is first, because the version is 0.0.0 and there is no tag for it.
Make the first release
Run the same command without --dryrun:
$ bump minor
BUMP 0.0.0 → 0.1.0 (first)
DONE Committed 0dfd458 v0.1.0
Tagged v0.1.0bump wrote 0.1.0 into package.json. It made the commit 0dfd458 with the message v0.1.0, and added the annotated tag v0.1.0 on it.
The tag v0.1.0 is now the anchor: the next release looks for changes after it.
Release a change
With no new commits, there is nothing to release:
$ bump patch
DONE Nothing to releaseChange a file and commit it:
echo 'export const bye = () => "bye";' >> index.js
git commit -am "feat: add bye"Preview, then release:
$ bump patch --dryrun
BUMP 0.1.0 → 0.1.1 (changed)
DONE Dry run; no files were written
$ bump patch
BUMP 0.1.0 → 0.1.1 (changed)
DONE Committed a50da2a v0.1.1
Tagged v0.1.1The reason is now changed: a file of the package changed since the v0.1.0 tag.
Push the release
bump does not push. Push the commit and its tags yourself:
git push --follow-tags--follow-tags pushes the annotated tags that point to the pushed commits. bump makes only annotated tags, so each release tag goes with its commit.
Then publish, if you want to:
npm publishNext steps
- How it works: learn how bump finds packages, anchors, and changes.
- Lockstep and independent: release a repository with several packages.
- Prereleases: make
1.0.0-next.0and similar versions.