What is a semantic version?
Software versioning has always been an issue ever since software has been created. Semantic versioning is a universal way of versioning some software or a development project where multiple versions of the software exist, or plan to exist.
A semantic version comes in the form of a number, split into pieces by a
. such as
ais the major version
bis the minor version
cis a patch
In a real scenario it would look something like:
Some rules that tend to be followed when working with semantic versioning are:
- Increase the Major version when the change is considered breaking, such as updating a contract of an API which would mean the consumer would have to recode the interface
- Increase the Minor version when a change is made, which does not break the rule above, such as an improvement which does not require recoding of the interface
- Increase the Patch version when working on bug fixes, or feature work which may still be under development.
Using Bumpversion to version a project
bumpversion as described by its author is:
A small command line tool to simplify releasing software by updating all version strings in your source code by the correct increment. Also creates commits and tags
It really helps with managing semantic versioning, as it will automatically increase the version easily in different places.
I typically start with a basic bumpversion config similar to this:
commit = True
tag = True
current_version = 1.0.0
I then make sure to add in my setup.py and version to include this version:
with open("README.md", "r") as fh:
long_description = fh.read()
description="A utility that does something",
Now every time I want to change the version, I just run the bumpversion command such as:
bumpversion patch - which will go from 1.0.0 -> 1.0.1
bumpversion minor - which will go from 1.0.0 -> 1.1.0
bumpversion major - which will go from 1.0.0 -> 2.0.0