mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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.
This commit is contained in:
committed by
Jeremy Elbourn
parent
708b91a7c4
commit
2f891e64f6
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user