Skip to content

Commit aad9876

Browse files
devversionandrewseguin
authored andcommitted
build: run release output validations on circle (#14716)
* Runs the release output validations on CircleCI after all release packages have been built. Closes #12877
1 parent ec9f9c8 commit aad9876

File tree

5 files changed

+38
-22
lines changed

5 files changed

+38
-22
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ jobs:
246246
- *yarn_install
247247

248248
- run: yarn gulp ci:build-release-packages
249+
- run: yarn check-release-output
249250

250251
# Store the release output in the workspace storage. This means that other jobs
251252
# in the same workflow can attach the release output to their job.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"gulp": "gulp",
2626
"stage-release": "ts-node --project tools/release/ tools/release/stage-release.ts",
2727
"publish-release": "ts-node --project tools/release/ tools/release/publish-release.ts",
28+
"check-release-output": "ts-node --project tools/release tools/release/check-release-output.ts",
2829
"preinstall": "node ./tools/npm/check-npm.js"
2930
},
3031
"version": "7.2.1",

tools/release/check-release-output.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {green, red} from 'chalk';
2+
import {join} from 'path';
3+
import {checkReleasePackage} from './release-output/check-package';
4+
import {releasePackages} from './release-output/release-packages';
5+
6+
/**
7+
* Checks the release output by running the release-output validations for each
8+
* release package.
9+
*/
10+
export function checkReleaseOutput(releaseOutputDir: string) {
11+
let hasFailed = false;
12+
13+
releasePackages.forEach(packageName => {
14+
if (!checkReleasePackage(releaseOutputDir, packageName)) {
15+
hasFailed = true;
16+
}
17+
});
18+
19+
// In case any release validation did not pass, abort the publishing because
20+
// the issues need to be resolved before publishing.
21+
if (hasFailed) {
22+
console.error(red(` ✘ Release output does not pass all release validations. Please fix ` +
23+
`all failures or reach out to the team.`));
24+
process.exit(1);
25+
}
26+
27+
console.info(green(` ✓ Release output passed validation checks.`));
28+
}
29+
30+
31+
if (require.main === module) {
32+
checkReleaseOutput(join(__dirname, '../../dist/releases'));
33+
}

tools/release/publish-release.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import {execSync} from 'child_process';
33
import {readFileSync} from 'fs';
44
import {join} from 'path';
55
import {BaseReleaseTask} from './base-release-task';
6+
import {checkReleaseOutput} from './check-release-output';
67
import {extractReleaseNotes} from './extract-release-notes';
78
import {GitClient} from './git/git-client';
89
import {getGithubReleasesUrl} from './git/github-urls';
910
import {isNpmAuthenticated, runInteractiveNpmLogin, runNpmPublish} from './npm/npm-client';
1011
import {promptForNpmDistTag} from './prompt/npm-dist-tag-prompt';
11-
import {checkReleasePackage} from './release-output/check-packages';
1212
import {releasePackages} from './release-output/release-packages';
1313
import {CHANGELOG_FILE_NAME} from './stage-release';
1414
import {parseVersionName, Version} from './version-name/parse-version';
@@ -87,8 +87,8 @@ class PublishReleaseTask extends BaseReleaseTask {
8787
this.buildReleasePackages();
8888
console.info(green(` ✓ Built the release output.`));
8989

90-
this.checkReleaseOutput();
91-
console.info(green(` ✓ Release output passed validation checks.`));
90+
// Checks all release packages against release output validations before releasing.
91+
checkReleaseOutput(this.releaseOutputPath);
9292

9393
// Extract the release notes for the new version from the changelog file.
9494
const releaseNotes = extractReleaseNotes(
@@ -145,25 +145,6 @@ class PublishReleaseTask extends BaseReleaseTask {
145145
spawnOptions);
146146
}
147147

148-
/** Checks the release output by running the release-output validations. */
149-
private checkReleaseOutput() {
150-
let hasFailed = false;
151-
152-
releasePackages.forEach(packageName => {
153-
if (!checkReleasePackage(this.releaseOutputPath, packageName)) {
154-
hasFailed = true;
155-
}
156-
});
157-
158-
// In case any release validation did not pass, abort the publishing because
159-
// the issues need to be resolved before publishing.
160-
if (hasFailed) {
161-
console.error(red(` ✘ Release output does not pass all release validations. Please fix ` +
162-
`all failures or reach out to the team.`));
163-
process.exit(1);
164-
}
165-
}
166-
167148
/**
168149
* Prompts the user whether they are sure that the current stable version should be
169150
* released to the "next" NPM dist-tag.

0 commit comments

Comments
 (0)