Automatically Bumping the NPM Package Semver Patch Version | Task

Ole Ersoy
Feb - 04  -  1 min

Scenario

Before publishing our NPM Package we want to automatically bump the semver patch version.

Approach

We will be using the NPM package @jsdevtools/version-bump-prompt to perform the automatic bump.

In the scripts section add the install script for it, such that users of the package know where the bump command comes from.

"scripts": {
    "ig": "npm install -g @jsdevtools/version-bump-prompt"
}

Now to install the bump command globally run npm run ig.

Next add a script that bumps the projects patch version:

"scripts": {
...
    "bp": "bump patch"
}

To bump the projects patch version run npm run bp.