Automate package publishing in Node.js using semantic-release

If you have managed an open-source project you already know what steps are involved in releasing a new version of the package or a library.

Changing the package version

Creating tags

Adding Github release

Publishing to npm

Developers hate repeating the same things. Automation is the solution. That’s why we have a great package called semantic-release-cli an npm tool which uses semantic-release to completely automate the package publishing process.

Semantic release CLI as the name suggests follows semantic versioning. Let’s take a quick look at what semantic versioning is.

Given the version number say (1.0.0) (Major.Minor.Patch).

Increment the Major number if you make API-incompatible changes.

Increment the Minor number if you add features that are backward compatible.

I have made a few changes to the package.json. I’ve set the package version to 0.0.0-semantically-released and I’ve set the test in the scripts to exit with 0, since we don’t have any tests for the demo.

To trigger a release we need to commit our code with messages following special conventions.

And semantic release CLI will take care of your releases. After Travis has successfully run all the tests and the build is successful you will see your package published on npm as well as a GitHub release.

A github release looks like this

Conclusion

Repeating steps in development can be time-consuming and will lead to reduced productivity. Developers must look to automate repetitive steps in the development process. Semantic Release CLI is an awesome utility one can use to automate the package release process for Node.js applications. Here we learned how we can set it up and use it. Give it a try in one of your projects I’m sure you will love it.