Skip to content

[Bug] Semantic version calculated from tag always ends with this format: 0.1.10-tags-0-1-9-rc-9.0 #3104

Closed
@slzmruepp

Description

@slzmruepp

Describe the bug
We use a trunk based development cycle:

  1. We branch from master to feature/xyz -> Develop Feature -> Rebase master into feature branch, push -f to feature branch - > Create PR - > FF-Merge to master
  2. Merge to master triggers the pipeline which builds the release candidate which gets tagged with x.x.x-rc. So we assume the tip of master is always a release candidate.

The first issue is that even if we use the tag "rc" in the main branch, the Semantic Version always includes the prerelease number:
x.x.x-rc.x
This would be ok to have the prerelease number in the tag on the master branch.
But: We can just not figure out how to get rid of this prerelease number. However, so at the end of the pipeline run we tag the master branch with the prerelease tag automatically with the generated semver:
x.x.x-rc.x

The release pipeline should then deploy the package to staging (-rc), stall there until smoke tests pass and the manually retag the commit to x.x.x (release) and deploy this to production.

This Tag triggers the deployment pipeline which picks up the checked out tag: What we want to achieve is that the tag reflects the release candidate x.x.x-rc WITHOUT the prerelease tag.
This worked once but we just can not find out why it worked for a short period of time.
So in the deployment pipeline from the tagged source, it should move the tag from x.x.x-rc.x -> x.x.x-rc, then retag the commit and from x.x.x-rc it should move to x.x.x which constitutes the released package.

So what we basically want to do is to retag in certain stages: from prerelease x.x.x-rc.x to release candidate in stg x.x.x-rc to release in prod: x.x.x

In the deployment run we get the following output of the semver originating from the 0.1.9-rc.9 tag: 0.1.10-tags-0-1-9-rc-9.0

What we expect is that we see the 0.1.9-rc tag as semver.

Our GitVersion.yml looks like this:

mode: Mainline
# Conventional Commits https://www.conventionalcommits.org/en/v1.0.0/
# https://regex101.com/r/Ms7Vx6/2
major-version-bump-message: "(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([a-z]+\\))?(!: .+|: (.+\\n\\n)+BREAKING CHANGE: .+)"
# https://regex101.com/r/Oqhi2m/1
minor-version-bump-message: "(feat)(\\([a-z]+\\))?: .+"
# https://regex101.com/r/f5C4fP/1
patch-version-bump-message: "(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([a-z]+\\))?: .+"
# Match nothing
no-bump-message: ^\b$
continuous-delivery-fallback-tag: ''
branches:
  development:
    increment: Patch
    # Everything except main and master
    regex: ^(?!(main|master)$)
    track-merge-target: true
    source-branches: []
  feature:
    # Match nothing
    regex: ^\b$
  develop:
    # Match nothing
    regex: ^\b$
  main:
    tag: 'rc'
    source-branches: []
    is-mainline: true
  release:
    # Match nothing
    regex: ^\b$
  pull-request:
    # Match nothing
    regex: ^\b$
  hotfix:
    # Match nothing
    regex: ^\b$
  support:
    # Match nothing
    regex: ^\b$

Output of the master pipeline run:

2022-04-28T17:54:10.4598940Z INFO [04/28/22 17:54:09:96] Working directory: /home/vsts/work/1/s
2022-04-28T17:54:10.4599854Z INFO [04/28/22 17:54:09:98] Project root is: /home/vsts/work/1/s/
2022-04-28T17:54:10.4600430Z INFO [04/28/22 17:54:09:98] DotGit directory is: /home/vsts/work/1/s/.git
2022-04-28T17:54:10.4601130Z INFO [04/28/22 17:54:09:98] Branch from build environment: refs/heads/master
2022-04-28T17:54:10.4602488Z INFO [04/28/22 17:54:09:98] Begin: Normalizing git directory for branch 'refs/heads/master'
2022-04-28T17:54:10.4603562Z   INFO [04/28/22 17:54:10:02] One remote found (origin -> 'https://[email protected]/SulzerChemtech/chemtech/_git/app-infra').
2022-04-28T17:54:10.4604536Z   INFO [04/28/22 17:54:10:02] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2022-04-28T17:54:10.4605582Z   INFO [04/28/22 17:54:10:03] Creating local branch master
2022-04-28T17:54:10.4606845Z   INFO [04/28/22 17:54:10:06] Creating local branch from remote tracking 'refs/remotes/origin/feature/addtagconfig'.
2022-04-28T17:54:10.4607836Z   INFO [04/28/22 17:54:10:07] HEAD points at branch 'refs/heads/master'.
2022-04-28T17:54:10.4608776Z   INFO [04/28/22 17:54:10:07] End: Normalizing git directory for branch 'refs/heads/master' (Took: 83.26ms)
2022-04-28T17:54:10.4609532Z   INFO [04/28/22 17:54:10:08] Begin: Loading version variables from disk cache
2022-04-28T17:54:10.4610291Z     INFO [04/28/22 17:54:10:08] Cache file /home/vsts/work/1/s/.git/gitversion_cache/E2B934FFEC499B9245241DF5F8AD121EB583A6D6.yml not found.
2022-04-28T17:54:10.4611142Z   INFO [04/28/22 17:54:10:08] End: Loading version variables from disk cache (Took: 0.39ms)
2022-04-28T17:54:10.4611770Z   INFO [04/28/22 17:54:10:08] Using latest commit on specified branch
2022-04-28T17:54:10.4612470Z   INFO [04/28/22 17:54:10:22] Running against branch: master (7842338 minor: Add mode mainline)
2022-04-28T17:54:10.4613096Z   INFO [04/28/22 17:54:10:22] Begin: Calculating base versions
2022-04-28T17:54:10.4613845Z     INFO [04/28/22 17:54:10:23] Fallback base version: 0.1.0 with commit count source 246b3264d0f7cee35516a32d157a8d9dfc3ec335
2022-04-28T17:54:10.4614975Z     INFO [04/28/22 17:54:10:26] Git tag '0.1.1-rc.1': 0.1.1-rc.1 with commit count source c6c5961d1bacd321cf8b8f07c8e463191c92deea
2022-04-28T17:54:10.4615950Z     INFO [04/28/22 17:54:10:31] Found multiple base versions which will produce the same SemVer (0.1.1), taking oldest source for commit counting (Fallback base version)
2022-04-28T17:54:10.4617138Z     INFO [04/28/22 17:54:10:31] Base version used: Fallback base version: 0.1.0 with commit count source 246b3264d0f7cee35516a32d157a8d9dfc3ec335
2022-04-28T17:54:10.4617965Z   INFO [04/28/22 17:54:10:31] End: Calculating base versions (Took: 86.54ms)
2022-04-28T17:54:10.4618654Z   INFO [04/28/22 17:54:10:31] 9 commits found between 246b326 Initial commit and 7842338 minor: Add mode mainline
2022-04-28T17:54:10.4619484Z   INFO [04/28/22 17:54:10:31] Begin: Using mainline development mode to calculate current version
2022-04-28T17:54:10.4620421Z     INFO [04/28/22 17:54:10:32] '^master$|^main$' does not match 'feature/addtagconfig'.
2022-04-28T17:54:10.4621353Z     INFO [04/28/22 17:54:10:32] '^\b$' does not match 'feature/addtagconfig'.
2022-04-28T17:54:10.4622161Z     INFO [04/28/22 17:54:10:32] '^master$|^main$' matches 'master'.
2022-04-28T17:54:10.4623688Z     INFO [04/28/22 17:54:10:33] Found merge base 784233875136a77554c0db9673085460c01d96e1 for 'master'.
2022-04-28T17:54:10.4626672Z     INFO [04/28/22 17:54:10:33] '^master$|^main$' does not match 'feature/addtagconfig'.
2022-04-28T17:54:10.4627524Z     INFO [04/28/22 17:54:10:33] '^\b$' does not match 'feature/addtagconfig'.
2022-04-28T17:54:10.4628194Z     INFO [04/28/22 17:54:10:33] '^master$|^main$' matches 'master'.
2022-04-28T17:54:10.4628915Z     INFO [04/28/22 17:54:10:33] Found merge base 784233875136a77554c0db9673085460c01d96e1 for 'origin/master'.
2022-04-28T17:54:10.4629508Z     INFO [04/28/22 17:54:10:33] Found possible mainline branches: master, origin/master
2022-04-28T17:54:10.4629996Z     INFO [04/28/22 17:54:10:33] Choosing master as mainline because it is the current branch
2022-04-28T17:54:10.4630593Z     INFO [04/28/22 17:54:10:33] Direct commit on main 47a358e Add tag config incremented base versions Patch, now 0.1.1
2022-04-28T17:54:10.4631195Z     INFO [04/28/22 17:54:10:33] Direct commit on main c538a13 Increment main minor incremented base versions Patch, now 0.1.2
2022-04-28T17:54:10.4631874Z     INFO [04/28/22 17:54:10:33] Direct commit on main b6bd43d fixup! Increment main minor incremented base versions Patch, now 0.1.3
2022-04-28T17:54:10.4632527Z     INFO [04/28/22 17:54:10:33] Direct commit on main 419c4c1 fixup! fixup! Increment main minor incremented base versions Patch, now 0.1.4
2022-04-28T17:54:10.4633198Z     INFO [04/28/22 17:54:10:33] Direct commit on main fc1bd00 fixup! fixup! fixup! Increment main minor incremented base versions Patch, now 0.1.5
2022-04-28T17:54:10.4633950Z     INFO [04/28/22 17:54:10:33] Direct commit on main 3937c6a fixup! fixup! fixup! fixup! Increment main minor incremented base versions Patch, now 0.1.6
2022-04-28T17:54:10.4634608Z     INFO [04/28/22 17:54:10:33] Direct commit on main 7f1fe00 fix: Added gitversion incremented base versions Patch, now 0.1.7
2022-04-28T17:54:10.4635330Z     INFO [04/28/22 17:54:10:33] Direct commit on main c6c5961 fix: bumped templates incremented base versions Patch, now 0.1.8
2022-04-28T17:54:10.4635953Z     INFO [04/28/22 17:54:10:33] Direct commit on main 7842338 minor: Add mode mainline incremented base versions Patch, now 0.1.9
2022-04-28T17:54:10.4636614Z     INFO [04/28/22 17:54:10:33] 9 commits found between 246b326 Initial commit and 7842338 minor: Add mode mainline
2022-04-28T17:54:10.4637186Z   INFO [04/28/22 17:54:10:33] End: Using mainline development mode to calculate current version (Took: 21.28ms)
2022-04-28T17:54:10.4637981Z   INFO [04/28/22 17:54:10:33] Begin: Getting version tags from branch 'refs/heads/master'.
2022-04-28T17:54:10.4638711Z   INFO [04/28/22 17:54:10:34] End: Getting version tags from branch 'refs/heads/master'. (Took: 5.07ms)
2022-04-28T17:54:10.4639237Z   INFO [04/28/22 17:54:10:34] Begin: Creating dictionary
2022-04-28T17:54:10.4639640Z   INFO [04/28/22 17:54:10:35] End: Creating dictionary (Took: 4.42ms)
2022-04-28T17:54:10.4640282Z   INFO [04/28/22 17:54:10:35] Begin: Storing version variables to cache file /home/vsts/work/1/s/.git/gitversion_cache/E2B934FFEC499B9245241DF5F8AD121EB583A6D6.yml
2022-04-28T17:54:10.4641167Z   INFO [04/28/22 17:54:10:39] End: Storing version variables to cache file /home/vsts/work/1/s/.git/gitversion_cache/E2B934FFEC499B9245241DF5F8AD121EB583A6D6.yml (Took: 41.76ms)
2022-04-28T17:54:10.4642018Z Executing GenerateSetVersionMessage for 'AzurePipelines'.
2022-04-28T17:54:10.4654103Z ##[debug]Update build number for build: 26202 to: 0.1.9-rc.9 at backend.

Output of the subsequent deployment pipeline run triggered by tagging of this tag: 0.1.9-rc.9 and checked out tag:

2022-04-28T18:05:24.4348335Z INFO [04/28/22 18:05:23:82] Working directory: /home/vsts/work/1/s
2022-04-28T18:05:24.4363341Z INFO [04/28/22 18:05:23:85] Project root is: /home/vsts/work/1/s/
2022-04-28T18:05:24.4364283Z INFO [04/28/22 18:05:23:85] DotGit directory is: /home/vsts/work/1/s/.git
2022-04-28T18:05:24.4366110Z INFO [04/28/22 18:05:23:85] Branch from build environment: refs/tags/0.1.9-rc.9
2022-04-28T18:05:24.4367435Z INFO [04/28/22 18:05:23:85] Begin: Normalizing git directory for branch 'refs/tags/0.1.9-rc.9'
2022-04-28T18:05:24.4369210Z   INFO [04/28/22 18:05:23:89] One remote found (origin -> 'https://[email protected]/SulzerChemtech/chemtech/_git/app-infra').
2022-04-28T18:05:24.4370402Z   INFO [04/28/22 18:05:23:90] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2022-04-28T18:05:24.4379620Z   INFO [04/28/22 18:05:23:91] Creating local branch tags/0.1.9-rc.9 pointing at 7842338
2022-04-28T18:05:24.4384861Z   INFO [04/28/22 18:05:23:94] Creating local branch from remote tracking 'refs/remotes/origin/feature/addtagconfig'.
2022-04-28T18:05:24.4385968Z   INFO [04/28/22 18:05:23:96] Creating local branch from remote tracking 'refs/remotes/origin/master'.
2022-04-28T18:05:24.4386769Z   INFO [04/28/22 18:05:23:96] HEAD points at branch 'refs/heads/tags/0.1.9-rc.9'.
2022-04-28T18:05:24.4387648Z   INFO [04/28/22 18:05:23:96] End: Normalizing git directory for branch 'refs/tags/0.1.9-rc.9' (Took: 108.70ms)
2022-04-28T18:05:24.4388301Z   INFO [04/28/22 18:05:23:97] Begin: Loading version variables from disk cache
2022-04-28T18:05:24.4389089Z     INFO [04/28/22 18:05:23:97] Cache file /home/vsts/work/1/s/.git/gitversion_cache/26FDAFEB26614DF0EE6E7C7151FF249BBE0F6DF3.yml not found.
2022-04-28T18:05:24.4389739Z   INFO [04/28/22 18:05:23:97] End: Loading version variables from disk cache (Took: 0.52ms)
2022-04-28T18:05:24.4390229Z   INFO [04/28/22 18:05:23:98] Using latest commit on specified branch
2022-04-28T18:05:24.4391011Z   INFO [04/28/22 18:05:24:15] Running against branch: tags/0.1.9-rc.9 (7842338 minor: Add mode mainline)
2022-04-28T18:05:24.4392026Z   INFO [04/28/22 18:05:24:16] Current commit is tagged with version 0.1.9-rc.9, version calculation is for metadata only.
2022-04-28T18:05:24.4393065Z   INFO [04/28/22 18:05:24:17] 0 commits found between 7842338 minor: Add mode mainline and 7842338 minor: Add mode mainline
2022-04-28T18:05:24.4393924Z   INFO [04/28/22 18:05:24:17] Begin: Calculating base versions
2022-04-28T18:05:24.4394503Z     INFO [04/28/22 18:05:24:18] Fallback base version: 0.1.0 with commit count source 246b3264d0f7cee35516a32d157a8d9dfc3ec335
2022-04-28T18:05:24.4395552Z     INFO [04/28/22 18:05:24:19] Git tag '0.1.9-rc.9': 0.1.9-rc.9 with commit count source 784233875136a77554c0db9673085460c01d96e1
2022-04-28T18:05:24.4396929Z     INFO [04/28/22 18:05:24:25] Found multiple base versions which will produce the same SemVer (0.1.1), taking oldest source for commit counting (Fallback base version)
2022-04-28T18:05:24.4397776Z     INFO [04/28/22 18:05:24:25] Base version used: Fallback base version: 0.1.0 with commit count source 246b3264d0f7cee35516a32d157a8d9dfc3ec335
2022-04-28T18:05:24.4398404Z   INFO [04/28/22 18:05:24:25] End: Calculating base versions (Took: 75.16ms)
2022-04-28T18:05:24.4398978Z   INFO [04/28/22 18:05:24:25] 9 commits found between 246b326 Initial commit and 7842338 minor: Add mode mainline
2022-04-28T18:05:24.4399587Z   INFO [04/28/22 18:05:24:25] Begin: Using mainline development mode to calculate current version
2022-04-28T18:05:24.4400493Z     INFO [04/28/22 18:05:24:26] '^master$|^main$' does not match 'feature/addtagconfig'.
2022-04-28T18:05:24.4401220Z     INFO [04/28/22 18:05:24:26] '^\b$' does not match 'feature/addtagconfig'.
2022-04-28T18:05:24.4401901Z     INFO [04/28/22 18:05:24:26] '^master$|^main$' matches 'master'.
2022-04-28T18:05:24.4404961Z     INFO [04/28/22 18:05:24:27] Found merge base 784233875136a77554c0db9673085460c01d96e1 for 'master'.
2022-04-28T18:05:24.4405823Z     INFO [04/28/22 18:05:24:27] '^master$|^main$' does not match 'tags/0.1.9-rc.9'.
2022-04-28T18:05:24.4406552Z     INFO [04/28/22 18:05:24:27] '^\b$' does not match 'tags/0.1.9-rc.9'.
2022-04-28T18:05:24.4407342Z     INFO [04/28/22 18:05:24:27] '^master$|^main$' does not match 'feature/addtagconfig'.
2022-04-28T18:05:24.4408077Z     INFO [04/28/22 18:05:24:27] '^\b$' does not match 'feature/addtagconfig'.
2022-04-28T18:05:24.4408755Z     INFO [04/28/22 18:05:24:27] '^master$|^main$' matches 'master'.
2022-04-28T18:05:24.4409844Z     INFO [04/28/22 18:05:24:27] Found merge base 784233875136a77554c0db9673085460c01d96e1 for 'origin/master'.
2022-04-28T18:05:24.4410436Z     INFO [04/28/22 18:05:24:27] Found possible mainline branches: master, origin/master
2022-04-28T18:05:24.4411464Z     INFO [04/28/22 18:05:24:27] Choosing master as mainline because tags/0.1.9-rc.9's merge base was a direct commit to master
2022-04-28T18:05:24.4412293Z     INFO [04/28/22 18:05:24:27] Found branch merge point; choosing 7842338 minor: Add mode mainline as effective mainline tip
2022-04-28T18:05:24.4413183Z     INFO [04/28/22 18:05:24:27] Current branch (tags/0.1.9-rc.9) was branch from 7842338 minor: Add mode mainline
2022-04-28T18:05:24.4413845Z     INFO [04/28/22 18:05:24:28] Direct commit on main 47a358e Add tag config incremented base versions Patch, now 0.1.1
2022-04-28T18:05:24.4414509Z     INFO [04/28/22 18:05:24:28] Direct commit on main c538a13 Increment main minor incremented base versions Patch, now 0.1.2
2022-04-28T18:05:24.4415504Z     INFO [04/28/22 18:05:24:28] Direct commit on main b6bd43d fixup! Increment main minor incremented base versions Patch, now 0.1.3
2022-04-28T18:05:24.4416399Z     INFO [04/28/22 18:05:24:28] Direct commit on main 419c4c1 fixup! fixup! Increment main minor incremented base versions Patch, now 0.1.4
2022-04-28T18:05:24.4417130Z     INFO [04/28/22 18:05:24:28] Direct commit on main fc1bd00 fixup! fixup! fixup! Increment main minor incremented base versions Patch, now 0.1.5
2022-04-28T18:05:24.4417864Z     INFO [04/28/22 18:05:24:28] Direct commit on main 3937c6a fixup! fixup! fixup! fixup! Increment main minor incremented base versions Patch, now 0.1.6
2022-04-28T18:05:24.4418579Z     INFO [04/28/22 18:05:24:28] Direct commit on main 7f1fe00 fix: Added gitversion incremented base versions Patch, now 0.1.7
2022-04-28T18:05:24.4419423Z     INFO [04/28/22 18:05:24:28] Direct commit on main c6c5961 fix: bumped templates incremented base versions Patch, now 0.1.8
2022-04-28T18:05:24.4420291Z     INFO [04/28/22 18:05:24:28] Direct commit on main 7842338 minor: Add mode mainline incremented base versions Patch, now 0.1.9
2022-04-28T18:05:24.4420972Z     INFO [04/28/22 18:05:24:28] 0 commits found between 7842338 minor: Add mode mainline and 7842338 minor: Add mode mainline
2022-04-28T18:05:24.4421567Z     INFO [04/28/22 18:05:24:28] Performing Patch increment for current branch 
2022-04-28T18:05:24.4422122Z   INFO [04/28/22 18:05:24:28] End: Using mainline development mode to calculate current version (Took: 29.34ms)
2022-04-28T18:05:24.4422684Z   INFO [04/28/22 18:05:24:28] Using branch name to calculate version tag
2022-04-28T18:05:24.4423515Z   INFO [04/28/22 18:05:24:28] Begin: Getting version tags from branch 'refs/heads/tags/0.1.9-rc.9'.
2022-04-28T18:05:24.4424372Z   INFO [04/28/22 18:05:24:30] End: Getting version tags from branch 'refs/heads/tags/0.1.9-rc.9'. (Took: 14.79ms)
2022-04-28T18:05:24.4424932Z   INFO [04/28/22 18:05:24:30] Begin: Creating dictionary
2022-04-28T18:05:24.4425372Z   INFO [04/28/22 18:05:24:31] End: Creating dictionary (Took: 5.53ms)
2022-04-28T18:05:24.4426162Z   INFO [04/28/22 18:05:24:31] Begin: Storing version variables to cache file /home/vsts/work/1/s/.git/gitversion_cache/26FDAFEB26614DF0EE6E7C7151FF249BBE0F6DF3.yml
2022-04-28T18:05:24.4426968Z   INFO [04/28/22 18:05:24:36] End: Storing version variables to cache file /home/vsts/work/1/s/.git/gitversion_cache/26FDAFEB26614DF0EE6E7C7151FF249BBE0F6DF3.yml (Took: 49.43ms)
2022-04-28T18:05:24.4449314Z Executing GenerateSetVersionMessage for 'AzurePipelines'.
2022-04-28T18:05:24.4461279Z ##[debug]Update build number for build: 26203 to: 0.1.10-tags-0-1-9-rc-9.0 at backend.

Expected Behavior

We want the semver from a tag checked out be calculated as x.x.x-rc

Actual Behavior

Possible Fix

Steps to Reproduce

Context

Your Environment

  • Version Used:
  • Operating System and version (Windows 10, Ubuntu 18.04):
  • Link to your project:
  • Link to your CI build (if appropriate):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions