Andrei Fedotov
Posted on June 8, 2021
Hello everyone!
What we have
We use the well-known schema for versioning the product builds:
major.minor[.build[.revision]]
For example: 3.2.1234.0
.
We use GitHub Actions for CI/CD needs. We use GitHub's run_number
value as a build
number.
The challenge
Recently we faced a challenge to set an offset for different types of build (e.g. production/test builds).
Searching over the internet had a lack of answers to the question of how to change run_number
or how to increment it.
The solution
After a good bit of time spent on documentation investigation, we came up with a solution. Assume run_number
is 1000
. And we want the build number to be 5000
. And the final product version we want to have 3.2.5000.0
We can do the following as separate step in the workflow:
steps:
- name: Set version number
run: |
$version = "3.2."+(4000+$($Env:GITHUB_RUN_NUMBER))+".0"
echo $version
echo "VERSION_NUMBER=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
That's it. Now the variable VERSION_NUMBER
contains the value 3.2.5000.0
.
And we can use that value across the workflow like this (e.g. we construct installer package name that containing the version):
MyProduct.${{ env.VERSION_NUMBER }}.msi
.
Hope this would be helpful for you.
Cheers!
Posted on June 8, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 29, 2024