From c67560828c47e24918fababb0bc8042afdf001e2 Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Thu, 22 Dec 2022 23:08:53 -0500 Subject: [PATCH] feat: add noVersionBumpBehavior option --- .github/workflows/deploy.yml | 19 +++++--------- CHANGELOG.md | 12 --------- README.md | 12 +++++---- action.yml | 12 +++++++-- dist/index.js | 13 +++++++++- index.js | 13 +++++++++- package.json | 4 +-- yarn.lock | 48 ++++++++++++++++++------------------ 8 files changed, 73 insertions(+), 60 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2d622b2..0f86e3c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,9 +19,9 @@ jobs: with: token: ${{ github.token }} branch: main - + - name: Create Draft Release - uses: ncipollo/release-action@v1 + uses: ncipollo/release-action@v1.12.0 if: ${{ !env.ACT }} with: prerelease: true @@ -39,10 +39,11 @@ jobs: with: token: ${{ github.token }} tag: ${{ steps.semver.outputs.next }} + writeToFile: false - name: Create Release if: ${{ !env.ACT }} - uses: ncipollo/release-action@v1 + uses: ncipollo/release-action@v1.12.0 with: allowUpdates: true draft: false @@ -50,10 +51,10 @@ jobs: name: ${{ steps.semver.outputs.next }} body: ${{ steps.changelog.outputs.changes }} token: ${{ github.token }} - + - name: Create Release (Major-only) if: ${{ !env.ACT }} - uses: ncipollo/release-action@v1 + uses: ncipollo/release-action@v1.12.0 with: allowUpdates: true draft: false @@ -63,14 +64,6 @@ jobs: body: ${{ steps.changelog.outputs.changes }} token: ${{ github.token }} - - name: Commit CHANGELOG.md - if: ${{ !env.ACT }} - uses: stefanzweifel/git-auto-commit-action@v4 - with: - branch: main - commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]' - file_pattern: CHANGELOG.md - # LOCAL TEST - name: (local) Checkout Code diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 69835c7..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [v1.2.0] - 2022-11-16 -### :sparkles: New Features -- [`4eb6fb4`](https://github.com/ietf-tools/semver-action/commit/4eb6fb4219d39deffaf10fad60dcc2cc97acf49e) - add skipInvalidTags option *(commit by [@NGPixel](https://github.com/NGPixel))* - - -[v1.2.0]: https://github.com/ietf-tools/semver-action/compare/v1.1.2...v1.2.0 \ No newline at end of file diff --git a/README.md b/README.md index 8cbdcfe..861328d 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,14 @@ This GitHub Action automatically determinate the next release version to use bas - [Inputs](#inputs) - [Outputs](#outputs) +> Works great alongside the [Changelog from Conventional Commits](https://github.com/marketplace/actions/changelog-from-conventional-commits) action! + ## Example workflow ``` yaml name: Deploy on: - push: - tags: - - v[0-9]+.[0-9]+.[0-9]+ + workflow_dispatch: jobs: deploy: @@ -42,10 +42,11 @@ jobs: branch: main - name: Create Release - uses: ncipollo/release-action@v1 + uses: ncipollo/release-action@v1.12.0 with: allowUpdates: true draft: false + makeLatest: true name: ${{ steps.semver.outputs.next }} body: Changelog Contents token: ${{ github.token }} @@ -61,7 +62,8 @@ jobs: | `minorList` | Comma separated commit prefixes, used to bump Minor version. | :x: | `feat, feature` | | `patchList` | Comma separated commit prefixes, used to bump Patch version. | :x: | `fix, bugfix, perf, refactor, test, tests` | | `patchAll` | If set to `true`, will ignore `patchList` and always count commits as a Patch. | :x: | `false` | -| `skipInvalidTags` | If set to true, will skip tags that are not valid semver until it finds a proper one (up to 10 from latest). | :x: | `false` | +| `skipInvalidTags` | If set to `true`, will skip tags that are not valid semver until it finds a proper one (up to 10 from latest). | :x: | `false` | +| `noVersionBumpBehavior` | Whether to exit with an error *(default)*, a warning or silently when none of the commits result in a version bump. (Possible values: `error`, `warn` or `silent`) | :x: | `error` | ## Outputs diff --git a/action.yml b/action.yml index 0de71c9..5f6723f 100644 --- a/action.yml +++ b/action.yml @@ -29,13 +29,21 @@ inputs: description: If set to true, will skip tags that are not valid semver until it finds a proper one (up to 10 from latest). required: false default: 'false' + noVersionBumpBehavior: + description: Whether to exit with an error, warning or silently when none of the commits result in a version bump. (error, warn, silent) + required: false + default: error outputs: current: - description: Current version number + description: Current version number / latest tag. next: description: Next version number in format v0.0.0 nextStrict: - description: Next version number without the v prefix + description: Next version number without the v prefix. + nextMajor: + description: Next version major number in format v0 + nextMajorStrict: + description: Next version major number only. runs: using: 'node16' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 92fee73..c5e7260 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31050,6 +31050,7 @@ async function main () { const owner = github.context.repo.owner const repo = github.context.repo.repo const skipInvalidTags = core.getBooleanInput('skipInvalidTags') + const noVersionBumpBehavior = core.getInput('noVersionBumpBehavior') const bumpTypes = { major: core.getInput('majorList').split(',').map(p => p.trim()).filter(p => p), @@ -31168,7 +31169,17 @@ async function main () { } else if (patchChanges.length > 0) { bump = 'patch' } else { - return core.setFailed('No commit resulted in a version bump since last release!') + switch (noVersionBumpBehavior) { + case 'warn': { + return core.warning('No commit resulted in a version bump since last release!') + } + case 'silent': { + return core.info('No commit resulted in a version bump since last release! Exiting silently...') + } + default: { + return core.setFailed('No commit resulted in a version bump since last release!') + } + } } core.info(`\n>>> Will bump version ${latestTag.name} using ${bump.toUpperCase()}\n`) diff --git a/index.js b/index.js index 2f22e20..520de1f 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,7 @@ async function main () { const owner = github.context.repo.owner const repo = github.context.repo.repo const skipInvalidTags = core.getBooleanInput('skipInvalidTags') + const noVersionBumpBehavior = core.getInput('noVersionBumpBehavior') const bumpTypes = { major: core.getInput('majorList').split(',').map(p => p.trim()).filter(p => p), @@ -129,7 +130,17 @@ async function main () { } else if (patchChanges.length > 0) { bump = 'patch' } else { - return core.setFailed('No commit resulted in a version bump since last release!') + switch (noVersionBumpBehavior) { + case 'warn': { + return core.warning('No commit resulted in a version bump since last release!') + } + case 'silent': { + return core.info('No commit resulted in a version bump since last release! Exiting silently...') + } + default: { + return core.setFailed('No commit resulted in a version bump since last release!') + } + } } core.info(`\n>>> Will bump version ${latestTag.name} using ${bump.toUpperCase()}\n`) diff --git a/package.json b/package.json index 7784bb0..04440d5 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,8 @@ "semver": "7.3.8" }, "devDependencies": { - "@vercel/ncc": "0.34.0", - "eslint": "8.27.0", + "@vercel/ncc": "0.36.0", + "eslint": "8.30.0", "eslint-config-standard": "17.0.0", "eslint-plugin-import": "2.26.0", "eslint-plugin-node": "11.1.0", diff --git a/yarn.lock b/yarn.lock index 04ae376..385f839 100644 --- a/yarn.lock +++ b/yarn.lock @@ -56,25 +56,25 @@ unist-util-visit "^2.0.3" unist-util-visit-parents "^3.1.1" -"@eslint/eslintrc@^1.3.3": - version "1.3.3" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.3.3.tgz#2b044ab39fdfa75b4688184f9e573ce3c5b0ff95" - integrity sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg== +"@eslint/eslintrc@^1.4.0": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.0.tgz#8ec64e0df3e7a1971ee1ff5158da87389f167a63" + integrity sha512-7yfvXy6MWLgWSFsLhz5yH3iQ52St8cdUY6FoGieKkRDVxuxmrNuUetIuu6cmjNWwniUHiWXjxCr5tTXDrbYS5A== dependencies: ajv "^6.12.4" debug "^4.3.2" espree "^9.4.0" - globals "^13.15.0" + globals "^13.19.0" ignore "^5.2.0" import-fresh "^3.2.1" js-yaml "^4.1.0" minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@humanwhocodes/config-array@^0.11.6": - version "0.11.7" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.7.tgz#38aec044c6c828f6ed51d5d7ae3d9b9faf6dbb0f" - integrity sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw== +"@humanwhocodes/config-array@^0.11.8": + version "0.11.8" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.8.tgz#03595ac2075a4dc0f191cc2131de14fbd7d410b9" + integrity sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g== dependencies: "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" @@ -229,10 +229,10 @@ resolved "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz" integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ== -"@vercel/ncc@0.34.0": - version "0.34.0" - resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.34.0.tgz#d0139528320e46670d949c82967044a8f66db054" - integrity sha512-G9h5ZLBJ/V57Ou9vz5hI8pda/YQX5HQszCs3AmIus3XzsmRn/0Ptic5otD3xVST8QLKk7AMk7AqpsyQGN7MZ9A== +"@vercel/ncc@0.36.0": + version "0.36.0" + resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.36.0.tgz#1f262b86fc4f0770bbc0fc1d331d5aaa1bd47334" + integrity sha512-/ZTUJ/ZkRt694k7KJNimgmHjtQcRuVwsST2Z6XfYveQIuBbHR+EqkTc1jfgPkQmMyk/vtpxo3nVxe8CNuau86A== JSONStream@^1.0.4: version "1.3.5" @@ -688,13 +688,13 @@ eslint-visitor-keys@^3.3.0: resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@8.27.0: - version "8.27.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.27.0.tgz#d547e2f7239994ad1faa4bb5d84e5d809db7cf64" - integrity sha512-0y1bfG2ho7mty+SiILVf9PfuRA49ek4Nc60Wmmu62QlobNR+CeXa4xXIJgcuwSQgZiWaPH+5BDsctpIW0PR/wQ== +eslint@8.30.0: + version "8.30.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.30.0.tgz#83a506125d089eef7c5b5910eeea824273a33f50" + integrity sha512-MGADB39QqYuzEGov+F/qb18r4i7DohCDOfatHaxI2iGlPuC65bwG2gxgO+7DkyL38dRFaRH7RaRAgU6JKL9rMQ== dependencies: - "@eslint/eslintrc" "^1.3.3" - "@humanwhocodes/config-array" "^0.11.6" + "@eslint/eslintrc" "^1.4.0" + "@humanwhocodes/config-array" "^0.11.8" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" ajv "^6.10.0" @@ -713,7 +713,7 @@ eslint@8.27.0: file-entry-cache "^6.0.1" find-up "^5.0.0" glob-parent "^6.0.2" - globals "^13.15.0" + globals "^13.19.0" grapheme-splitter "^1.0.4" ignore "^5.2.0" import-fresh "^3.0.0" @@ -889,10 +889,10 @@ glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -globals@^13.15.0: - version "13.17.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.17.0.tgz#902eb1e680a41da93945adbdcb5a9f361ba69bd4" - integrity sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw== +globals@^13.19.0: + version "13.19.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.19.0.tgz#7a42de8e6ad4f7242fbcca27ea5b23aca367b5c8" + integrity sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ== dependencies: type-fest "^0.20.2"