Bookmarks

SemVer — semantic versioning

A convention for naming software versions: a number of the form MAJOR.MINOR.PATCH, where each part tells you whether the new version is compatible with the old one and how the code has changed.

Also: semantic version, SemVer

checked 9 Nov

All terms

A version number is a message to developers: “this update is safe” or “expect breakage”. Semantic versioning turns it into a contract: if a library goes from 2.3.0 to 3.0.0, the API changed incompatibly and your code needs checking; if it goes to 2.3.1, you can update without reading the changelog.

What a version number consists of

PartWhen it changesExample bump
MAJORincompatible changes: an API is removed or altered2.3.1 → 3.0.0
MINORnew functionality that stays backward compatible2.3.1 → 2.4.0
PATCHbug fixes with no change to the API2.3.0 → 2.3.1

Version 2.3.1 means MAJOR 2, MINOR 3, PATCH 1: the second generation of the API, the third batch of new features, the first fix. Initial development happens under 0.y.z: the specification allows anything to change at any time, and 1.0.0 is considered the first stable release. The main rules:

  • Once a version is released, its contents never change: fixes ship as a new version.
  • When MAJOR goes up, MINOR and PATCH reset to zero (2.3.1 → 3.0.0); when MINOR goes up, PATCH resets (2.3.1 → 2.4.0).
  • Declaring an API deprecated (deprecation) requires a MINOR bump: before a function is removed in a new MAJOR, at least one MINOR release must ship with a warning.
  • 0.y.z is for initial development: the API is not guaranteed and anything may change.
  • The v prefix is common in tags (git tag v1.2.3), but according to the specification the version itself is just numbers separated by dots.

Prerelease and update ranges

textA version: number, prerelease, build metadata
1.2.0-rc.1+build.20261107

A hyphen adds a prerelease label for a version that is not ready yet: 1.2.0-alpha.1, 1.2.0-beta.2, 1.2.0-rc.1 (release candidate). The + sign introduces build metadata (1.2.0+build.77), which is ignored when comparing versions. A prerelease always sorts below its release: 1.2.0-alpha < 1.2.0-beta < 1.2.0.

In package.json, requirements.txt and other dependency files, a version comes with a constraint: the range of updates you accept. The syntax differs between package managers, but the idea is the same; in npm notation:

  • ^1.2.3 — 1.2.3 or newer, but within MAJOR version 1: no breaking changes;
  • ~1.2.3 — 1.2.3 or newer, but within the same MINOR: no new features;
  • >=1.2 <2.0 — a range built from comparison operators.

A “^” or “~” range together with a lock file that pins exact versions gives you updates without surprises: the range for new installs, the lock file for reproducibility.

Where it is used

SemVer is the common convention in open ecosystems: npm, Cargo, Go modules. But nobody is obliged to follow it: some projects ship breaking changes under a MINOR bump. So the number is a good guide, but you should still check key dependencies against the changelog.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • LTSlong-term support

    LTS is a promise to support a release for a long time; an LTS version is also numbered with SemVer, but it speaks about the support period, not compatibility.

  • GitOps

    GitOps is a delivery practice: the desired state of the system is stored in Git; SemVer is only a convention for naming versions.

In depth in the references

where the topic is covered in detail