Semantic Versioning

v3.0.0, W3C Draft, 30 March 2024


Overview

Given a version number

MAJOR.MINOR.PATCH-EXTRA+META

, increment the:

  1. MAJOR version when you make backwards incompatible changes
  2. MINOR version when you add functionality in a backward compatible manner
  3. PATCH version when you make backward compatible bug fixes
  4. EXTRA version when you make a new prerelease, or other extra versioning parameters

EXTRA Has a natural ordering, specified below, may contain any alphanumeric characters, in addition to dots, and additional dashes

META metadata is non-ordered, this does not increment

Semantic Versioning Specification

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD","SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

  1. A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative integers, and MUST NOT contain leading zeroes. X is the major version, Y is the minor version, and Z is the patch version. Each element MUST increase numerically.

  2. Once a versioned package has been released, the contents of that version MUST NOT be modified. Any modifications MUST be released as a new version.

  3. Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The artifact SHOULD NOT be considered stable.

  4. Version 1.0.0 defines the artifact. The way in which the version number is incremented after this release is dependent on the version class of the component.

  5. Patch version Z (x.y.Z | x > 0) MUST be incremented if only backward compatible bug fixes are introduced. A bug fix is defined as an internal change that fixes incorrect documented behavior or improves performance characteristics while adding no new functionality.

  6. Minor version Y (x.Y.z | x > 0) MUST be incremented if new, backward compatible functionality is introduced to the component. It MUST be incremented if any public functionality is marked as deprecated and it MUST be incremented if new functionality is exposed publicly through the versioned component. It MAY include patch level changes. Patch version MUST be reset to 0 when minor version is incremented. The minor version MUST NOT increment if the major version is eligible to be incremented at this time.

  7. Major version X (X.y.z | X > 0) MUST be incremented if any backward incompatible changes are introduced to the component being versioned. It MAY also include minor and patch and minor level changes. Patch and minor versions MUST be reset to 0 when major version is incremented.

  8. Extra version MAY exist and WILL be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. Identifiers MUST comprise either only ASCII alphanumerics [0-9A-Za-z] or only numbers and periods [0-9.]. Identifiers MUST NOT be empty. Numeric identifiers MUST NOT include leading zeroes. Extra versions have a lower precedence than the associated normal version. An extra version containing letters indicates a pre-release and that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version. An extra version containing only numbers separated by periods represents a subversion and will follow the same format and rules as a normal version (see dependent version class below). The extra version MAY reset when either major, minor, or patch versions increase.

  9. Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-].Identifiers MUST NOT be empty. Build metadata MUST be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence.

  10. Precedence refers to how versions are compared to each other when ordered.

    1. Precedence MUST be calculated by separating the version into major, minor, patch and pre-release identifiers in that order (Build metadata does not figure into precedence).
    2. Precedence is determined by the first difference when comparing each of these identifiers from left to right as follows: Major, minor, and patch versions are always compared numerically.
    3. When major, minor, and patch are equal, a pre-release version has lower precedence than a normal version.
    4. Precedence for two pre-release versions with the same major, minor, and patch version MUST be determined by comparing each dot separated identifier from left to right until a difference is found as follows:
      1. Identifiers consisting of only digits are compared numerically.
      2. Identifiers with letters or hyphens are compared lexically in ASCII sort order.
      3. Numeric identifiers always have lower precedence than non-numeric identifiers.
      4. A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
  11. Select the subcategory below that best describes the artifact. They are ordered in descending priority, so pick the first category that matches your software type.

Example versions without the optional EXTRA or META components:

1.9.0, 1.10.0, 1.11.0

Example versions utilizing the optional EXTRA component but without META:

1.0.0-alpha, 1.0.0-alpha.1, 1.0.0-0.3.7, 1.0.0-x.7.z.92, 1.0.0-x-y-z

Example versions utilizing the optional EXTRA and META components:

1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85, 1.0.0+21AF26D3117B344092BD

Example version precedence:

1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0 < 2.0.0-alpha < 2.0.0 < 2.1.0 < 2.1.1

Version Classes

While the general meaning of a PATCH, MINOR, and MAJOR version are defined in the specification above the specific interpretation is not always clear depending on the class of resources you happen to be versioning. An API, Schema, or even an application would all interpret when to bump a version a bit differently. Therefore we have tried to define explicitly versioning rules for the various classes of resources of interest. Any class not covered in this specification is technically not covered by it, but it is still recommended the general principles outlined in the specification above still be adhered to when possible.

When picking a version class we only care about exposed components. Internal APIs, internal data, and dependencies shouldn't affect versioning. The exposed components being versions, and the versioning class being used, should always be explicitly stated by the project owners.

When a artifact covers several exposed components that are either of different versioning classes, or just make sense to version separately then they should always be versioned separately. The overall artifact version can be determined by the hybrid versioning class mentioned below.

API Versioning

When, versioning software with a public API such as libraries, and web endpoints it must match the following criteria:

  1. The resource MUST declare a public API.
  2. The API must be declared as code or specification documentation.

For any artifact of this type the meaning of incrementing the components of a version are as follows:

  • PATCH - An internal fix to bring behavior in compliance with the documented expected behavior for the public API; this should implement no changes to the public API signatures.
  • MINOR - If new functionality is added to the public API in a backwards compatible way, including new information in the return values.
  • MAJOR - Any change to the public API that breaks backwards incompatibility.

UI Versioning

When versioning User Interfaces which may have any nature of input whether it be command-line, GUI, or some other interface, the following paradigm should be used. The following criteria must be satisfied:

  1. The resource must have a user interface of some kind, both command-line and GUI are acceptable.

For any artifact of this type the meaning of incrementing the components of a version are as follows:

  • PATCH - An internal fix to bring behavior in compliance with the documented expected behavior for the UI; this should implement no changes to the user interface of any kind.
  • MINOR - Any backwards compatible changes to the UI. Backwards compatible means while new entries and elements can be added the existing ones should retain their same name, exist somewhere within the same menu items and menu structure, and behave consistently as they have in the past (or fixed according to the documented and expected behavior). This applies to all language variants of the interface.
  • MAJOR - Any change to any of the interfaced in any language, that breaks backwards incompatibility.

Dataset Versioning

When, versioning datasets which may have the schema versioned alongside or separately. A dataset may include such things as a RDBMS database, a Semantic Web Knowledge Graph, or an XML file. Such Datasets must describe the following:

  1. Public structured data for which access is being provided.

For any artifact of this type the meaning of incrementing the components of a version are as follows:

Anytime the underlying schema experiences an increase in any of its version's parts then the dataset must at least increment its version corresponding part, or a more significant part.

  • PATCH - Additional rows / instances have been added to your dataset. This MUST also be incremented when incremented on the schema.
  • MINOR - Additional, backwards compatible, information is provided about existing rows/individuals. This MUST increment when MINOR is incremented in the underlying schema (see schema versioning below).
  • MAJOR - Non-backwards compatible changes to the data or underlying schema. This MUST be incremented when MAJOR is incremented in the underlying schema.

Schema Versioning

When, versioning schemas for reading or interacting with data sets, for example, RDBMS Schema, Semantic Web Ontologies, and XML Schemas. Such schemas must describe the following:

  1. Public structured data whose schema is being defined.
  2. You are versioning the schema independently of the dataset or you are versioning the schema and not the dataset.

For any artifact of this type the meaning of incrementing the components of a version are as follows:

  • PATCH - Additional or improved validation, indexing, and other backwards compatible improvements that do not introduce new data. Also data's structure and typing is unchanged except for bugs contrary to the documented expected behavior.
  • MINOR - Additions only to the schema allowing access to new underlying data while not changing the structure of historic data.
  • MAJOR - Any changes to the structure of the data preventing bachwards-compatible access to historic data.

Hybrid Versioning

When, versioning artifacts that contain multiple resources that should be versioned separate, which is required when you have public interfaces that represent 2 or more of the version classes listed here, then you must use hybrid versioning. To use Hybrid Versioning the following criteria must be met.

  1. The artifact must include 2 or more publicly exposed components that can be defined by one of the versioning classes outlined here.
  2. The exposed components must be of either different versioning classes, or are versioned separately.

Each versioned public component receives a version that is independent and according to the rules of it's versioning class. In addition the overall artifact gets an additional version, this version will increment one of its parts depending on the most significant version change across all its other interfaces. Bumping at most one version step. The specific parts of the version behave as follows:

  • META - This will be dropped or assigned at the package maintainers discretion. Never expect it to be an ordered value.
  • EXTRA - Increment this when the most significant version bump among your other components was a bump to the EXTRA version. This field may not reset when a higher position resets. It will always be, at a minimum, the lowest value, if any, after reset, from all its subcomponents.
  • PATCH - Increment this when the most significant version bump among your other components was a bump to the PATCH version.
  • MINOR - Increment this when the most significant version bump among your other components was a bump to the MINOR version.
  • MAJOR - Increment this when the most significant version bump among your other components was a bump to the MAJOR version.

Example hybrid version jumps based on the version changes in its other components.

1.0.0-alpha -> 1.0.0-beta if 2.6.7-alpha -> 2.6.7-beta, 1.8.3+102 -> 1.8.3+111

1.0.0-alpha -> 1.0.1-beta if 2.6.7-alpha -> 2.6.7-beta, 1.8.3+102 -> 1.8.4

1.0.0-alpha -> 1.1.0 if 2.6.7-alpha -> 2.6.7, 1.8.3+102 -> 1.10.3

1.0.0-alpha -> 1.1.0 if 2.6.7-alpha -> 2.6.7+112, 1.8.3+102 -> 1.10.3+113

Dependent Artifact Versioning

On occasion you have software that needs to be versioned relative to the version it is written against. Example projects, and schema-extensions are good examples of this. Such software should have the following criteria.

  1. Its version only makes sense relative to the base projects version.
  2. The version of the base project will always be treated as a more significant digit than the version of this project. Such that .

When using this versioning paradigm the EXTRA field is used to embed this projects encoding. The EXTRA field effectively embeds a second version that follows all the same rules as a standalone version. The fully expanded format for a version with this paradigm would now be MAJOR_BASE.MINOR_BASE.PATCH_BASE-EXTRA_BASE+META_BASE which expands to:

MAJOR_BASE.MINOR_BASE.PATCH_BASE-MAJOR.MINOR.PATH-EXTRA+META_BASE+META

For any artifact of this type the meaning of incrementing the components of a version entirely depend on the versioning class itself.

Example Dependent Artifact Versioning

1.2.3-4.5.6 > 1.2.2-5.6.7