From 752872daea14761701c6f2b7676f404c1aa9ec32 Mon Sep 17 00:00:00 2001 From: Pierre Gordon Date: Wed, 1 Sep 2021 19:52:54 -0500 Subject: [PATCH] Verify milestone and tag name match --- .github/actions/draft-release/src/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/actions/draft-release/src/index.js b/.github/actions/draft-release/src/index.js index 6cee31d3013..bf5fadc3b97 100644 --- a/.github/actions/draft-release/src/index.js +++ b/.github/actions/draft-release/src/index.js @@ -15,11 +15,16 @@ async function main() { } // Get tag name from plugin main PHP file. - let tagName = ''; const pluginFile = fs.readFileSync(path.resolve(process.cwd(), 'amp.php')).toString(); const matches = /\*\s+Version:\s+(\d+(\.\d+)+-\w+)/.exec(pluginFile); - if (matches && matches[1]) { - [, tagName] = matches; + const tagName = matches?.[1]; + + if (! tagName) { + throw new Error( 'Unable to parse Version from plugin bootstrap PHP file.' ); + } + + if (! tagName.startsWith(milestone)) { + throw new Error( "Milestone mismatch with PHP plugin bootstrap version." ); } // Get target branch.