When I develop a component, a library or start a personal side project, I always feel worried about how tedious is managing versions. I searched on Internet for a solution, however, most of them were complicated to implement, they got a lot of documentation and various configurations.

Why can’t this be something simple?

I will care about complexity later if I feel is necessary.

How can I have a simple versioning system?

The best approach at the moment is to version via a repository tag.

I was concerned about branching strategies though, so I made a question in reddit, discussed with colleagues, and researched a bit more (Semantic Versioning). All that I gathered gave me a clear understanding of how it should work, and I put my hands on and created myself a set of Gradle and Shell scripts:

https://github.com/chattylabs/gradle-versioning-plugin/tree/5aac7c01e5e8c73dd0bde4315404776526fad865

It used to work quite well, but it also used to be time consuming when it was about to configure all the script files. A colleague then convinced me and we finally decided to create a gradle-versioning-plugin.

The usage is simple:

Once applied, it generates a version.properties file with the last version tag.

If you fetch and pull remote changes, run ./gradlew updateVersion .

If you want to persist a new version, run ./gradlew releaseVersion .

But how this increases the version?

You just need to add the configured keywords above in you commit messages.

# Let's pretend the version is 0.1.7, now commit some changes git commit -m "... [feature] ..." // Increases minor by 1

git commit -m "... [bug] ..." // Increases patch by 1

git push origin <branch> # The new version now is 0.2.1 git commit -m "... [bug] ..." // Increases patch by 1

git push origin <branch> # And now version is 0.2.2

Check also the example on the project README file to apply to a CI system.