Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 25a1a99

Browse files
authored
build: switch release methods (#710)
1 parent 1a5c4d3 commit 25a1a99

File tree

4 files changed

+46
-16
lines changed

4 files changed

+46
-16
lines changed

tools/gulp/gulpfile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ createPackageBuildTasks(flexLayoutPackage);
77
import './tasks/aot';
88
import './tasks/build-release'; // release build `github.com/angular/flex-layout-builds`
99
import './tasks/clean';
10+
import './tasks/changelog';
1011
import './tasks/ci';
1112
import './tasks/default';
1213
import './tasks/development';

tools/gulp/tasks/changelog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {task, src, dest} from 'gulp';
2-
import {buildConfig} from 'material2-build-tools';
2+
import {buildConfig} from 'lib-build-tools';
33
import {join} from 'path';
44
import {yellow, red} from 'chalk';
55

tools/gulp/tasks/publish.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export const releasePackages = [
1212
'flex-layout'
1313
];
1414

15+
/** Regular Expression that matches valid version numbers of Angular Material. */
16+
export const validVersionRegex = /^\d+\.\d+\.\d+(-(alpha|beta|rc)\.\d+)?$/;
17+
1518
/** Parse command-line arguments for release task. */
1619
const argv = minimist(process.argv.slice(3));
1720

@@ -38,22 +41,40 @@ task(':publish:whoami', execTask('npm', ['whoami'], {
3841
task(':publish:logout', execTask('npm', ['logout']));
3942

4043
task(':publish', async () => {
41-
const label = argv['tag'];
44+
const tag = argv['tag'];
4245
const version = buildConfig.projectVersion;
4346
const currentDir = process.cwd();
4447

48+
if (!version.match(validVersionRegex)) {
49+
console.log(red(`Error: Cannot publish due to an invalid version name. Version "${version}" ` +
50+
`is not following our semver format.`));
51+
console.log(yellow(`A version should follow this format: d.d.d, d.d.d-beta.x, d.d.d-alpha.x, ` +
52+
`d.d.d-rc.x`));
53+
return;
54+
}
55+
4556
console.log('');
46-
if (!label) {
47-
console.log(yellow('You can use a label with --tag=labelName.'));
48-
console.log(yellow(`Publishing version ${version} using the latest tag.`));
57+
if (!tag) {
58+
console.log(grey('> You can specify the tag by passing --tag=labelName.\n'));
59+
console.log(green(`Publishing version "${version}" to the latest tag...`));
4960
} else {
50-
console.log(yellow(`Publishing ${version} using the ${label} tag.`));
61+
console.log(yellow(`Publishing version "${version}" to the ${tag} tag...`));
5162
}
5263
console.log('');
5364

65+
66+
// TODO(CaerusKaru): uncomment when Layout exits beta/rc
67+
// if (version.match(/(alpha|beta|rc)/) && (!tag || tag === 'latest')) {
68+
// console.log(red(`Publishing ${version} to the "latest" tag is not allowed.`));
69+
// console.log(red(`Alpha, Beta or RC versions shouldn't be published to "latest".`));
70+
// console.log();
71+
// return;
72+
// }
73+
5474
if (releasePackages.length > 1) {
5575
console.warn(red('Warning: Multiple packages will be released if proceeding.'));
56-
console.warn(red('Warning: Packages to be released: ', releasePackages.join(', ')));
76+
console.warn(red('Warning: Packages to be released:', releasePackages.join(', ')));
77+
console.log();
5778
}
5879

5980
console.log(yellow('> Make sure to check the "angularVersion" in the build config.'));
@@ -62,13 +83,13 @@ task(':publish', async () => {
6283

6384
// Iterate over every declared release package and publish it on NPM.
6485
for (const packageName of releasePackages) {
65-
await _execNpmPublish(label, packageName);
86+
await _execNpmPublish(tag, packageName);
6687
}
6788

6889
process.chdir(currentDir);
6990
});
7091

71-
function _execNpmPublish(label: string, packageName: string): Promise<{}> | undefined {
92+
function _execNpmPublish(tag: string, packageName: string): Promise<{}> | undefined {
7293
const packageDir = join(buildConfig.outputDir, 'releases', packageName);
7394

7495
if (!statSync(packageDir).isDirectory()) {
@@ -89,8 +110,8 @@ function _execNpmPublish(label: string, packageName: string): Promise<{}> | unde
89110
const command = 'npm';
90111
const args = ['publish', '--access', 'public'];
91112

92-
if (label) {
93-
args.push('--tag', label);
113+
if (tag) {
114+
args.push('--tag', tag);
94115
}
95116

96117
return new Promise((resolve, reject) => {

tools/gulp/tasks/validate-release.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {readFileSync} from 'fs';
33
import {join} from 'path';
44
import {green, red} from 'chalk';
55
import {releasePackages} from './publish';
6+
import {sync as glob} from 'glob';
67
import {buildConfig, sequenceTask} from 'lib-build-tools';
78

8-
99
/** Path to the directory where all releases are created. */
1010
const releasesDir = join(buildConfig.outputDir, 'releases');
1111

@@ -37,9 +37,19 @@ task('validate-release:check-bundles', () => {
3737

3838
/** Task that validates the given release package before releasing. */
3939
function checkReleasePackage(packageName: string): string[] {
40-
const bundlePath = join(releasesDir, packageName, '@angular', `${packageName}.js`);
40+
return glob(join(releasesDir, packageName, 'esm2015/*.js'))
41+
.reduce((failures: string[], bundlePath: string) => {
42+
return failures.concat(checkEs2015ReleaseBundle(bundlePath));
43+
}, []);
44+
}
45+
46+
/**
47+
* Checks an ES2015 bundle inside of a release package. Secondary entry-point bundles will be
48+
* checked as well.
49+
*/
50+
function checkEs2015ReleaseBundle(bundlePath: string): string[] {
4151
const bundleContent = readFileSync(bundlePath, 'utf8');
42-
let failures = [];
52+
let failures: string[] = [];
4353

4454
if (inlineStylesSourcemapRegex.exec(bundleContent) !== null) {
4555
failures.push('Bundles contain sourcemap references in component styles.');
@@ -52,5 +62,3 @@ function checkReleasePackage(packageName: string): string[] {
5262
return failures;
5363
}
5464

55-
56-

0 commit comments

Comments
 (0)