Semantic Versioning
Tuesday, January 24, 2023
Semantic Versioning (or “semver” for short) is a
specification for handling version numbers, and providing a way to sort and
specify compatibility using a MAJOR.MINOR.PATCH
structure with optional
“pre-release” and “build” information.
Some examples of semantic version numbers:
- 1.0.0-alpha
- 1.0.0-beta+win32
- 1.0.0-rc.1
- 1.0.0
For a long time, I thought it might be funny to follow the upcoming release
of Factor version 0.99
with version 0.100
.
Well, if we wanted to be consistent with “semver”, it might instead have to
be something like 0.100.0-joke+haha
.
There is now a semver vocabulary that provides some words for sorting and working with semantic version numbers. Here’s an example using it:
IN: scratchpad USE: semver
IN: scratchpad "0.99.0" >semver bump-alpha semver.
0.99.1-alpha.0
IN: scratchpad "0.99.0" >semver bump-preminor bump-rc semver.
0.100.0-rc.0
IN: scratchpad "0.99.0" "0.100.0" semver<=> .
+lt+
IN: scratchpad "0.100.0-joke+haha" >semver bump-major semver.
1.0.0
Reading the Semantic Versioning 2.0.0 specification, it suggests using the version numbers to represent compatibility with previous versions. And many languages have package managers that use these compatibility guarantees with “semver ranges” to manage project dependencies.