diff --git a/.circleci/config.yml b/.circleci/config.yml index a20ee779c87b..989c7d27f761 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -246,6 +246,7 @@ jobs: - *yarn_install - run: yarn gulp ci:build-release-packages + - run: yarn check-release-output # Store the release output in the workspace storage. This means that other jobs # in the same workflow can attach the release output to their job. diff --git a/package.json b/package.json index 8987d3a1dd71..2aa67c3e27cb 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "gulp": "gulp", "stage-release": "ts-node --project tools/release/ tools/release/stage-release.ts", "publish-release": "ts-node --project tools/release/ tools/release/publish-release.ts", + "check-release-output": "ts-node --project tools/release tools/release/check-release-output.ts", "preinstall": "node ./tools/npm/check-npm.js" }, "version": "7.2.0", diff --git a/tools/release/check-release-output.ts b/tools/release/check-release-output.ts new file mode 100644 index 000000000000..02c20b77b12d --- /dev/null +++ b/tools/release/check-release-output.ts @@ -0,0 +1,33 @@ +import {green, red} from 'chalk'; +import {join} from 'path'; +import {checkReleasePackage} from './release-output/check-package'; +import {releasePackages} from './release-output/release-packages'; + +/** + * Checks the release output by running the release-output validations for each + * release package. + */ +export function checkReleaseOutput(releaseOutputDir: string) { + let hasFailed = false; + + releasePackages.forEach(packageName => { + if (!checkReleasePackage(releaseOutputDir, packageName)) { + hasFailed = true; + } + }); + + // In case any release validation did not pass, abort the publishing because + // the issues need to be resolved before publishing. + if (hasFailed) { + console.error(red(` ✘ Release output does not pass all release validations. Please fix ` + + `all failures or reach out to the team.`)); + process.exit(1); + } + + console.info(green(` ✓ Release output passed validation checks.`)); +} + + +if (require.main === module) { + checkReleaseOutput(join(__dirname, '../../dist/releases')); +} diff --git a/tools/release/publish-release.ts b/tools/release/publish-release.ts index 15fe05c9bb29..53355964238b 100644 --- a/tools/release/publish-release.ts +++ b/tools/release/publish-release.ts @@ -3,12 +3,12 @@ import {execSync} from 'child_process'; import {readFileSync} from 'fs'; import {join} from 'path'; import {BaseReleaseTask} from './base-release-task'; +import {checkReleaseOutput} from './check-release-output'; import {extractReleaseNotes} from './extract-release-notes'; import {GitClient} from './git/git-client'; import {getGithubReleasesUrl} from './git/github-urls'; import {isNpmAuthenticated, runInteractiveNpmLogin, runNpmPublish} from './npm/npm-client'; import {promptForNpmDistTag} from './prompt/npm-dist-tag-prompt'; -import {checkReleasePackage} from './release-output/check-packages'; import {releasePackages} from './release-output/release-packages'; import {CHANGELOG_FILE_NAME} from './stage-release'; import {parseVersionName, Version} from './version-name/parse-version'; @@ -87,8 +87,8 @@ class PublishReleaseTask extends BaseReleaseTask { this.buildReleasePackages(); console.info(green(` ✓ Built the release output.`)); - this.checkReleaseOutput(); - console.info(green(` ✓ Release output passed validation checks.`)); + // Checks all release packages against release output validations before releasing. + checkReleaseOutput(this.releaseOutputPath); // Extract the release notes for the new version from the changelog file. const releaseNotes = extractReleaseNotes( @@ -145,25 +145,6 @@ class PublishReleaseTask extends BaseReleaseTask { spawnOptions); } - /** Checks the release output by running the release-output validations. */ - private checkReleaseOutput() { - let hasFailed = false; - - releasePackages.forEach(packageName => { - if (!checkReleasePackage(this.releaseOutputPath, packageName)) { - hasFailed = true; - } - }); - - // In case any release validation did not pass, abort the publishing because - // the issues need to be resolved before publishing. - if (hasFailed) { - console.error(red(` ✘ Release output does not pass all release validations. Please fix ` + - `all failures or reach out to the team.`)); - process.exit(1); - } - } - /** * Prompts the user whether they are sure that the current stable version should be * released to the "next" NPM dist-tag. diff --git a/tools/release/release-output/check-packages.ts b/tools/release/release-output/check-package.ts similarity index 100% rename from tools/release/release-output/check-packages.ts rename to tools/release/release-output/check-package.ts