Bump package version
ActionsTags
(2)A github action bumping the version of a package and pushing the version bump to the repo.
This github action bumps package.json version after a commit is pushed or a pull request is merged to the repo master branch. The updated package.json file is then pushed to master and a tag is created.
Warning: This action requires the checkout action to work.
Commits messages starting with these keywords will trigger a major bump. Commas may be used to specify more than one keyword
Default value: [Major]:
Commits messages starting with these keywords will trigger a minor bump. Commas may be used to specify more than one keyword
Default value: [Minor]:
Commits messages starting with these keywords will trigger a patch bump. Commas may be used to specify more than one keyword
Default value: [Patch]:
If no keywords are present in branch commits, bump anyway by doing a patch.
Default value: false
true
if version has been bumped in package.json.
If the action runs on a commit whose message starts with either [Major]:
, [Minor]:
or [Patch]:
, the version will be bumped and a tag will be created.
name: package bump
on: [push]
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
[...]
- name: Bumping version
uses: jpb06/bump-package@latest
The action will bump the package depending on commits present in the pull request when it is merged to the master branch. By priority order:
- if any commit message contains
BREAKING CHANGE
, then there will be a major bump. - if any commit message contains
feat
orminor
but none of the above, then there will be a minor bump. - if any commit message contains
fix
orchore
but none of the above, then there will be a patch bump.
A tag will also be created by the action.
name: package bump
on: [push]
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
[...]
- name: Bumping version
uses: jpb06/bump-package@latest
with:
major-keywords: BREAKING CHANGE
minor-keywords: feat,minor
patch-keywords: fix,chore
You may want to bump the package version even if no keywords were present in the commits list (if merging a PR) or in the last commit (if pushing to master branch).
By setting should-default-to-patch
to true
you can trigger this behavior. Here is an example:
name: package bump
on: [push]
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
[...]
- name: Bumping version
uses: jpb06/bump-package@latest
with:
major-keywords: BREAKING CHANGE
minor-keywords: feat,minor
patch-keywords: fix,chore
should-default-to-patch: true
Now let's imagine I'm running this action when merging a PR with the following commits:
- cool
- obnoxios commit message
- hey
Since no keywords were detected, the action will bump the package version with a patch: 1.0.0
-> 1.0.1
.
We may want to perform an action if package.json has been bumped. We can use bump-performed
output for this:
name: package bump
on: [push]
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
[...]
- name: Bumping version
id: bumping-version
uses: jpb06/bump-package@latest
- name: Publishing package
if: steps.bumping-version.outputs.bump-performed == 'true'
run: |
cd dist
yarn publish --non-interactive
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Bump package version is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.