semantic-version icon indicating copy to clipboard operation
semantic-version copied to clipboard

Bump each commit false seems to be ignored

Open Andreas1331 opened this issue 1 year ago • 4 comments

As of Version 5.3.0 the argument "bump_each_commit: false" does not seem to ignore commits that do not match either major or minor pattern. Any commit not matching major or minor will cause the patch to increase, but it is my understand this argument is suppose to filter these and ignore them.

I have a very simple GitHub Action Workflow setup that generates a new tag version, and creates a tag. I am using the default options, and every commit has an empty body and a simple title with either (MAJOR), (MINOR) or random characters to create commits that should be ignore.

Every push I make causes the patch to increment, and I'm using the format MAJOR.MINOR.PATCH and also all major commits causes MINOR to go up it seems. Am I using this wrong?

` on: push: branches: - main # Adjust branch name as needed workflow_dispatch:

jobs: update-version: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0

  - name: Get next version
    id: versioning
    uses: paulhatch/[email protected]
    with:
      # The prefix to use to identify tags
      tag_prefix: "v"
      # A string which, if present in a git commit, indicates that a change represents a
      # major (breaking) change, supports regular expressions wrapped with '/'
      major_pattern: "(MAJOR)"
      # A string which indicates the flags used by the `major_pattern` regular expression. Supported flags: idgs
      major_regexp_flags: ""
      # Same as above except indicating a minor change, supports regular expressions wrapped with '/'
      minor_pattern: "(MINOR)"
      # A string which indicates the flags used by the `minor_pattern` regular expression. Supported flags: idgs
      minor_regexp_flags: ""
      # A string to determine the format of the version output
      version_format: "${major}.${minor}.${patch}"
      # Named version, will be used as suffix for name version tag
      namespace: ""
      # If this is set to true, *every* commit will be treated as a new version.
      bump_each_commit: false
      # If true, the body of commits will also be searched for major/minor patterns to determine the version type.
      search_commit_body: false
      # If enabled, diagnostic information will be added to the action output.
      debug: true
      
  - name: Create tag
    uses: EndBug/latest-tag@latest
    with:
      # You can change the name of the tag with this input.
      # Default: 'latest'
      ref: ${{ steps.versioning.outputs.version_tag }}

`

image

Andreas1331 avatar Mar 24 '24 21:03 Andreas1331

By automatically tagging each commit with the version, you are causing the version to be incremented on the next commit.

PaulHatch avatar Mar 25 '24 06:03 PaulHatch

Thank you for responding @PaulHatch

However, it doesn't seem to make any difference if I have the tagging of each commit or not. I tried to modify my workflow to only run the semantic-version to see if there's a new version warranted or not. These were the tags before: image and this was the commit: image and here's the workflow running on that commit: image and the result of the workflow stating the next version is now 1.0.4 image

This should have said no new version detected, as the commit does not contain any of the keywords for MAJOR or MINOR, nor do I have the bump on every commit enabled.

Here is the modified workflow that simply runs on pushes, pulls the commits and runs semantic-version.

`name: Update csproj version

on: push: branches: - main # Adjust branch name as needed workflow_dispatch:

jobs: update-version: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0

  - name: Get next version
    id: versioning
    uses: paulhatch/[email protected]
    with:
      # The prefix to use to identify tags
      tag_prefix: "v"
      # A string which, if present in a git commit, indicates that a change represents a
      # major (breaking) change, supports regular expressions wrapped with '/'
      major_pattern: "(MAJOR)"
      # A string which indicates the flags used by the `major_pattern` regular expression. Supported flags: idgs
      major_regexp_flags: ""
      # Same as above except indicating a minor change, supports regular expressions wrapped with '/'
      minor_pattern: "(MINOR)"
      # A string which indicates the flags used by the `minor_pattern` regular expression. Supported flags: idgs
      minor_regexp_flags: ""
      # A string to determine the format of the version output
      version_format: "${major}.${minor}.${patch}"
      # Named version, will be used as suffix for name version tag
      namespace: ""
      # If this is set to true, *every* commit will be treated as a new version.
      bump_each_commit: false
      # If true, the body of commits will also be searched for major/minor patterns to determine the version type.
      search_commit_body: false
      # If enabled, diagnostic information will be added to the action output.
      debug: true

`

Am I using this right, or is this just expected behavior?

Andreas1331 avatar Mar 25 '24 17:03 Andreas1331

Follow up.

I tried to just set the bumping pattern to a bunch of 1's and then set bumping to true. Now it stopped incrementing the patch on every commit. The second I commit with all my 1's the patch goes up.

bump_each_commit: true bump_each_commit_patch_pattern: "11111"

A commit that didn't follow the required pattern, which usually would trigger patch to increase. image

and afterwards a new commit "11111", that triggers the patch to increase. image

So bump_each_commit: false does not seem to work for me.

Andreas1331 avatar Mar 25 '24 18:03 Andreas1331

Made a duplicate of this and now discovered there's an issue open for it already. Have the same issue here. As I understand from the docs, setting bump_each_commit: false should not increment a patch on each commit, but it does. Unless of course I'm reading this wrong:

# If this is set to true, *every* commit will be treated as a new version.
    bump_each_commit: false

And it actually means something else?

I've also set the bump_each_commit_patch_pattern now and that also stopped a patch from being created on each commit.


UPD: @Andreas1331 , the author of this action included a more detailed explanation on how this is supposed to work in the other issue: https://github.com/PaulHatch/semantic-version/issues/154#issuecomment-2064935274

serpro69 avatar Apr 18 '24 19:04 serpro69