From 5d776519d39c7ce3ced421d03bdbe72bf8461073 Mon Sep 17 00:00:00 2001 From: Daniel Kao Date: Wed, 25 Nov 2020 12:15:10 +0800 Subject: [PATCH 1/2] Allow the version upgrade to be executed on a separate branch --- action.yml | 4 ++++ index.js | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 09b163b..eaede21 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,10 @@ inputs: description: 'Custom dir to the package' default: '' required: false + branch: + description: 'A separate branch to perform the version bump on' + default: '' + required: false default: description: 'Set a default version bump to use' default: 'patch' diff --git a/index.js b/index.js index a2affab..1848dbe 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,7 @@ Toolkit.run(async tools => { const majorWords = process.env['INPUT_MAJOR-WORDING'].split(',') const minorWords = process.env['INPUT_MINOR-WORDING'].split(',') const preReleaseWords = process.env['INPUT_RC-WORDING'].split(',') - + // if patch words aren't specified, any commit message qualifies as a patch const patchWords = process.env['INPUT_PATCH-WORDING'] ? process.env['INPUT_PATCH-WORDING'].split(',') : null @@ -78,6 +78,9 @@ Toolkit.run(async tools => { currentBranch = process.env.GITHUB_HEAD_REF isPullRequest = true } + if (process.env['INPUT_TAG-BRANCH']) { + currentBranch = process.env['INPUT_TAG-BRANCH'] + } console.log('currentBranch:', currentBranch) // do it in the current checked out github branch (DETACHED HEAD) // important for further usage of the package.json version From 1f7f2d1296f6b615b3280f10e2d23871033b65b2 Mon Sep 17 00:00:00 2001 From: Daniel Kao Date: Wed, 25 Nov 2020 22:47:18 +0800 Subject: [PATCH 2/2] Update setting name and README --- README.md | 10 ++++++++++ action.yml | 2 +- index.js | 5 +++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6a8fe74..1a9f7d7 100644 --- a/README.md +++ b/README.md @@ -76,3 +76,13 @@ Make sure you use the `actions/checkout@v2` action! GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PACKAGEJSON_DIR: 'frontend' ``` + +**TARGET-BRANCH:** Set a custom target branch to use when bumping the version. Useful in cases such as updating the version on master after a tag has been set (optional). Example: +```yaml +- name: 'Automated Version Bump' + uses: 'phips28/gh-action-bump-version@master' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + target-branch: 'master' +``` diff --git a/action.yml b/action.yml index eaede21..06a65e3 100644 --- a/action.yml +++ b/action.yml @@ -31,7 +31,7 @@ inputs: description: 'Custom dir to the package' default: '' required: false - branch: + target-branch: description: 'A separate branch to perform the version bump on' default: '' required: false diff --git a/index.js b/index.js index 1848dbe..9d799f4 100644 --- a/index.js +++ b/index.js @@ -78,8 +78,9 @@ Toolkit.run(async tools => { currentBranch = process.env.GITHUB_HEAD_REF isPullRequest = true } - if (process.env['INPUT_TAG-BRANCH']) { - currentBranch = process.env['INPUT_TAG-BRANCH'] + if (process.env['INPUT_TARGET-BRANCH']) { + // We want to override the branch that we are pulling / pushing to + currentBranch = process.env['INPUT_TARGET-BRANCH'] } console.log('currentBranch:', currentBranch) // do it in the current checked out github branch (DETACHED HEAD)