I want to automate my versioning in an azure devops pipeline. The way it should work is as follows:
- The major number is given as constant and will be increased manually.
- The minor number should be incremented for each build of the master branch.
- On the develop branch the minor number should not increase, but have always the last value used by the master branch plus one.
(Develop-Build numbers will have an additional increasing revision, but this is not part of the question. I also omit the patch number to make the example shorter.)
Example:
- Build master => major 1, minor 1
- Build develop => major 1, minor 2
- Build develop => major 1, minor 2
- Build master => major 1, minor 2
- Build develop => major 1, minor 3
- Build develop => major 1, minor 3
- Build master => major 2, minor 1
- Build develop => major 2, minor 2
I already managed the autoincrement only for the master branch like
variables:
major: 1
minor: $[counter(variables['major'], 1)]
in combination with the condition
eq(variables['Build.SourceBranch'], 'refs/heads/master')
But I don't know how to get the next counter value from a develop build without incrementing it.