From 0bba404bec997c821cbc2519e986e42242f52f02 Mon Sep 17 00:00:00 2001 From: falko189 Date: Mon, 16 Nov 2020 16:24:15 +0000 Subject: [PATCH 1/3] Added output of the tag to the action --- .github/workflows/push.yml | 5 +++++ action.yml | 3 +++ index.js | 21 +++++++++++---------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 01d096c..ffe2e5e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -22,6 +22,7 @@ jobs: with: node-version: 12 - name: "Automated Version Bump" + id: version-bump uses: "phips28/gh-action-bump-version@master" with: tag-prefix: '' @@ -29,3 +30,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "cat package.json" run: cat ./package.json + - name: 'Output Step' + env: + NEW_TAG: ${{ steps.version-bump.outputs.newTag }} + run: echo "new tag $NEW_TAG" diff --git a/action.yml b/action.yml index 9af8969..09b163b 100644 --- a/action.yml +++ b/action.yml @@ -35,3 +35,6 @@ inputs: description: 'Set a default version bump to use' default: 'patch' required: false +outputs: + newTag: + description: 'The newly created tag' diff --git a/index.js b/index.js index 6943420..39c6e29 100644 --- a/index.js +++ b/index.js @@ -33,23 +33,23 @@ Toolkit.run(async tools => { let version = process.env['INPUT_DEFAULT'] || 'patch' let foundWord = null; - + if (messages.some( message => /^([a-zA-Z]+)(\(.+\))?(\!)\:/.test(message) || majorWords.some(word => message.includes(word)))) { version = 'major' } else if (messages.some(message => minorWords.some(word => message.includes(word)))) { version = 'minor' } else if (messages.some(message => preReleaseWords.some(word => { - if (message.includes(word)) { - foundWord = word; - return true; - } else { - return false; - } + if (message.includes(word)) { + foundWord = word; + return true; + } else { + return false; } - ))) { - const preid = foundWord.split("-")[1]; - version = `prerelease --preid=${preid}`; + } + ))) { + const preid = foundWord.split("-")[1]; + version = `prerelease --preid=${preid}`; } else if (patchWords && Array.isArray(patchWords)) { if (!messages.some(message => patchWords.some(word => message.includes(word)))) { version = null @@ -97,6 +97,7 @@ Toolkit.run(async tools => { newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString().trim() newVersion = `${process.env['INPUT_TAG-PREFIX']}${newVersion}` console.log('new version:', newVersion) + console.log(`::set-output name=newTag::${newVersion}`) try { // to support "actions/checkout@v1" await tools.runInWorkspace('git', ['commit', '-a', '-m', `ci: ${commitMessage} ${newVersion}`]) From f89fbceca40c8a0a86c8e0aea0e89d2763371780 Mon Sep 17 00:00:00 2001 From: phips28 Date: Mon, 16 Nov 2020 20:25:09 +0100 Subject: [PATCH 2/3] reformat --- index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 39c6e29..81ea787 100644 --- a/index.js +++ b/index.js @@ -19,7 +19,7 @@ Toolkit.run(async tools => { const messages = event.commits ? event.commits.map(commit => commit.message + '\n' + commit.body) : [] const commitMessage = 'version bump to' - console.log('messages:', messages); + console.log('messages:', messages) const isVersionBump = messages.map(message => message.toLowerCase().includes(commitMessage)).includes(true) if (isVersionBump) { tools.exit.success('No action necessary!') @@ -32,7 +32,7 @@ Toolkit.run(async tools => { const preReleaseWords = process.env['INPUT_RC-WORDING'].split(',') let version = process.env['INPUT_DEFAULT'] || 'patch' - let foundWord = null; + let foundWord = null if (messages.some( message => /^([a-zA-Z]+)(\(.+\))?(\!)\:/.test(message) || majorWords.some(word => message.includes(word)))) { @@ -41,15 +41,15 @@ Toolkit.run(async tools => { version = 'minor' } else if (messages.some(message => preReleaseWords.some(word => { if (message.includes(word)) { - foundWord = word; - return true; + foundWord = word + return true } else { - return false; + return false } } ))) { - const preid = foundWord.split("-")[1]; - version = `prerelease --preid=${preid}`; + const preid = foundWord.split('-')[1] + version = `prerelease --preid=${preid}` } else if (patchWords && Array.isArray(patchWords)) { if (!messages.some(message => patchWords.some(word => message.includes(word)))) { version = null From 4a6678f27944640c795f0e09ff95127423e91249 Mon Sep 17 00:00:00 2001 From: phips28 Date: Mon, 16 Nov 2020 20:26:17 +0100 Subject: [PATCH 3/3] reformat --- index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 81ea787..2ebbdd0 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,7 @@ Toolkit.run(async tools => { const patchWords = process.env['INPUT_PATCH-WORDING'].split(',') const preReleaseWords = process.env['INPUT_RC-WORDING'].split(',') - let version = process.env['INPUT_DEFAULT'] || 'patch' + let version = process.env.INPUT_DEFAULT || 'patch' let foundWord = null if (messages.some( @@ -40,13 +40,13 @@ Toolkit.run(async tools => { } else if (messages.some(message => minorWords.some(word => message.includes(word)))) { version = 'minor' } else if (messages.some(message => preReleaseWords.some(word => { - if (message.includes(word)) { - foundWord = word - return true - } else { - return false - } + if (message.includes(word)) { + foundWord = word + return true + } else { + return false } + } ))) { const preid = foundWord.split('-')[1] version = `prerelease --preid=${preid}`