From 156dc3eb63ba7c64430e87677736c7e483e49be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bure=C5=A1?= Date: Wed, 20 Nov 2019 13:37:42 +0100 Subject: [PATCH 1/8] Add tag prefix --- .github/workflows/push.yml | 2 ++ action.yml | 5 +++++ index.js | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 49d7734..7c004d5 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -23,6 +23,8 @@ jobs: node-version: 8.10.0 - name: "Automated Version Bump" uses: "phips28/gh-action-bump-version@master" + wiht: + tag-prefix: '' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "cat package.json" diff --git a/action.yml b/action.yml index e84718c..9716c4b 100644 --- a/action.yml +++ b/action.yml @@ -6,3 +6,8 @@ runs: branding: icon: chevron-up color: blue +inputs: + tag-prefix: + description: 'Prefix that is used for the git tag' + default: '' + required: false diff --git a/index.js b/index.js index 4714e3f..88fe514 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +const core = require('@actions/core') const { Toolkit } = require('actions-toolkit') const { execSync } = require('child_process') @@ -22,6 +23,8 @@ Toolkit.run(async tools => { version = 'minor' } + const tagPrefix = core.getInput('tag-prefix') + try { const current = pkg.version.toString() // set git user @@ -45,6 +48,7 @@ Toolkit.run(async tools => { ['version', '--allow-same-version=true', '--git-tag-version=false', current]) console.log('current:', current, '/', 'version:', version) newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString().trim() + newVersion = `${tagPrefix}${newVersion}` console.log('new version:', newVersion) await tools.runInWorkspace('git', ['commit', '-a', '-m', `"ci: ${commitMessage} ${newVersion}"`]) From 0bda515c1446e7ad81fb027421786b6614f283f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bure=C5=A1?= Date: Wed, 20 Nov 2019 13:43:29 +0100 Subject: [PATCH 2/8] Fix --- Dockerfile | 2 +- package-lock.json | 41 ++++++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8c1b36e..01871d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ COPY package*.json ./ RUN apt-get update RUN apt-get -y install git -RUN npm ci +RUN npm ci --only=production # Copy the rest of your action's code diff --git a/package-lock.json b/package-lock.json index f547855..decbd04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2348,7 +2348,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -2369,12 +2370,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2389,17 +2392,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2516,7 +2522,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2528,6 +2535,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2542,6 +2550,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2549,12 +2558,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2573,6 +2584,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2653,7 +2665,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2665,6 +2678,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2750,7 +2764,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2786,6 +2801,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2805,6 +2821,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2848,12 +2865,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, From 202e9b2f2b1c36de01c8aecc4cb622824492e04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bure=C5=A1?= Date: Wed, 20 Nov 2019 13:50:15 +0100 Subject: [PATCH 3/8] test --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 88fe514..8cefa05 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,8 @@ Toolkit.run(async tools => { const pkg = tools.getPackageJSON() const event = tools.context.payload + console.log('info', tools.context) + const messages = event.commits.map(commit => commit.message + '\n' + commit.body) const commitMessage = 'version bump to' From 08b29a2aab328c850be5d1783b83f53ae3d848c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bure=C5=A1?= Date: Wed, 20 Nov 2019 13:53:57 +0100 Subject: [PATCH 4/8] remove core --- index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/index.js b/index.js index 8cefa05..795b3c4 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ -const core = require('@actions/core') const { Toolkit } = require('actions-toolkit') const { execSync } = require('child_process') @@ -25,8 +24,6 @@ Toolkit.run(async tools => { version = 'minor' } - const tagPrefix = core.getInput('tag-prefix') - try { const current = pkg.version.toString() // set git user From 02fc217becaa04cbf9545aa0b478f4444f22a00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bure=C5=A1?= Date: Wed, 20 Nov 2019 13:59:16 +0100 Subject: [PATCH 5/8] add arguments --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 795b3c4..8f0bbbf 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ Toolkit.run(async tools => { const pkg = tools.getPackageJSON() const event = tools.context.payload - console.log('info', tools.context) + console.log('info', tools.arguments) const messages = event.commits.map(commit => commit.message + '\n' + commit.body) From 42e514b7559f25aba5e154e2e0463928d483c681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bure=C5=A1?= Date: Wed, 20 Nov 2019 14:07:49 +0100 Subject: [PATCH 6/8] Add actions/core --- index.js | 5 +++-- package-lock.json | 5 +++++ package.json | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 8f0bbbf..88fe514 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +const core = require('@actions/core') const { Toolkit } = require('actions-toolkit') const { execSync } = require('child_process') @@ -6,8 +7,6 @@ Toolkit.run(async tools => { const pkg = tools.getPackageJSON() const event = tools.context.payload - console.log('info', tools.arguments) - const messages = event.commits.map(commit => commit.message + '\n' + commit.body) const commitMessage = 'version bump to' @@ -24,6 +23,8 @@ Toolkit.run(async tools => { version = 'minor' } + const tagPrefix = core.getInput('tag-prefix') + try { const current = pkg.version.toString() // set git user diff --git a/package-lock.json b/package-lock.json index decbd04..896eaeb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,11 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@actions/core": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz", + "integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw==" + }, "@babel/code-frame": { "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", diff --git a/package.json b/package.json index f614022..432305f 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "test": "jest" }, "dependencies": { + "@actions/core": "^1.2.0", "actions-toolkit": "^2.2.0", "yargs": "^14.2.0" }, From 5b4be2a84cd3ebab365e449e8890cff78330ff86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bure=C5=A1?= Date: Wed, 20 Nov 2019 15:55:55 +0100 Subject: [PATCH 7/8] Fix typo --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 7c004d5..45093a6 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -23,7 +23,7 @@ jobs: node-version: 8.10.0 - name: "Automated Version Bump" uses: "phips28/gh-action-bump-version@master" - wiht: + with: tag-prefix: '' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 19ce3c893e8282b71d494f812ddddfe6635fc528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Bure=C5=A1?= Date: Wed, 20 Nov 2019 16:00:55 +0100 Subject: [PATCH 8/8] Remove actions/core --- index.js | 5 +---- package-lock.json | 48 ++++++++++++----------------------------------- package.json | 1 - 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/index.js b/index.js index 88fe514..2fb914f 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ -const core = require('@actions/core') const { Toolkit } = require('actions-toolkit') const { execSync } = require('child_process') @@ -23,8 +22,6 @@ Toolkit.run(async tools => { version = 'minor' } - const tagPrefix = core.getInput('tag-prefix') - try { const current = pkg.version.toString() // set git user @@ -48,7 +45,7 @@ Toolkit.run(async tools => { ['version', '--allow-same-version=true', '--git-tag-version=false', current]) console.log('current:', current, '/', 'version:', version) newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString().trim() - newVersion = `${tagPrefix}${newVersion}` + newVersion = `${process.env['INPUT_TAG-PREFIX']}${newVersion}` console.log('new version:', newVersion) await tools.runInWorkspace('git', ['commit', '-a', '-m', `"ci: ${commitMessage} ${newVersion}"`]) diff --git a/package-lock.json b/package-lock.json index 896eaeb..3af2c3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,11 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@actions/core": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz", - "integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw==" - }, "@babel/code-frame": { "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", @@ -2353,8 +2348,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -2375,14 +2369,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2397,20 +2389,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -2527,8 +2516,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -2540,7 +2528,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2555,7 +2542,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2563,14 +2549,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2589,7 +2573,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2670,8 +2653,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2683,7 +2665,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2769,8 +2750,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -2806,7 +2786,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2826,7 +2805,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2870,14 +2848,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -6164,4 +6140,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 432305f..f614022 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "test": "jest" }, "dependencies": { - "@actions/core": "^1.2.0", "actions-toolkit": "^2.2.0", "yargs": "^14.2.0" },