Semantic Versioning 2.0.0
Semver Construction
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards-compatible manner, and
-
PATCH version when you make backwards-compatible bug fixes.
-
Version 0.1.10 is ordered before 0.10.1
- Version 0.1.1 is ordered before 1.0.0
- Version 1.10.10 is ordered before 10.1.1
Semver Ranges
- "1.2.3 - 2.3.4" is the same as ">=1.2.3 <=2.3.4" which specifies that the range can include all versions from, and including 1.2.3 all the way up to, and including 2.3.4.
- ">=1.2.0 <1.3.0" is be similar to "1.2.x" (but not exactly the same, thanks to pre-release and metadata labels which are beyond the scope of this article).
- "<1.0.0" only accepts versions in the "0.x.x" range.
Tilde & Caret Shorthand
semver also introduces shorthand ranges: ~ (tilde) and ^ (caret).
- Prefixing a single semver version string with the ~ character defines a range of acceptable versions that include all patch versions from the one specified up to, but not including, the next minor version. "~1.2.3" can be expanded as ">=1.2.3 <1.3.0".
- Prefixing a single semver version string with the ^ character defines a range of acceptable versions that include all patch and minor versions from the ones specified up to, but not including, the next version. So "^1.2.3" can be expanded as ">=1.2.3 <2.0.0".
0.x.x Versions
With 0.x.x versions the rules get messy due to the nature of the 0 major version number in the semver specification. The major version 0 is supposed to be reserved for "initial development", where "anything may change at any time", so the "patch" and "minor, non-breaking changes" essentially have no meaning. Unlike ~, the ^ operator with a major version of 0 is essentially a no-op, in that it translates to exactly that version rather than a full range. So "^0.2.3" is equal to just "0.2.3" and no more.