Git/Sem-Versioning spring-boot project

I was recently working on a spring-boot release management and continuous integration process. As a part of the project, had to do versioning of the releases with GitHub. It took a while to figure out the stuff. So, I thought of writing this.

To get started with, hope you have a sample spring project. If not, use this link to create or use the project.

Next step is to add versioning plugin to your gradle file. Add plugin as below (Refer this link to know more about the plugin):

plugins {...
id 'com.palantir.git-version' version '0.12.3'

Next step is to assign the gitVersion method to the version in the gradle build file. You will be having

version = '0.0.1-SNAPSHOT'

Change the line to

version gitVersion()

Now, you are ready to have version your jar files. Before building jar, make sure to add all the files to git and commit by using command:

git add .
git commit -m "Testing Versioning"

Run below command and check build/libs/ folder to see the jar file.

./gradlew bootJar

You may have some random text as name with jar file, that’s the digits in commit hash. Because we have not specified any tags. Specify any tags to build jar with the specified version. (Make sure that there is no file to be committed)

git tag 1.0.0.beta-1

Now run the bootJar command again to build the jar.

./gradlew bootJar

🎉 You are done. You can check the build/libs/ folder to relive that the jar is built with the version you have specified.

Note: Make sure you have git initialised with your project.

Start-up and tech enthusiast. I write about Tech, Devops and anything related.