Add Major/Minor/Patch versions

This commit is contained in:
koeneijkemans 2020-07-05 09:50:20 +02:00
parent bf791bd8c8
commit ff65870724
2 changed files with 24 additions and 4 deletions

View File

@ -13,4 +13,4 @@ jobs:
id: getversion
uses: diligencia/semantic-git-version-action@master
- name: Echo name
run: echo "The version of the branch is ${{ steps.getversion.outputs.version }}!"
run: echo "The version of the branch is ${{ steps.getversion.outputs.version }}. Major -> ${{ steps.getversion.outputs.major}} Minor -> ${{ steps.getversion.outputs.minor}} Patch -> ${{ steps.getversion.outputs.patch}}"

View File

@ -9,8 +9,10 @@ try {
const versionNumber = extractVersion(name);
if (versionNumber) {
core.setOutput('version', versionNumber);
console.log(versionNumber);
core.setOutput('VERSION', versionNumber.version);
core.setOutput('MAJOR_VERSION', versionNumber.major);
core.setOutput('MINOR_VERSION', versionNumber.minor);
core.setOutput('PATCH_VERSION', versionNumber.patch);
}
});
} catch (error) {
@ -36,5 +38,23 @@ function extractVersion(branch) {
const regexp = /([0-9]\.[0-9]\.[0-9])|([0-9]\.[0-9])|([0-9])/g;
const matches = branch.match(regexp);
return matches ? matches.shift() : null;
const versions = null;
if (matches) {
const version = matches.shift();
var versionParts = version.split('.');
var major = versionParts[0];
var minor = versionParts.length >= 2 ? versionParts[1] : null;
var patch = versionParts.length >= 3 ? versionParts[2] : null;
versions = {
version: version,
major: major,
minor: minor,
patch: patch
}
}
return versions
}