Skip to content

Commit

Permalink
Merge pull request #6 from GauzStudio/fred-update-semantic-versioning
Browse files Browse the repository at this point in the history
add catch net for missing/invalid SEMVER_LEVEL
  • Loading branch information
FredericoGauz authored Mar 3, 2021
2 parents 39c7ff9 + fad45ab commit 642b6f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
14 changes: 11 additions & 3 deletions .github/actions/bumpVersion/bumpVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions .github/actions/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down

0 comments on commit 642b6f1

Please sign in to comment.