read https://docs.npmjs.com/cli/version it's very straight forward.
Everything in npm config
cli is available to be set in .npmrc
like preid.
IE this allows your to define your prerelease identifier. By default npm follows this format.
MAJOR.MINOR.PATCH-PRE
Let say we start at 0.0.1
.
-
We want to publish a pre / alpha release of a upcoming minor release.
-
npm version preminor
This will bump the package.json and
git tag
the repo in one atomic step at0.1.0-0
-
-
Lets say we found another bug in our preminor, well then we make the fix and cut a new release
-
npm version prerelease
(you always use prerelease to stay within current semver context)now we're at
0.1.0-1
-
-
Finally ready for a stable release
npm version minor
at0.1.0
Without any .npmrc
mods to local repo
scenario | command | package.json version | git tag |
---|---|---|---|
new minor pre | npm version preminor |
0.1.0-0 | v0.1.0-0 |
new minor pre (staying in current pre) | npm version prerelease |
0.1.0-1 | v0.1.0-1 |
stable minor ready | npm version minor |
0.1.0 | v0.1.0 |
new pre patch | npm version prepatch |
0.1.1-0 | v0.1.1-0 |
skip ahead to next pre patch (some odd reason as this is rare) | npm version prepatch |
0.1.2-0 | v0.1.2-0 |
another pre patch fix | npm version prerelease |
0.1.2-1 | v0.1.2-1 |
release patch | npm version patch |
0.1.2 | v0.1.2 |
almost ready for a major release | npm version premajor |
1.0.0-0 | v1.0.0-0 |
major release | npm version major |
1.0.0 | v1.0.0 |
With .npmrc
mods to local repo
./.npmrc
tag-version-prefix=""
preid=alpha
scenario | command | package.json version | git tag |
---|---|---|---|
new minor pre | npm version preminor |
0.1.0-0 | 0.1.0-alpha.0 |
new minor pre (staying in current pre) | npm version prerelease |
0.1.0-1 | 0.1.0-alpha.1 |
stable minor ready | npm version minor |
0.1.0 | 0.1.0 |
new pre patch | npm version prepatch |
0.1.1-0 | 0.1.1-alpha.0 |
skip ahead to next pre patch (some odd reason as this is rare) | npm version prepatch |
0.1.2-0 | 0.1.2-alpha.0 |
another pre patch fix | npm version prerelease |
0.1.2-1 | 0.1.2-alpha.1 |
release patch | npm version patch |
0.1.2 | 0.1.2 |
almost ready for a major release | npm version premajor |
1.0.0-0 | 1.0.0-alpha.0 |
major release | npm version major |
1.0.0 | 1.0.0 |