How to increment version minor/patch based on the branch from which we merge

Viewed 392

We have a simple GitHubFlow workflow with feature/* and bug/* branches.

When things are merged to master, then the version gets bumped whatever we specify in the GitVersion.yml file (minor/patch).

mode: Mainline
branches:
  main:
    regex: ^master$
    tag: ''
    # Increment is always the same regardless of the branch from which we are merging
    increment: Minor

  feature:
    regex: ^feature/
    tag: useBranchName
    increment: Minor
    source-branches:
    - main

  bug:
    regex: ^bug/
    tag: useBranchName
    increment: Patch
    source-branches:
    - main

However, I'd like to bump the minor or patch version depending on whether we merged from a feature or bug branch.

I'm using Squashing when merging to master.

Is there a way to do this please?

1 Answers

Unfortunately, I was not able to increment the major, minor and patch versions based on the branch (the increment property inside each branch is ignored) so all merges to master increment the same way but with possibility to bump differently based on something added to the message e.g. Add +f (feature) to increment minor versions and +b (bug) to increment patch version.

mode: Mainline
major-version-bump-message: '\+major'
minor-version-bump-message: '\+f'
patch-version-bump-message: '\+b'
branches:
  master:
    regex: ^master$
    tag: ""
    increment: Minor
    is-mainline: true

  feature:
    regex: ^feature/
    tag: useBranchName
    increment: Patch

  bug:
    regex: ^bug/
    tag: useBranchName
    increment: Patch
    source-branches:
      - master
Related