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

Bump each commit + patch patter does not update changed output correctly

Open PaulHatch opened this issue 1 year ago • 0 comments

Discussed in https://github.com/PaulHatch/semantic-version/discussions/139

Originally posted by rmendal February 29, 2024 Hi, I'm running this action in my repo and I want it to increment the version when there is a change to the docs directory AND one of the keywords for bump_each_commit_patch_pattern is met. I do have bump_each_commit set to true as well.

It's entirely possible I'm not understanding the docs and doing this wrong but I'm assuming that based on my code below that if I make a change in the docs dir AND make a commit with a message like, "minor docs update" that the changed output will be true otherwise it will be false. However, if I don't make any changes in docs the changed output is always true. This includes commit messages that don't contain any pattern keywords. Possibly worth mentioning that I've disabled bump_each_commit but that had no effect.

Please tell me what I'm doing wrong here.

- name: Image Version
      id: version
      uses: paulhatch/[email protected]
      with:
        # The prefix to use to identify tags
        tag_prefix: ""
        # 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: '/\bmajor\b/'
        # 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: '/\bminor\b/'
        # 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}"
        # Optional path to check for changes. If any changes are detected in the path the
        # 'changed' output will true. Enter multiple paths separated by spaces.
        change_path: "docs"
        # Named version, will be used as suffix for name version tag
        # namespace: my-service
        # If this is set to true, *every* commit will be treated as a new version.
        bump_each_commit: true
        # If bump_each_commit is also set to true, setting this value will cause the version to increment only if the pattern specified is matched.
        bump_each_commit_patch_pattern: '/\bmajor|minor|patch\b/'
        # If true, the body of commits will also be searched for major/minor patterns to determine the version type.
        search_commit_body: false
        # The output method used to generate list of users, 'csv' or 'json'.
        user_format_type: "csv"
        # Prevents pre-v1.0.0 version from automatically incrementing the major version.
        # If enabled, when the major version is 0, major releases will be treated as minor and minor as patch. Note that the version_type output is unchanged.
        enable_prerelease_mode: true
        # If enabled, diagnostic information will be added to the action output.
        debug: true
        # If true, the branch will be used to select the maximum version.
        version_from_branch: false
    - run: |
        echo "${{ steps.version.outputs.changed }}"

Action output from a run with a comment added to the action yaml file in .github/workflows, no change to the docs dir and a commit message of update no docs changes

Run paulhatch/[email protected]
  with:
    major_pattern: /\bmajor\b/
    minor_pattern: /\bminor\b/
    version_format: ${major}.${minor}.${patch}
    change_path: docs
    bump_each_commit: true
    bump_each_commit_patch_pattern: /\bmajor|minor|patch\b/
    search_commit_body: false
    user_format_type: csv
    enable_prerelease_mode: true
    debug: true
    version_from_branch: false
    branch: HEAD
    use_branches: false
Version is 2.8.5
To create a release for this version, go to https://github.com/***//releases/new?tag=2.8.5&target=55cf0c6825c05[3](https://github.com/***//actions/runs/8088000993/job/22101121667#step:4:3)a561ce0e[4](https://github.com/***//actions/runs/8088000993/job/22101121667#step:4:4)2f2e10dc04ad80d2f
0s
Run echo "true"
  echo "true"
true
```</div>

PaulHatch avatar Mar 07 '24 08:03 PaulHatch