mirror of
https://github.com/diligencia/semantic-branch-version.git
synced 2024-11-23 16:43:51 +08:00
add logic to extract version number
This commit is contained in:
parent
e224891859
commit
c02262795c
16
index.js
16
index.js
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user