Skip to content

Commit

Permalink
build: enforce consistent version names (#9917)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
devversion authored and jelbourn committed Feb 13, 2018
1 parent 708b91a commit 2f891e6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tools/gulp/tasks/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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'));
Expand Down

0 comments on commit 2f891e6

Please sign in to comment.