Most companies building software know there are best practices or conventions they should follow, even if they don’t actually follow them. Versioning releases, preferably using version control that tags the release with the release number, is one of these best practices.
At a minimum, giving software releases incremental integer numbers—1, 2, 3, etc.—is sufficient to tell which code state is the latest iteration. But wouldn’t it be cool if a version number schema could tell you more about the state of software rather than just a sequence of changes?
This is where Semantic Versioning, or “SemVer,” comes in handy. Authored by GitHub founder Tom Preston-Werner, SemVer is a simple set of rules and requirements that governs and standardizes the assigning and incrementation of software iterations based on pre-existing common practices used in both closed and open-source software.
Semantic versioning uses the pattern of Major.Minor.Patch to label changes with the rules that:
- Patches are always backwards compatible
- Minor changes are always backwards compatible
- Any change that breaks the API (is not backwards compatible) increments the Major version number
While this approach may seem pedantic, there is one situation where it can be a lifesaver—an emergency rollback.
Say you’ve pushed a sev 2 bug to production. You need to roll it back immediately, but you don’t want to break production further. If you’ve adhered to SemVer, you immediately know if you’re going to break the database or dependencies on your rollback. Without it, you can hope there is a developer around to manually read through a diff of all code changes between the previous and current version, while your users suffer with a broken application.
As someone who has inherited mismanaged projects and been that developer in the second scenario, I can say that proper versioning makes it much less stressful and costly for everyone involved.
To learn more about SemVer and how versioning can convey important information in the underlying code, visit semver.org.