diff --git a/action.yml b/action.yml index ea9b078..5ee2c4e 100644 --- a/action.yml +++ b/action.yml @@ -11,5 +11,5 @@ outputs: manifestSafeVersionString: description: 'A version string that is save to use in Dnn manifests' runs: - using: 'node12' + using: 'node16' main: './dist/index.js' \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 05fd583..0146dcb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,17 +1,16 @@ import * as core from '@actions/core'; import * as github from '@actions/github'; -const getVersion = async (version: string): Promise => { - const numbers = version.split('.'); - console.log("numbers:", numbers); +const getVersion = async (version: Array): Promise => { + console.log("version:", version); return { - major: parseInt(numbers[0]), - minor: parseInt(numbers[1]), - patch: parseInt(numbers[2]), + major: parseInt(version[1]), + minor: parseInt(version[2]), + patch: parseInt(version[3]), manifestSafeVersionString: - numbers[0].padStart(2, "0") + "." + - numbers[1].padStart(2, "0") + "." + - numbers[2].padStart(2, "0") + version[0].padStart(2, "0") + "." + + version[1].padStart(2, "0") + "." + + version[2].padStart(2, "0") }; } @@ -30,10 +29,10 @@ async function run() { // Grab the branch version const branchName: string = github.context.payload.ref; - const regex = new RegExp(/^release\/\d{1,2}\.\d{1,2}\.\d{1,2}$/); - if (branchName.match(regex)){ - const versionString = branchName.split('/')[1]; - const version = await getVersion(versionString); + const regex = new RegExp(/^release[-\/](\d{1,2})\.(\d{1,2})\.(\d{1,2})$/); + const releaseInfo = branchName.match(regex) + if (releaseInfo){ + const version = await getVersion(releaseInfo); console.log("version: ", version); core.setOutput("major", version.major); core.setOutput("minor", version.minor);