Skip to content

Commit e74a06e

Browse files
devversionandrewseguin
authored andcommitted
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.
1 parent 123880c commit e74a06e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/gulp/tasks/publish.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export const releasePackages = [
1616
'material-moment-adapter'
1717
];
1818

19+
/** Regular Expression that matches valid version numbers of Angular Material. */
20+
export const validVersionRegex = /^\d+\.\d+\.\d+(-(alpha|beta|rc)\.\d+)?$/;
21+
1922
/** Parse command-line arguments for release task. */
2023
const argv = minimist(process.argv.slice(3));
2124

@@ -46,6 +49,14 @@ task(':publish', async () => {
4649
const version = buildConfig.projectVersion;
4750
const currentDir = process.cwd();
4851

52+
if (!version.match(validVersionRegex)) {
53+
console.log(red(`Error: Cannot publish due to an invalid version name. Version "${version}" ` +
54+
`is not following our semver format.`));
55+
console.log(yellow(`A version should follow this format: d.d.d, d.d.d-beta.x, d.d.d-alpha.x, ` +
56+
`d.d.d-rc.x`));
57+
return;
58+
}
59+
4960
console.log('');
5061
if (!tag) {
5162
console.log(grey('> You can specify the tag by passing --tag=labelName.\n'));

0 commit comments

Comments
 (0)