From c9f74f6081c4204d1f1637a6fd2447534762b698 Mon Sep 17 00:00:00 2001 From: Kevin Mahoney <716806+kevcube@users.noreply.github.com> Date: Tue, 13 Jul 2021 15:38:26 -0600 Subject: [PATCH 1/2] make pushing optional --- action.yml | 4 ++++ index.js | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/action.yml b/action.yml index 7d874a3..59c8979 100644 --- a/action.yml +++ b/action.yml @@ -50,6 +50,10 @@ inputs: description: 'Set a custom commit message for version bump commit' default: '' required: false + push: + description: 'Set to false to skip pushing the new tag' + default: 'true' + required: false outputs: newTag: description: 'The newly created tag' diff --git a/index.js b/index.js index 5ad32ff..5427b4e 100644 --- a/index.js +++ b/index.js @@ -105,6 +105,11 @@ Toolkit.run(async (tools) => { return; } + // case: if user sets push == false + if ( process.env['INPUT_PUSH'] === "false" ) { + return; + } + // GIT logic try { const current = pkg.version.toString(); From 14d1980003d46f7f8138c5cc96ddf12b4f792f99 Mon Sep 17 00:00:00 2001 From: Kevin Mahoney <716806+kevcube@users.noreply.github.com> Date: Tue, 13 Jul 2021 15:43:33 -0600 Subject: [PATCH 2/2] document --- README.md | 16 +++++++++++++--- index.js | 6 ++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bdab86d..deccaf0 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ GitHub Action for automated npm version bump. -This Action bumps the version in package.json and pushes it back to the repo. -It is meant to be used on every successful merge to master but +This Action bumps the version in package.json and pushes it back to the repo. +It is meant to be used on every successful merge to master but you'll need to configured that workflow yourself. You can look to the [`.github/workflows/push.yml`](./.github/workflows/push.yml) file in this project as an example. @@ -14,7 +14,7 @@ Make sure you use the `actions/checkout@v2` action! ### Workflow * Based on the commit messages, increment the version from the latest release. - * If the string "BREAKING CHANGE", "major" or the Attention pattern `refactor!: drop support for Node 6` is found anywhere in any of the commit messages or descriptions the major + * If the string "BREAKING CHANGE", "major" or the Attention pattern `refactor!: drop support for Node 6` is found anywhere in any of the commit messages or descriptions the major version will be incremented. * If a commit message begins with the string "feat" or includes "minor" then the minor version will be increased. This works for most common commit metadata for feature additions: `"feat: new API"` and `"feature: new API"`. @@ -107,3 +107,13 @@ Make sure you use the `actions/checkout@v2` action! with: commit-message: 'CI: bumps version to {{version}} [skip ci]' ``` + +**push:** Set false you want to avoid pushing the new version tag/package.json. Example: +```yaml +- name: 'Automated Version Bump' + uses: 'phips28/gh-action-bump-version@master' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + push: false +``` diff --git a/index.js b/index.js index 5427b4e..02db002 100644 --- a/index.js +++ b/index.js @@ -105,8 +105,10 @@ Toolkit.run(async (tools) => { return; } - // case: if user sets push == false - if ( process.env['INPUT_PUSH'] === "false" ) { + // case: if user sets push to false, to skip pushing new tag/package.json + const push = process.env['INPUT_PUSH'] + if ( push === "false" || push === false ) { + tools.exit.success('User requested to skip pushing new tag and package.json. Finished.'); return; }