Closed eric-personal closed 6 months ago
Yes, it's true that running the action always bumps the version. If not specified it will increment the patch version.
You could create an if
condition for the workflow (or even just the Bump package version
step). For example, to base the condition on having a certain string in the commit message you can use a condition like this.
jobs:
version-bump:
if: "startsWith(github.event.head_commit.message, 'VERSION BUMP:')"
If you more frequently wish to bump the version than not bump the version, you could invert the condition to prevent it.
jobs:
version-bump:
if: "!startsWith(github.event.head_commit.message, 'NO BUMP:')"
These conditions are just examples.
As a real world example, our workflow creates an rc version bump by default, not a patch. To achieve that we used the following settings.
...
with:
# These words need to be part of a commit to trigger
# They are purposefully complex to avoid accidental triggers
major-wording: 'major-bb-protected'
minor-wording: 'minor-bb-protected'
patch-wording: 'patch-bb-protected'
# needs to be empty for all pushes to be prerelease
rc-wording: ''
# defaulting to bump prerelease version--default is patch
default: prerelease
preid: 'rc'
tag-prefix: 'v'
target-branch: 'main'
commit-message: 'CI: bumps version to {{version}}'
Another option is to include [ci skip]
in the commit message, from Github Docs. Note that this will skip all action workflows that would otherwise be triggered by the commit.
I think the formatting of the if
statement may have changed; in my shared workflow definition, I had to format the if
statement like:
if: ${{ ! startsWith(github.event.head_commit.message, '[skip-version]') }}
Just in case anyone else stumbles along here!
When I don't use a conventional commit message like 'feat:' or 'fix: ...' I still get a bump in version. It seems to default to a patch number.
Another example using conventional commit message which works as intended :
How would one go about skipping bump version all together ? Here is what I have in my workflow: