From b8b23f67d51d5523aa9656e42660d05ce07025b8 Mon Sep 17 00:00:00 2001 From: phips28 Date: Thu, 1 Jul 2021 21:53:38 +0200 Subject: [PATCH 1/4] input tag in commit message detection --- .github/workflows/push.yml | 24 ++++++++++++------------ index.js | 9 +++++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index f6f7800..142b48e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,36 +1,36 @@ -name: "Bump Version" +name: 'Bump Version' on: push: branches: - - "master" + - 'master' jobs: bump-version: - name: "Bump Version on master" + name: 'Bump Version on master' runs-on: ubuntu-latest steps: - - name: "Checkout source code" - uses: "actions/checkout@v2" + - name: 'Checkout source code' + uses: 'actions/checkout@v2' with: ref: ${{ github.ref }} - - name: "cat package.json" + - name: 'cat package.json' run: cat ./package.json - - name: "Setup Node.js" - uses: "actions/setup-node@v1" + - name: 'Setup Node.js' + uses: 'actions/setup-node@v1' with: node-version: 12 - - name: "Automated Version Bump" + - name: 'Automated Version Bump' id: version-bump - uses: "phips28/gh-action-bump-version@master" + uses: 'phips28/gh-action-bump-version@test/tagPrefix' with: tag-prefix: 'v' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: "cat package.json" + - name: 'cat package.json' run: cat ./package.json - - name: 'Output Step' + - name: 'Output Step' env: NEW_TAG: ${{ steps.version-bump.outputs.newTag }} run: echo "new tag $NEW_TAG" diff --git a/index.js b/index.js index 263ece8..da9c457 100644 --- a/index.js +++ b/index.js @@ -16,15 +16,16 @@ Toolkit.run(async (tools) => { console.log("Couldn't find any commits in this event, incrementing patch version..."); } + const tagPrefix = process.env['INPUT_TAG-PREFIX'] || ''; const messages = event.commits ? event.commits.map((commit) => commit.message + '\n' + commit.body) : []; const commitMessage = process.env['INPUT_COMMIT-MESSAGE'] || 'ci: version bump to {{version}}'; console.log('messages:', messages); - const commitMessageRegex = new RegExp(commitMessage.replace(/{{version}}/g, 'v\\d+\\.\\d+\\.\\d+'), 'ig'); + const commitMessageRegex = new RegExp(commitMessage.replace(/{{version}}/g, `${tagPrefix}\\d+\\.\\d+\\.\\d+`), 'ig'); const isVersionBump = messages.find((message) => commitMessageRegex.test(message)) !== undefined; if (isVersionBump) { - tools.exit.success('No action necessary!'); + tools.exit.success('No action necessary because we found a previous bump!'); return; } @@ -112,7 +113,7 @@ Toolkit.run(async (tools) => { await tools.runInWorkspace('npm', ['version', '--allow-same-version=true', '--git-tag-version=false', current]); console.log('current:', current, '/', 'version:', version); let newVersion = execSync(`npm version --git-tag-version=false ${version}`).toString().trim().replace(/^v/, ''); - newVersion = `${process.env['INPUT_TAG-PREFIX']}${newVersion}`; + newVersion = `${tagPrefix}${newVersion}`; await tools.runInWorkspace('git', ['commit', '-a', '-m', commitMessage.replace(/{{version}}/g, newVersion)]); // now go to the actual branch to perform the same versioning @@ -124,7 +125,7 @@ Toolkit.run(async (tools) => { await tools.runInWorkspace('npm', ['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().replace(/^v/, ''); - newVersion = `${process.env['INPUT_TAG-PREFIX']}${newVersion}`; + newVersion = `${tagPrefix}${newVersion}`; console.log(`::set-output name=newTag::${newVersion}`); try { // to support "actions/checkout@v1" From d012ab63198347c55c892ebd5fdc6a6f653c808e Mon Sep 17 00:00:00 2001 From: phips28 Date: Thu, 1 Jul 2021 21:54:24 +0200 Subject: [PATCH 2/4] test/tagPrefix --- .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 142b48e..eb2429b 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -3,7 +3,7 @@ name: 'Bump Version' on: push: branches: - - 'master' + - 'test/tagPrefix' jobs: bump-version: From aacaac5e0637589834ae09ddcc14298e758018d7 Mon Sep 17 00:00:00 2001 From: Automated Version Bump Date: Thu, 1 Jul 2021 19:55:17 +0000 Subject: [PATCH 3/4] ci: version bump to v8.2.17 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f46a768..bcf16fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gh-action-bump-version", - "version": "8.2.16", + "version": "8.2.17", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a641d77..1d0796c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gh-action-bump-version", - "version": "8.2.16", + "version": "8.2.17", "repository": { "type": "git", "url": "git+https://github.com/phips28/gh-action-bump-version.git" From 278be27ea76c1c9cbe90f236b40b4c0c709b1d25 Mon Sep 17 00:00:00 2001 From: phips28 Date: Thu, 1 Jul 2021 21:58:06 +0200 Subject: [PATCH 4/4] revert to master --- .github/workflows/push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index eb2429b..2244c1c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -3,7 +3,7 @@ name: 'Bump Version' on: push: branches: - - 'test/tagPrefix' + - 'master' jobs: bump-version: @@ -23,7 +23,7 @@ jobs: node-version: 12 - name: 'Automated Version Bump' id: version-bump - uses: 'phips28/gh-action-bump-version@test/tagPrefix' + uses: 'phips28/gh-action-bump-version@master' with: tag-prefix: 'v' env: