From a4bdccbef074e150b6314bf91e92de029cdf476c Mon Sep 17 00:00:00 2001 From: Ross Anderson Date: Wed, 8 Dec 2021 19:20:01 -0800 Subject: [PATCH 1/3] Implement skip-push --- README.md | 17 ++++++++++++++--- action.yml | 6 +++++- index.js | 11 ++++++++--- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ae11079..f30e607 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ The tag is not added to the git repository (optional). Example: ``` #### **skip-commit:** -No commit is made after the version is bumped (optional). Example: +No commit is made after the version is bumped (optional). Must be used in combination with `skip-tag`, since if there's no commit, there's nothing to tag. Example: ```yaml - name: 'Automated Version Bump' uses: 'phips28/gh-action-bump-version@master' @@ -104,8 +104,19 @@ No commit is made after the version is bumped (optional). Example: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: skip-commit: 'true' + skip-tag: 'true' ``` +#### **skip-push:** +If true, skip pushing any commits or tags created after the version bump (optional). Example: +```yaml +- name: 'Automated Version Bump' + uses: 'phips28/gh-action-bump-version@master' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + skip-push: 'true' +``` #### **PACKAGEJSON_DIR:** Param to parse the location of the desired package.json (optional). Example: @@ -139,8 +150,8 @@ Set a custom commit message for version bump commit. Useful for skipping additio commit-message: 'CI: bumps version to {{version}} [skip ci]' ``` -#### **push:** -Set false you want to avoid pushing the new version tag/package.json. Example: +#### [DEPRECATED] **push:** +**DEPRECATED** 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' diff --git a/action.yml b/action.yml index 0a65d44..3c7f8f6 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,10 @@ inputs: description: 'Avoid to add a commit after the version is bumped' default: 'false' required: false + skip-push: + description: 'Skip pushing the commit with the version bump' + default: false + required: false PACKAGEJSON_DIR: description: 'Custom dir to the package' default: '' @@ -55,7 +59,7 @@ inputs: default: '' required: false push: - description: 'Set to false to skip pushing the new tag' + description: '[DEPRECATED] Set to false to skip pushing the new tag' default: 'true' required: false outputs: diff --git a/index.js b/index.js index e626e2c..475f41c 100644 --- a/index.js +++ b/index.js @@ -176,10 +176,15 @@ const workspace = process.env.GITHUB_WORKSPACE; const remoteRepo = `https://${process.env.GITHUB_ACTOR}:${process.env.GITHUB_TOKEN}@github.com/${process.env.GITHUB_REPOSITORY}.git`; if (process.env['INPUT_SKIP-TAG'] !== 'true') { await runInWorkspace('git', ['tag', newVersion]); - await runInWorkspace('git', ['push', remoteRepo, '--follow-tags']); - await runInWorkspace('git', ['push', remoteRepo, '--tags']); + if (process.env['INPUT_SKIP-PUSH'] !== 'true') { + await runInWorkspace('git', ['push', remoteRepo, '--follow-tags']); + await runInWorkspace('git', ['push', remoteRepo, '--tags']); + } } else { - await runInWorkspace('git', ['push', remoteRepo]); + // skip-tag: true, so we push without pushing tags. + if (process.env['INPUT_SKIP-PUSH'] !== 'true') { + await runInWorkspace('git', ['push', remoteRepo]); + } } } catch (e) { logError(e); From ce0fadf7769d3c66a8fa5ec665e84359530202dc Mon Sep 17 00:00:00 2001 From: Ross Anderson Date: Wed, 8 Dec 2021 19:24:52 -0800 Subject: [PATCH 2/3] Remove extraneous comment --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index 475f41c..98205a3 100644 --- a/index.js +++ b/index.js @@ -181,7 +181,6 @@ const workspace = process.env.GITHUB_WORKSPACE; await runInWorkspace('git', ['push', remoteRepo, '--tags']); } } else { - // skip-tag: true, so we push without pushing tags. if (process.env['INPUT_SKIP-PUSH'] !== 'true') { await runInWorkspace('git', ['push', remoteRepo]); } From 38b9ac6f5039a995b088bfa4e204167e0d9d0dd2 Mon Sep 17 00:00:00 2001 From: Ross Anderson Date: Wed, 8 Dec 2021 19:29:20 -0800 Subject: [PATCH 3/3] use same wording in action.yml as in README --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 3c7f8f6..cd22c02 100644 --- a/action.yml +++ b/action.yml @@ -35,7 +35,7 @@ inputs: default: 'false' required: false skip-push: - description: 'Skip pushing the commit with the version bump' + description: 'If true, skip pushing any commits or tags created after the version bump' default: false required: false PACKAGEJSON_DIR: