Software Versioning | Do you know about Semantic Versioning?

Maulik Bhojani
3 min readJan 26, 2019

--

Software versioning — A unique name of version

What is Software Versioning?

Software versioning is the process of assigning either unique version names or unique version numbers to unique states of computer software.

The way you version your software impacts how people use it and what they think about it.

In simple terms, in software development we need unique number to identify the release number which contains information related to current versions. Like Stable version, Bug fixes or changes (major or minor).

You may think, we can give version name with some text context which can be more meaningful and we can understand it easily. Let’s try with software versioning with simple name. For example, I give below name for my versions..

If I give version number by simple text

If you see on above example, I tried giving version numbers by simple name as text, But the version number may not be unique all the time (consider we have 10k+ versions on our software, it’s difficult to manage it as unique all the time), and the version number not showing dependency and compatibility with the previous version. To solve this problem, we need some common practice that help us with unique, meaningful, dependency , compatibility handling on our version number. For that, Semantic Versioning comes in picture.

Different version numbers on Widows vs iPhone

What is Semantic Versioning?

Semantic versioning (also referred as SemVer) is a versioning system, that you can use for your software, extensions, plugins, packages, libraries etc.

Semantic version is universal and widely used way of software versioning.

It contains 3 components, in the format of MAJOR.MINOR.PATCH where:

MAJOR: When you do incompatible changes, means it may contains changes which are may not be compatible with older version, or major feature or functional changes to it.

MINOR: When you do compatible changes, means it add features backwards-compatible manner,

PATCH: when you make backwards-compatible bug fixes.

Version number Syntax

QUALIFIER: If you’re doing release very fluently and you need one for pre-release or additional qualifier you can use qualifier at last.

Major package manager uses this semantic versioning. Like npm, composer.

If you’re using any of such package manager tool, you will find Version Range using different symbols like (~, ^, * and -).

What is Version Range and What is use of it?

By using comparison operators you can specify ranges of valid versions. Here some of version range symbol you can use.

Hyphenated Version Range ( — )

Inclusive set of versions. Partial versions on the right include are completed with a wildcard. For example 1.0 - 2.0 is equivalent to >=1.0.0 <2.1 as the 2.0 becomes 2.0.*. On the other hand 1.0.0 - 2.1.0 is equivalent to >=1.0.0 <=2.1.0

Wildcard Version Range (.*)

You can specify a pattern with a * wildcard. 1.0.* is the equivalent of >=1.0 <1.1

Tilde Version Range (~)

The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2 <2.0.0, while ~1.2.3 is equivalent to >=1.2.3 <1.3.0

Caret Version Range (^)

The ^ operator behaves very similarly but it sticks closer to semantic versioning, and will always allow non-breaking updates. For example ^1.2.3 is equivalent to >=1.2.3 <2.0.0 as none of the releases until 2.0 should break backwards compatibility.

Note: Be careful when using unbounded ranges as you might end up unexpectedly installing versions that break backwards compatibility. Consider using the caret operator instead for safety.

To learn more about semantic versioning, please follow below reference links:

https://en.wikipedia.org/wiki/Software_versioning

https://semver.org/spec/v2.0.0.html

https://docs.npmjs.com/about-semantic-versioning

https://getcomposer.org/doc/articles/versions.md

--

--

Maulik Bhojani
Maulik Bhojani

Written by Maulik Bhojani

I’m a Software Engineer, passionate about web technologies with a vocation for writing beautiful and clean code. #JavaScript #VueJS #ReactJS #Node #PHP #MySQL

No responses yet