From 2f891e64f64b1f4ec376fa93b73c7407136b7ac0 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 13 Feb 2018 16:53:32 +0100 Subject: [PATCH] build: enforce consistent version names (#9917) Ensures that versions are following a consistent format before publishing. e.g. versions like `6.0.0-beta-0` is not valid, because the last dash should be actually a dot. Closes #9910. --- tools/gulp/tasks/publish.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/gulp/tasks/publish.ts b/tools/gulp/tasks/publish.ts index e0f7f5fe2e3..6c65a3eb666 100644 --- a/tools/gulp/tasks/publish.ts +++ b/tools/gulp/tasks/publish.ts @@ -16,6 +16,9 @@ export const releasePackages = [ 'material-moment-adapter' ]; +/** Regular Expression that matches valid version numbers of Angular Material. */ +export const validVersionRegex = /^\d+\.\d+\.\d+(-(alpha|beta|rc)\.\d+)?$/; + /** Parse command-line arguments for release task. */ const argv = minimist(process.argv.slice(3)); @@ -46,6 +49,14 @@ task(':publish', async () => { const version = buildConfig.projectVersion; const currentDir = process.cwd(); + if (!version.match(validVersionRegex)) { + console.log(red(`Error: Cannot publish due to an invalid version name. Version "${version}" ` + + `is not following our semver format.`)); + console.log(yellow(`A version should follow this format: d.d.d, d.d.d-beta.x, d.d.d-alpha.x, ` + + `d.d.d-rc.x`)); + return; + } + console.log(''); if (!tag) { console.log(grey('> You can specify the tag by passing --tag=labelName.\n'));