From bca7e4ef470066ebccc090d5705008ab5c498ade Mon Sep 17 00:00:00 2001 From: Frederico Gauz Date: Wed, 3 Mar 2021 06:17:06 -0800 Subject: [PATCH 1/2] add catch net for missing/invalid SEMVER_LEVEL --- .github/actions/bumpVersion/bumpVersion.js | 14 +++++++++++--- .github/workflows/version.yml | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/actions/bumpVersion/bumpVersion.js b/.github/actions/bumpVersion/bumpVersion.js index 11b56eb24f73..ad4d34e75a73 100644 --- a/.github/actions/bumpVersion/bumpVersion.js +++ b/.github/actions/bumpVersion/bumpVersion.js @@ -48,10 +48,18 @@ do { // tags come from latest to oldest const highestVersion = tags[0]; - console.log(highestVersion); + console.log(`Highest version found: ${highestVersion}.`); - // should SEMVER_LEVEL default to BUILD? - const semanticVersionLevel = core.getInput('SEMVER_LEVEL', {require: true}); + let semanticVersionLevel = core.getInput('SEMVER_LEVEL', {require: true}); + + // SEMVER_LEVEL defaults to BUILD + // it actually would fall to build anyway, but I think it is better to make it explicity + if (!semanticVersionLevel || !Object.values(functions.semanticVersionLevels) + .find(v => v === semanticVersionLevel)) { + // eslint-disable-next-line max-len, semi + console.log(`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel},defaulting to: ${functions.semanticVersionLevels.build}`) + semanticVersionLevel = functions.semanticVersionLevels.build; + } const newVersion = functions.incrementVersion(highestVersion, semanticVersionLevel); core.setOutput('VERSION', newVersion); diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml index ee77b3e51003..5f8ddd5d7275 100644 --- a/.github/workflows/version.yml +++ b/.github/workflows/version.yml @@ -37,7 +37,7 @@ jobs: uses: ./.github/actions/bumpVersion with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - SEMVER_LEVEL: Patch + SEMVER_LEVEL: PATCH - name: Print new version run: echo "New version is ${{steps.generate-new-version.outputs.VERSION}}" From fad45ab5908eb4b32cc11f173cdb09d26ca82f92 Mon Sep 17 00:00:00 2001 From: Frederico Gauz Date: Wed, 3 Mar 2021 06:19:10 -0800 Subject: [PATCH 2/2] forgot to run ncc --- .github/actions/bumpVersion/index.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/actions/bumpVersion/index.js b/.github/actions/bumpVersion/index.js index 687d27fb2ee5..cc208ce0c23c 100644 --- a/.github/actions/bumpVersion/index.js +++ b/.github/actions/bumpVersion/index.js @@ -55,10 +55,18 @@ do { // tags come from latest to oldest const highestVersion = tags[0]; - console.log(highestVersion); + console.log(`Highest version found: ${highestVersion}.`); - // should SEMVER_LEVEL default to BUILD? - const semanticVersionLevel = core.getInput('SEMVER_LEVEL', {require: true}); + let semanticVersionLevel = core.getInput('SEMVER_LEVEL', {require: true}); + + // SEMVER_LEVEL defaults to BUILD + // it actually would fall to build anyway, but I think it is better to make it explicity + if (!semanticVersionLevel || !Object.values(functions.semanticVersionLevels) + .find(v => v === semanticVersionLevel)) { + // eslint-disable-next-line max-len, semi + console.log(`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel},defaulting to: ${functions.semanticVersionLevels.build}`) + semanticVersionLevel = functions.semanticVersionLevels.build; + } const newVersion = functions.incrementVersion(highestVersion, semanticVersionLevel); core.setOutput('VERSION', newVersion);