Semantic Versioning

Semantic versioning helps developers understand the compatibility and impact of changes to software over time.

Semantic versioning uses three digits separated by dots to represent a software version number. e.g. 1.3.0

These digits represent the major, minor, and patch versions of the software, respectively.

MAJOR.MINOR.PATCH

  1. You increment the MAJOR version when you make incompatible API changes.
  2. You increment the MINOR version when you add functionality in a backwards-compatible manner.
  3. You increment the PATCH version when you make backwards-compatible bug fixes.

Now, when you install software, how do you specify a range of compatible versions?

You can use the tilde ~ and caret ^.

The tilde matches the most recent minor version (the middle number). ~1.2.3 will match all 1.2.x versions but will miss 1.3.0.

The caret will update you to the most recent major version (the first number). ^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0.

Here’s a comparison of the ranges specified by tilde and caret:

  • ~1.2.3: Accepts any version from 1.2.3 to 1.2.x
  • ^1.2.3: Accepts any version from 1.2.3 to 1.x.x

Date
March 25, 2023