gitbranching-strategygitversion

How to configure GitVersion for Release Flow?


I am trying to configure GitVersion to work with the Release Flow branching strategy.

enter image description here

Basically, I have a mainline Master branch, Release, Feature and Fix branches. The Feature and Fix branches are created from the Master branch and merged back into Master via a pull request. At the end of a sprint, I create a Release branch from Master, which will last till the end of the next sprint, when a new Release branch will be created. The Release branches are not merged back into master. They can even be deleted after a new Release branch has been created. If there's a hotfix needed, it will be developed on a Fix branch created from and merged back into master and then cherry-picked into the current Release branch. I only use git tags for major releases.

Going back to GitVersion, I want to configure it so that the minor version number will increase when I create a new release branch and the patch number to increase when there's a new commit on the release branch (cherry-picked from a Fix branch).

Has anyone done that already and can help me?


Solution

  • We use flow pretty similar to this one (actually based on it). We do hotfixes right on release branches and we also create pre-release branches before release ones (convenient to have separate channels in octopus-deploy).

    After a bit struggle, i ended up with my own PowerShell script. The script is simple and works super fast (near 1 second, unlike GitVersion, which could work 5-15 minutes on our huge repos with big amount of branches). Now, the result looks like that:

    It mostly designed to usage with TeamCity, but i think you could easily change it to feet you needs. You can see detailed description of calculation algorithm inside script comments. It also briefly explained on this diagram:

    Caveat: In future/topic branches, unlike GitVersion, script uses always growing build counter from teamcity, instead of commits counter. I had to do it, when i found out than our colleges use force pushes(some "clean history" politics), and i can't rely on commits history.