I recently got introduced to the concept of CalVer. I thought I'd play with the concept on a little test build, to see if I could get a meta-runner extracted to be used for other builds, should we decide to take this forward.
I'm looking to:
- Have a build step that runs on Linux and Windows agents
- Have a build number in the format: YY.MM.BC (2 digit year, 2 digit month and the build counter).
- Have the build counter reflect the number of builds in a given month
I'm happy to play with the format more as time goes on.
I have the first parts done. To make this compatible with both our linux and Windows build agents, I've leveraged the Docker support and run the script in this step in an alpine container. It only adds on 1 second and makes it cross-platform. I then use a script like this to update the build number to a CalVer looking build.
date_portion=$(date +"%%y.%%m")
build_number=$BUILD_NUMBER
combined="${date_portion}.${build_number}"
echo "##teamcity[buildNumber '$combined']"
Results in build numbers like: 18.11.1
My question is: How would I go about making it so that builds I do in December have a build counter starting off at 1? I'd rather not have to run a build once a month to reset it if I can help it. Are there any cleaner ways?