mirror of
https://github.com/diligencia/semantic-branch-version.git
synced 2024-11-23 09:33: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 {
|
||||
getBranchName()
|
||||
.then(name => {
|
||||
console.log(name);
|
||||
core.setOutput("branchname", name)
|
||||
|
||||
const versionNumber = extractVersion(name);
|
||||
|
||||
if (versionNumber) {
|
||||
core.setOutput('version', versionNumber);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
@ -23,9 +28,10 @@ async function getBranchName() {
|
||||
|
||||
await execlib.exec('git', ['branch'], options);
|
||||
|
||||
if (output) {
|
||||
console.log('Got some sweet output...' + 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