Spring Boot Semantic Versioning
A Beginner’s Guide With an Example!
In this post, we will talk about what Semantic Versioning is and how we can integrate this into our spring boot application.
What is Semantic Versioning?
Semantic Versioning (SemVer) is the most popular system of versioning unique states of projects. It provides meaningful software releases that keep things clean and simple.
A semantic version number has three core parts, written in a form of x.y.z, where x, y, and z are numbers.
- X stands for a major version. When API changes occur and the code is no longer backward compatible, then you have made “breaking” changes that will require a major update.
- Y stands for a minor version. A minor release is used to signify that new functionality has been added, but the code is otherwise backward compatible.
- Z stands for a patch version. Patch versions are, used for bug fixes. This is when there are no functionality changes in the updates.
e.g.
Patch Update
0.5.3 >> 0.5.4: increment patch version number by one.Minor release
0.5.3 >> 0.6.0: increment minor version number by one and reset the patch version number to zero.Major release
0.5.3 >> 1.0.0: increment major version number by one and reset the minor and patch version number to zero.
Reference: https://semver.org/
Now that we know what Semantic Versioning is, let’s implement it in a Spring Boot application that uses maven.
The plugins we will use are:
- org.codehaus.mojo:build-helper-maven-plugin
A plugin to assist with the Maven build lifecycle - org.codehaus.mojo:versions-maven-plugin
A plugin to help manage the versions of artifacts in a project’s POM
Next, create 3 profiles to do the following:
- bump-patch
This profile will be activated when given the property,bumpPatch
- bump-minor
This profile will be activated when given the property,bumpMinor
- bump-major
This profile will be activated when given the property,bumpMajor
Now let’s try out the 3 profiles that we have just created.
bumpPatch
mvn validate -DbumpPatch
Output:
bumpMinor
mvn validate -DbumpMinor
Output:
bumpMajor
mvn validate -DbumpMajor
Output:
That’s about it. If you have come all the way here, congratulations!. I hope you have found this useful. Thank you for reading.