Semantic Versioning Simplified
Software systems depend on other components to work. These components can be internal or external, they are called as dependecies. With time everything has to change, hence inevitably the dependencies change. To make these dependencies(the modified ones) not break your system there should be a common notation which all parties must agree on. This way the developers maintaining the systems know whether to take the new dependencies or stick with the old ones. Semantic Versioning is one such notation.
Given a version number MAJOR.MINOR.PATCH (Example: 0.0.0):
Increment the PATCH version when you make backwards-compatible bug fixes (Example: 0.0.1)
Increment the MINOR version when you add functionality in a backwards-compatible manner (Example: 0.1.1)
Increment the MAJOR version when you make incompatible API changes (Example: 1.1.1)
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format (Example: 1.1.1-DEVELOPMENT)
Ranges Simplified:
Hyphen Ranges X.Y.Z – A.B.C
Specifies an inclusive set.
1.2.3 – 2.3.4 translates to all the versions that are >=1.2.3 and <=2.3.4 If a partial version is provided as the first version in the inclusive range, then the missing pieces are replaced with zeroes. Example: 1.2 - 2 translates to all the versions that are >=1.2.0 and <=2.0.0X-Ranges 1.2.x 1.X 1.2.* *
Any of X, x, or * may be used to “stand in” for one of the numeric values in the [major, minor, patch] tuple.
* translates to >=0.0.0 (Any version satisfies)
1.x translates to >=1.0.0 <2.0.0 (Matching major version) 1.2.x translates to >=1.2.0 <1.3.0 (Matching major and minor versions) A partial version range is treated as an X-Range, so the special character is in fact optional.Tilde Ranges
Allows patch-level changes if a minor version is specified on the comparator. Allows minor-level changes if not.
Example: ~1.2.3 will match all 1.2.x versions but will miss 1.3.0.
Caret ranges
It will update you to the most recent major version (the first number).
Example: ^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0.
Hungry for more learning on semantic versioning, please go through the following resources:
http://semver.org/
https://github.com/npm/node-semver
https://www.npmjs.com/doc/files/package.json.html (look into the dependencies section)
-Edsger W. Dijkstra
One thought on “Semantic Versioning Simplified”