add logic to extract version number

This commit is contained in:
koeneijkemans 2020-07-05 09:18:35 +02:00
parent e224891859
commit c02262795c

View File

@ -4,8 +4,13 @@ const execlib = require('@actions/exec');
try { try {
getBranchName() getBranchName()
.then(name => { .then(name => {
console.log(name);
core.setOutput("branchname", name) core.setOutput("branchname", name)
const versionNumber = extractVersion(name);
if (versionNumber) {
core.setOutput('version', versionNumber);
}
}); });
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
@ -23,9 +28,10 @@ async function getBranchName() {
await execlib.exec('git', ['branch'], options); await execlib.exec('git', ['branch'], options);
if (output) {
console.log('Got some sweet output...' + output);
}
return output; return output;
} }
function extractVersion(branch) {
const regexp = /^([0-9]\.[0-9]\.[0-9])|([0-9]\.[0-9])|([0-9])$/;
return branch.match(regexp);
}