I've recently upgraded to GitVersion 6.0.x (due to various other issues) and now I can't seem to get my master builds to get versioned correctly. I want the master builds to be named "-alpha" and only any tagged builds to get the exact version of the next-version
field.
This is my gitversion.yml
:
# current development version which is first version of next release branched away from master
next-version: 6.4.0
# configuration for all branches
tag-prefix: '[vV]?'
assembly-versioning-scheme: MajorMinorPatchTag
assembly-file-versioning-scheme: MajorMinorPatchTag
mode: ContinuousDelivery
commit-message-incrementing: Enabled
branches:
master:
label: '-alpha'
regex: ^master$|^main$
is-main-branch: true
feature:
mode: ContinuousDelivery
regex: ^workitems?[/-](?<BranchName>.+)
label: '--w.{BranchName}'
source-branches: ['master']
pre-release-weight: 0
pull-request:
regex: (pull|pull\-requests|pr)[/-]
label: -pr
source-branches: ['master']
# Official product releases
release:
regex: releases/[Vv]
label: beta
# Increment patch version after a release
increment: Patch
source-branches: ['master']
If I'm on a feature branch, everything seems to work, but when I'm on master, this is the output:
{
"AssemblySemFileVer": "6.4.0.48990",
"AssemblySemVer": "6.4.0.48990",
"BranchName": "master",
"BuildMetaData": null,
"CommitDate": "2024-11-05",
"CommitsSinceVersionSource": 48990,
"EscapedBranchName": "master",
"FullBuildMetaData": "Branch.master.Sha.3edf09c0a1683a97b79b2380bXXXX",
"FullSemVer": "6.4.0-48990",
"InformationalVersion": "6.4.0-48990+Branch.master.Sha.3edf09c0a1683a97b79b2380b5XXX",
"Major": 6,
"MajorMinorPatch": "6.4.0",
"Minor": 4,
"Patch": 0,
"PreReleaseLabel": "",
"PreReleaseLabelWithDash": "",
"PreReleaseNumber": 48990,
"PreReleaseTag": "48990",
"PreReleaseTagWithDash": "-48990",
"SemVer": "6.4.0-48990",
"Sha": "3edf09c0a1683a97b79b2380b5cdacXXXXXX",
"ShortSha": "3edf09c",
"UncommittedChanges": 1,
"VersionSourceSha": "",
"WeightedPreReleaseNumber": 103990
}
with the 5.X version of gitversion the output was like:
"Major":6,
"Minor":4,
"Patch":0,
"PreReleaseTag":"alpha.13161",
"PreReleaseTagWithDash":"-alpha.13161",
"PreReleaseLabel":"alpha",
"PreReleaseNumber":13161,
"WeightedPreReleaseNumber":68161,
"BuildMetaData":"",
"BuildMetaDataPadded":"",
"FullBuildMetaData":"Branch.master.Sha.2acac930ea679651600c0ab55cXXXXXXX",
"MajorMinorPatch":"6.4.0",
"SemVer":"6.4.0-alpha.13161",
"LegacySemVer":"6.4.0-alpha13161",
"LegacySemVerPadded":"6.4.0-alpha0013161",
"AssemblySemVer":"6.4.0.13161",
"AssemblySemFileVer":"6.4.0.13161",
"FullSemVer":"6.4.0-alpha.13161",
"InformationalVersion":"6.4.0-alpha.13161+Branch.master.Sha.2acac930ea679651600c0ab55c5XXXXXXXX",
"BranchName":"master",
"Sha":"2acac930ea679651600c0ab55c53bXXXXXXXXXX",
"ShortSha":"2acac93",
"NuGetVersionV2":"6.4.0-alpha0013161",
"NuGetVersion":"6.4.0-alpha0013161",
"NuGetPreReleaseTagV2":"alpha13161",
"NuGetPreReleaseTag":"alpha13161",
"VersionSourceSha":"16f71543433b202773b49d6d5a7dbXXXXXXXXX",
"CommitsSinceVersionSource":13161,
"CommitsSinceVersionSourcePadded":"0013161",
"CommitDate":"2024-10-24"
Relevant part of the old yml file:
# current development version which is first version of next release branched away from master
next-version: 6.4.0
# configuration for all branches
assembly-versioning-scheme: MajorMinorPatchTag
assembly-file-versioning-scheme: MajorMinorPatchTag
mode: ContinuousDeployment
legacy-semver-padding: 7
build-metadata-padding: 7
commits-since-version-source-padding: 7
commit-message-incrementing: Disabled
branches:
master:
regex: ^master$|^main$
tag: alpha
feature:
regex: workitems?[/-]
tag: --w.{BranchName}
source-branches: ['master']
How do I get gitversion 6.0.X to do the same as the previous version for the master branch? Namely the PreRelaseLabel
appears to be always empty.
I found the issue. When running gitversion /showconfig
it was visible that there was a default main
branch included in the configuration which took precedence over the manually defined master
branch. And thus the setting for the master branch where never applied. Changing the yml to
branches:
main:
label: 'alpha'
regex: ^master$|^main$
is-main-branch: true
fixed the issue.