From 81b63a69b3d1d806470244e93c988b313611fcd2 Mon Sep 17 00:00:00 2001 From: Sparkle <1284531+baurine@users.noreply.github.com> Date: Fri, 23 Aug 2024 23:25:21 +0800 Subject: [PATCH] chore: refine `make tag` script (#1721) --- scripts/create_release_tag.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/create_release_tag.js b/scripts/create_release_tag.js index 549662639..52dd9b5b2 100644 --- a/scripts/create_release_tag.js +++ b/scripts/create_release_tag.js @@ -29,6 +29,7 @@ function getGitShortSha() { function getGitLatestTag() { // v7.6.0-alpha, v7.6.0-, v7.6.0, v7.6.1-, v7.6.1 + // v7.6.0-alpha-3-g383cf602, v7.6.0--3-g383cf602, v7.6.0-3-g383cf602, v7.6.1--3-g383cf602, v7.6.1-3-g383cf602 return execSync('git describe --tags --dirty --always').toString().trim(); } @@ -63,6 +64,11 @@ function createReleaseTag() { // then the next tag should be v7.6.1- for v7.6.0, v7.6.2- for v7.6.1 const suffix = latestTag.replace(`v${branchVer}.`, ''); nextTag = `v${branchVer}.${parseInt(suffix) + 1}-${shortSha}`; + } else if (latestTag.match(/^v\d+\.\d+\.\d+-\d+-[0-9a-z]{9}/)) { + // the latest tag likes v7.6.0-3-g383cf602, v7.6.1-3-g383cf602 + // then the next tag should be v7.6.1- for v7.6.0, v7.6.2- for v7.6.1 + const suffix = latestTag.substring(0, splitPos).replace(`v${branchVer}.`, ''); + nextTag = `v${branchVer}.${parseInt(suffix) + 1}-${shortSha}`; } else { // the latest tag likes v7.6.0-, v7.6.1- // then the next tag should be v7.6.0- for v7.6.0-, v7.6.1- for v7.6.1- @@ -76,7 +82,7 @@ function createReleaseTag() { function createMasterTag() { const latestTag = getGitLatestTag(); // the latest tag must like vX.Y.0-alpha, likes `v8.4.0-alpha` - if (!latestTag.match(/^v\d+\.\d+.0-alpha$/)) { + if (!latestTag.match(/^v\d+\.\d+.0-alpha/)) { console.error(`Err: latest tag ${latestTag} is not a valid alpha tag`) process.exit(1) }