I recently took freecodecamp's backend development and APIs course and it was there I first came across the term semantic versioning or semver for short. Before that, I had always looked at frameworks and packages, particularly those used for Nodejs development and wondered what all the numbers which came after the package name stood for and why they looked so weird.
Semantic versioning is one of the various things I learnt during the course of the course. Before moving on, I would really advise anyone looking to learn a new tech skill and get a certificate for it to check out their courses on freecodecamp.org/learn. It's comprehensive, you get to build some fun projects and it's free. As an added advantage, you can follow freecodecamp on YouTube as they constantly release quality videos made by quality tutors.
Now to the good stuff. I'll try to explain semantic versioning or semver for short as simple as I can.
Semantic versioning is simply a method or system of versioning APIs or frameworks. It simply helps the developers of a framework or API to continously assign appropriate versions to their work. It was was first proposed by Tom Preston-Werner in 2013 to specify how version numbering should be controlled.
Semver makes use of a format which is made up of three component numbers written as X.Y.Z where:
X stands for major version. Y stands for or minor version Z stands for patch version
Let assume we have a framework called depend 1.2.5
.
The leftmost number is the major version. If a new functionality which breaks the framework is added, the major version is increased while the minor and patch versions are changed to 0. In the case above, the framework would become depend 2.0.0
.
In the example above, the depend framework has a minor version of 2. This is increased when a functionality is added to the framework which is backward compatible i.e does not break the framework. An increase in the minor version would change the version of the framework to 1.3.0
as the patch version changes to 0 when the minor version is increased.
Under semantic versioning, patch changes are used for backward compatible bug fixes i.e changes that are meant to fix bugs and do not break the framework and thus any bug fixed lead to an increase of the depend framework above to 1.2.6
It is important to note that there are various other methods for versioning frameworks or APIs. Semver is popular because it is relatively easy to understand and implement as well as enables users of the framework to understand the risks in updating their local packages.