Azure 39: GitVersion → image tag → chart version
easy⏱ 5 mincourseazure
Mainline workflow
Lythia uses mainline branching: PRs merge to main, no long-lived develop branch. Each merge bumps the patch by default. Commit messages can opt into bigger bumps with magic strings: +semver: minor (feature), +semver: major / +semver: breaking (incompatible change). PR branches get pre-release tags like 1.4.0-feat-cart-1.5 so canary builds don't collide with main.
# GitVersion.yml in pipeline-templates
mode: ContinuousDelivery
branches:
main:
regex: ^main$
tag: ''
increment: Patch
feature:
regex: ^feature[/-]
tag: useBranchName
increment: Inherit
GitVersion as a CI step
pipeline-templates/ci/jobs/determine-version.yaml runs the GitVersion container and exports GITVERSION_SEMVER, MAJOR, MINOR, PATCH, BRANCH_SAFE. Downstream jobs consume those: Docker tags the image service:1.4.2, Helm packages the chart with version: 1.4.2, npm publishes @driveway/react@1.4.2. One commit, one SemVer, propagated everywhere.
- task: PublishPipelineArtifact@1
inputs:
artifactName: version
# downstream
steps:
- script: docker build -t $(acrContainer)/$(serviceName):$(GIT_SEM_VER) .
- script: helm package ./chart --version $(GIT_SEM_VER) --app-version $(GIT_SEM_VER)
Compute the next version
Write nextVersion(currentTag, commits) where commits is an array of { message, branch }. Start from currentTag ('1.4.1'). For each commit on main: if message contains +semver: breaking, bump major and reset minor/patch; if +semver: minor, bump minor and reset patch; otherwise bump patch. For non-main branches, suffix with -<branchSafe>.<n> where n increments per commit. Log the final tag.
Use the same SemVer for the docker tag AND the chart version
It is seductive to tag the chart with a build-number and the image with SemVer. Don't. Argo Rollouts and Datadog correlate by image tag; on-call correlates incidents by chart version. If they diverge, the same version string means two different things in two different tools and root-causing prod issues takes 4x longer. One number, one truth.
Quiz: pre-release ordering
Three tags exist: 1.4.0, 1.4.0-feat-cart.3, 1.4.0-feat-cart.10. Which is newest per SemVer? 1.4.0 (no pre-release suffix). And 1.4.0-feat-cart.10 > 1.4.0-feat-cart.3 because pre-release dot-separated identifiers compare numerically when all-numeric. Helm and npm both follow this rule, so chart upgrades from feat-cart.10 to 1.4.0 work cleanly.