Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow assigning a version to the main branch / feature branches in a more easy way #3159

Closed
moses70 opened this issue Jul 27, 2022 · 8 comments

Comments

@moses70
Copy link

moses70 commented Jul 27, 2022

Improve version sources so that builds from the main branch can have a proper ALPHA-version without breaking release branches
I find it very difficult to assign a version to the main branch without affecting any release branches.
Often, the release branches are "inheriting" all version tags from the main branch and in the end the release gets a wrong version.
There should be a way to set a version source for only one branch and block any impact to other branches.

Detailed Description / Context

In git, all branches go eventually back to the same origin.
For release branches especially, I want to be able to create a new branch from main any time. So when I have a tag "3.0-alpha" in my main branch, all derived release branches will see this tag also.

But my release branch "release/2.2" should use yield a version "2.2-beta" based on the branch name.
The only way to achieve this now is to make sure that the "3.0-alpha" tag does not show up in the release branch's history. Otherwise it will take precendence.

I understand that the "next-version" configuration setting could help here. But unfortunately, the "next-version" seems to have precence over the branch name as a version source. So it does not seem to be a way.

Possible Implementation

On solution could be to let the "branch name" version source have precence over "next-version".
I guess this would be a breaking change so maybe activate this behavior with a new config option?

Another way would be to allow "next-version" to be branch-specific.
Or one could thing about making "tag-prefix" branch-specific, which would allow to restrict visiblity a special version tag only to main and feature-branches.

@asbjornu
Copy link
Member

Can you please share your GitVersion.yml configuration?

@moses70
Copy link
Author

moses70 commented Jul 30, 2022

Hi asbjornu,

this is my configuration:

assembly-versioning-scheme: MajorMinorPatchTag
mode: ContinuousDeployment
branches:
  release:
    increment: Patch
  main:
    tag: alpha
ignore:
  sha: []
merge-message-formats: {}

@moses70
Copy link
Author

moses70 commented Aug 9, 2022

Hi asbjornu,

thank you for your first feedback to this topic.
Is my description and suggestion understandable to you?

@asbjornu
Copy link
Member

What happens if you set source-branches to [] (an empty list) for your release branches?

@moses70
Copy link
Author

moses70 commented Aug 18, 2022

Hi asbornu,

Thank you, that sounds reasonable! Just tried it out:

The result is not what I wanted yet, because the tag "3.0-alpha" from the "main" branch is still taking precendence over the branch name "release/2.8". I expected that the tag from main would be ignored completely.

  INFO [08/18/22 13:32:53:80] Fallback base version: 0.1.0 with commit count source 5c5a3ee51e63b083c165b223f1af3b02722216bf
  INFO [08/18/22 13:32:53:86] Git tag '3.0-alpha': 3.0.0-alpha with commit count source f1a774b0611600797783714e57565e1b43c4d209
  INFO [08/18/22 13:32:53:86] Begin: Finding branch source of 'release/2.8'
  INFO [08/18/22 13:32:53:88] End: Finding branch source of 'release/2.8' (Took: 18.78ms)
  INFO [08/18/22 13:32:53:88] Version in branch name: 2.8.0 with commit count source External Source
  INFO [08/18/22 13:32:53:91] Found multiple base versions which will produce the same SemVer (3.0.0-alpha), taking oldest source for commit counting (Git tag '3.0-alpha')
  INFO [08/18/22 13:32:53:91] Base version used: Git tag '3.0-alpha': 3.0.0-alpha with commit count source f1a774b0611600797783714e57565e1b43c4d209
  INFO [08/18/22 13:32:53:91] End: Calculating base versions (Took: 128.35ms)

My new configuration is:

assembly-versioning-scheme: MajorMinorPatchTag
mode: ContinuousDeployment
branches:
  release:
    increment: Patch
    source-branches: []
  main:
    tag: alpha
ignore:
  sha: []
merge-message-formats: {}

The new option is definitely an improvement because the
" Multiple source branches have been found, picking the first one (main)." warning went away.

Is there a way to achieve the behavior that I want, or would you suggest to use another approach?

@moses70
Copy link
Author

moses70 commented Aug 18, 2022

After some more tests, I found a promising approach:

I realized that I want to have my "main" branch to act more like a "develop" branch. So I added this:

image

And I removed the "3.0-alpha" tag from main (and all other old version tags because they dont belong there anyways).
Because I already have a "release/2.0" and a "release/2.1" branch, I end up with "3.0-alpha" in main which is what I want.

What do you think?

@asbjornu
Copy link
Member

Sounds good!

@HHobeck
Copy link
Contributor

HHobeck commented Mar 4, 2023

Okay that means GitVersion has already all configuration option on board to fullfill your requirements right? I'm going to close this issue. Please give me a feedback if you are not agree.

Please notice you can use the new workflow feature to write your custom workflow from scratch: #3305

Cheers.

@HHobeck HHobeck closed this as completed Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants