Update and commit package version for Gitflow workflow.
This package makes bumping package version according to semantic versioning easier when using Gitflow workflow just by running a single CLI command. It does the following things automatically:
-
Bump version in
package.jsonin development branch (say, make a patch update from0.3.2to0.4.0). -
Add release header with updated version and date in text changelog file:
## 0.4.0 (2020-12-14) -
Commit changes in
package.jsonand text changelog file with a message that looks like:Raise version: 0.4.0 -
Merge changes to release branch and tag them as
0.4.0. -
Push local development branch, release branch and new tags to remote repository.
All the things mentioned above are configurable. The package can also be used for centralized workflow.
npm install raise-version --save-dev
or
yarn add raise-version --dev
-
Initialize
raise-versionfrom the root directory of your project (optional — if missed then default configuration will be used):-
if installed globally:
raise-version init -
if installed locally:
npx raise-version init
.raiseverrcconfiguration file will be created.raiseveris an alias forraise-versionCLI command. -
-
Adjust configuration parameters in
.raiseverrc, these are default values:{ "changelog": { "enabled": true, "path": "CHANGELOG.md", "encoding": "utf-8", "prefix": "##", "bullet": "-" }, "git": { "enabled": true, "release": "master", "development": "develop", "remote": "origin", "commit": true, "merge": true, "all": false, "tag": true, "push": false } }They correspond to
optionsof console command:-l,--changelogUpdate version in changelog file [boolean] [default: true]-f,--changelog-pathPath to changelog file [string] [default: "CHANGELOG.md"]-e,--changelog-encodingEncoding of changelog file [string] [default: "utf-8"]-h,--changelog-prefixPrefix for version header in changelog file [string] [default: "##"]-b,--changelog-bulletBullet character for changes' item in changelog file [string] [default: "-"]-g,--gitCommit updates to git [boolean] [default: true]-r,--git-releaseGit release branch [string] [default: "master"]-d,--git-developmentGit development branch [string] [default: "develop"]-o,--git-remoteGit remote repository name [string] [default: "origin"]-c,--git-commitCommit changes to development branch [boolean] [default: true]-m,--git-mergeMerge changes to release branch [boolean] [default: true]-a,--git-allCommit all changes [boolean] [default: false]-t,--git-tagCreate git tag [boolean] [default: true]-p,--git-pushPush git changes to remote repository [boolean] [default: false]
More CLI options:
-s,--skip-updateDon't update package.json fileIn order to use
raise-versionwith centralized workflow just set a value ofdevelopmentbranch equal toreleasebranch (master).git.mergeparameter and--git-mergeCLI option make no sense in this case. -
Make changes to your source code, describe them in changelog file (if used) and raise a version:
raise-version [release] [options]release— semver part to update, one of the following:major,minor,patch;options— CLI options overwriting configuration from.raiseverrc.
Basic usage examples used below considers that .raiseverrc has default configuration (or not created):
-
Update patch version in
package.json, make new version and release date heading inCHANGELOG.mdprepended with##(list items of changes are already prepended by-):raise-version patchpackage.json
{ "name": "my-package", "vesion": "1.0.0" }CHANGELOG.md
# Changelog - New feature is implemented. - Some bugs are fixed. ## 1.0.0 (2020-12-07) - Initial release.package.json
{ "name": "my-package", "vesion": "1.0.1" }CHANGELOG.md
# Changelog ## 1.0.1 (2020-12-10) - New feature is implemented. - Some bugs are fixed. ## 1.0.0 (2020-12-07) - Initial release.
-
The same as previous but also push commits to remote repository:
raise-version patch --git-push -
Don't update version in
package.jsonandCHANGELOG.md, don't commit but merge fromdevelopmentbranch toreleasebranch and push changes to remote repository:raise-version --skip-update --changelog=false --git-commit=false --git-push -
Don't update, don't commit and don't merge anything, just push to remote repository only:
raise-version --skip-update --changelog=false --git-commit=false --git-merge=false --git-push
const raiseVersion = require('raise-version');
raiseVersion({
release: 'patch',
git: {
push: true
}
}).catch(function(e) {
console.error('Something went wrong');
});

