## How to manage the versioning of the library at every release using Github Actions
Ok, now you have the library published, but how do you manage the versioning of the library? Every time you publish a new version of the library, you need to bump the version number manually updating the version
property in the package.json
file, republishing the library on npm, and making a release on the github repository. Pretty annoying, isn't it?
But there is a magic way to manage the versioning of the library, and it's called semantic versioning. It's a way to manage the versioning of a library based on the changes that you make to the library. The idea is to use a version number that is composed of three parts: major, minor and patch. The major version number is used to indicate a breaking change in the API. The minor version number is used to indicate an additive, backwards-compatible change. The patch version number is used to indicate a bug fix. The version number is always in the format major.minor.patch
. For example, the version number 1.0.0
indicates that the library is a first release, and the version number 1.1.0
indicates that the library is a first release with a bug fix. The version number 1.1.1
indicates that the library is a first release with a bug fix and a new feature. You can see more about semantic versioning here.
Wait a minute Renny, this semantic versioning seems a bit confusing, how do i know how to apply the correct version every time I publish a new version of the library?
This is what the semantic-release
library is for. It's a library that helps you manage the versioning of your library. It's a tool that will help you manage the versioning of your library, and it will help you to publish the library on npm and github.
semantic-release
libraryFirst, we need to install the library in your.. yes, library 😅. You can run the following command to install it:
1$ npm install -D semantic-release@18
Next, we need to add a script to the package.json
file. This script will be used to publish the library on npm and Github. Note that this command will work only in a CI environment, so you should not run it manually.
1"scripts": {
2 "semantic-release": "semantic-release"
3},