Release NPM package with git-flow

Having an NPM package in an enterprise environment and wanting to release that package using the git-flow model? Then using the node-generate-release can be very helpful.
This blog shows how to execute an integrated git flow release from your NPM package, even if your master and develop branches are protected.

Install plugin

Let’s assume we have all changes in the develop branch and we would like to create a release with all the current changes in develop. With the git-flow release the result will be that all changes will be merged into master and a tag for the release version is created with correct version. Before we can finish the release the correct version in NPM package.json needs to be set. This can all be nicely done with node-generate-release plugin.

Add as script

Now we can add a release script that will call the generate-release CLI from the plugin.

Run

If we run the following command from the command line, the complete git flow release start and git flow release finish commands will be performed.

With pull requests

In many cases the master and develop branches are protected. Therefore we need to create pull requests in the git repository before merging the release/* branch back. In that case we want to skip the git flow release finish process and push the release/* branch. To do so we can include the following property in our package.json:

More configuration can be found here

Original blog post

Leave a Reply

Your email address will not be published. Required fields are marked *