Skip to content

Commit 0aec45a

Browse files
authored
build: switch to release tool from dev-infra (#23333)
* build: switch to release tool from dev-infra Switches to the release tool from the shared dev-infra package. This script is more aligned with the versioning and branching the whole Angular organization follows as this point. We work around a couple of APIs that need to be discussed within the release tool in order to wire up custom release stage / publish validations. We still want to keep them for now so we use some monkey-patching (which is acceptable for the interim until we have determined which checks should be built-in / how consumers can wire up additional checks) * fixup! build: switch to release tool from dev-infra Remove wombat registry explicit entries * fixup! build: switch to release tool from dev-infra Address feedback
1 parent 219e1f5 commit 0aec45a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+302
-241
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ test --test_output=errors
4545

4646
# Configures script to do version stamping.
4747
# See https://docs.bazel.build/versions/master/user-manual.html#flag--workspace_status_command
48-
build:release --workspace_status_command="node ./tools/bazel-stamp-vars.js"
48+
build:release --workspace_status_command="yarn -s ng-dev release build-env-stamp --mode=release"
4949
build:release --stamp
5050

51-
build:snapshot-build --workspace_status_command="node ./tools/bazel-stamp-vars.js --snapshot"
51+
build:snapshot-build --workspace_status_command="yarn -s ng-dev release build-env-stamp --mode=snapshot"
5252
build:snapshot-build --stamp
5353

5454
################################

.circleci/config.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,16 +386,8 @@ jobs:
386386
- *yarn_install
387387
- *setup_bazel_binary
388388

389-
- run: yarn build
390-
- run:
391-
name: Checking release output
392-
command: |
393-
pkg_json_version=$(node -pe "require('./package.json').version")
394-
expected_version="${pkg_json_version}-sha-$(git rev-parse --short HEAD)"
395-
yarn check-release-output ${expected_version}
396-
- run:
397-
name: Checking tooling scripts
398-
command: yarn check-tools
389+
- run: yarn build-and-check-release-output
390+
- run: yarn check-tools
399391

400392
# TODO(devversion): replace this with bazel tests that run Madge. This is
401393
# cumbersome and doesn't guarantee no circular deps for other entry-points.

.ng-dev/release.ts

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,66 @@
1-
import {join} from 'path';
2-
import {ReleaseConfig} from '@angular/dev-infra-private/release/config';
3-
import {releasePackages} from '../tools/release/release-output/release-packages';
4-
import {promptAndGenerateChangelog} from '../tools/release/changelog';
1+
import {BuiltPackage, ReleaseConfig} from '@angular/dev-infra-private/release/config';
2+
import {ReleaseAction} from '@angular/dev-infra-private/release/publish/actions';
3+
import {SemVer} from 'semver';
4+
5+
import {
6+
assertValidFrameworkPeerDependency
7+
} from '../tools/release-checks/check-framework-peer-dependency';
8+
import {
9+
assertValidUpdateMigrationCollections
10+
} from '../tools/release-checks/check-migration-collections';
11+
import {assertValidNpmPackageOutput} from '../tools/release-checks/npm-package-output';
12+
13+
const actionProto = ReleaseAction.prototype as any;
14+
const _origStageFn = actionProto.stageVersionForBranchAndCreatePullRequest;
15+
const _origVerifyFn = actionProto._verifyPackageVersions;
16+
17+
// Patches the `@angular/dev-infra-private` release tool to perform sanity checks
18+
// before staging a release. This is temporary until the dev-infra team has implemented
19+
// a more generic solution to running sanity checks before releasing (potentially building
20+
// some of the checks we have in the components repository into the release tool).
21+
actionProto.stageVersionForBranchAndCreatePullRequest = async function(newVersion: SemVer) {
22+
await assertValidFrameworkPeerDependency(newVersion);
23+
await assertValidUpdateMigrationCollections(newVersion);
24+
25+
return await _origStageFn.apply(this, arguments);
26+
};
27+
28+
// Patches the `@angular/dev-infra-private` release tool to perform sanity
29+
// checks of the NPM package output, before publishing to NPM.
30+
actionProto._verifyPackageVersions =
31+
async function(newVersion: SemVer, builtPackages: BuiltPackage[]) {
32+
await assertValidNpmPackageOutput(builtPackages, newVersion);
33+
34+
return await _origVerifyFn.apply(this, arguments);
35+
};
36+
37+
/**
38+
* Packages that will be published as part of the project.
39+
*
40+
* Note: The order of packages here will control how sections
41+
* appear in the changelog.
42+
*/
43+
export const releasePackages = [
44+
'cdk',
45+
'material',
46+
'google-maps',
47+
'youtube-player',
48+
'cdk-experimental',
49+
'material-experimental',
50+
'material-moment-adapter',
51+
'material-luxon-adapter',
52+
'material-date-fns-adapter',
53+
];
554

655
/** Configuration for the `ng-dev release` command. */
756
export const release: ReleaseConfig = {
57+
releaseNotes: {useReleaseTitle: true, groupOrder: releasePackages},
858
publishRegistry: 'https://wombat-dressing-room.appspot.com',
959
npmPackages: releasePackages.map(pkg => `@angular/${pkg}`),
1060
buildPackages: async () => {
11-
// The performNpmReleaseBuild function is loaded at runtime as the loading the script causes an
12-
// invocation of bazel.
13-
const {performNpmReleaseBuild} = require(join(__dirname, '../scripts/build-packages-dist'));
61+
// The `performNpmReleaseBuild` function is loaded at runtime as loading of the
62+
// script results in an invocation of Bazel for any `yarn ng-dev` command.
63+
const {performNpmReleaseBuild} = await import('../scripts/build-packages-dist');
1464
return performNpmReleaseBuild();
15-
},
16-
// TODO: This can be removed once there is an org-wide tool for changelog generation.
17-
generateReleaseNotesForHead: async () => {
18-
await promptAndGenerateChangelog(join(__dirname, '../CHANGELOG.md'));
19-
},
65+
}
2066
};

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
},
1616
"scripts": {
1717
"postinstall": "node tools/postinstall/apply-patches.js && ngcc --properties module main --create-ivy-entry-points && node tools/postinstall/update-ngcc-main-fields.js",
18-
"build": "node ./scripts/build-packages-dist.js",
18+
"build": "ts-node --project scripts/tsconfig.json ./scripts/build-packages-dist.js",
19+
"build-and-check-release-output": "ts-node --project scripts/tsconfig.json scripts/build-and-check-release-output.ts",
1920
"build-docs-content": "node ./scripts/build-docs-content.js",
2021
"dev-app": "ibazel run //src/dev-app:devserver",
2122
"test": "node ./scripts/run-component-tests.js",
@@ -26,10 +27,9 @@
2627
"deploy-dev-app": "node ./scripts/deploy-dev-app.js",
2728
"breaking-changes": "ts-node --project scripts/tsconfig.json scripts/breaking-changes.ts",
2829
"gulp": "gulp",
29-
"stage-release": "ts-node --project tools/release/tsconfig.json tools/release/stage-release.ts",
30-
"publish-release": "ts-node --project tools/release/tsconfig.json tools/release/publish-release.ts",
30+
"~~stage-release": "ts-node --project tools/legacy-release/tsconfig.json tools/legacy-release/stage-release.ts",
31+
"~~publish-release": "ts-node --project tools/legacy-release/tsconfig.json tools/legacy-release/publish-release.ts",
3132
"check-entry-point-setup": "node ./scripts/check-entry-point-setup.js",
32-
"check-release-output": "ts-node --project tools/release/tsconfig.json tools/release/check-release-output.ts",
3333
"check-rollup-globals": "ts-node --project scripts/tsconfig.json scripts/check-rollup-globals.ts",
3434
"changelog": "ts-node --project tools/release/tsconfig.json tools/release/changelog.ts",
3535
"format": "yarn ng-dev format changed",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Script that builds the NPM release output for all packages
3+
* and runs sanity checks against the NPM package output.
4+
*/
5+
6+
import {performNpmReleaseBuild} from './build-packages-dist';
7+
import {assertValidNpmPackageOutput} from '../tools/release-checks/npm-package-output';
8+
import * as semver from 'semver';
9+
10+
const {version} = require('../package.json');
11+
12+
async function main() {
13+
// Build the NPM package artifacts.
14+
const builtPackages = performNpmReleaseBuild();
15+
16+
// Run the release output validation checks.
17+
await assertValidNpmPackageOutput(builtPackages, semver.parse(version)!);
18+
}
19+
20+
main().catch(e => {
21+
console.error(e);
22+
process.exit(1);
23+
});
24+
25+

scripts/build-packages-dist.js renamed to scripts/build-packages-dist.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
* distribution folder within the project.
77
*/
88

9-
const {execSync} = require('child_process');
10-
const {join} = require('path');
11-
const {chmod, cp, mkdir, rm, set, test} = require('shelljs');
9+
import {execSync} from 'child_process';
10+
import {join} from 'path';
11+
import {BuiltPackage} from '@angular/dev-infra-private/release/config';
12+
import {chmod, cp, mkdir, rm, set, test} from 'shelljs';
1213

1314
// ShellJS should exit if a command fails.
1415
set('-e');
@@ -20,7 +21,7 @@ const releaseTargetTag = 'release-package';
2021
const projectDir = join(__dirname, '../');
2122

2223
/** Command that runs Bazel. */
23-
const bazelCmd = process.env.BAZEL_COMMAND || `yarn -s bazel`;
24+
const bazelCmd = process.env.BAZEL_COMMAND || `bazel`;
2425

2526
/** Command that queries Bazel for all release package targets. */
2627
const queryPackagesCmd =
@@ -43,23 +44,25 @@ if (module === require.main) {
4344
}
4445

4546
/** Builds the release packages for NPM. */
46-
function performNpmReleaseBuild() {
47+
export function performNpmReleaseBuild(): BuiltPackage[] {
4748
return buildReleasePackages(false, defaultDistPath, /* isSnapshotBuild */ false);
4849
}
4950

5051
/**
5152
* Builds the release packages as snapshot build. This means that the current
5253
* Git HEAD SHA is included in the version (for easier debugging and back tracing).
5354
*/
54-
function performDefaultSnapshotBuild() {
55+
export function performDefaultSnapshotBuild(): BuiltPackage[] {
5556
return buildReleasePackages(false, defaultDistPath, /* isSnapshotBuild */ true);
5657
}
5758

5859
/**
5960
* Builds the release packages with the given compile mode and copies
6061
* the package output into the given directory.
6162
*/
62-
function buildReleasePackages(useIvy, distPath, isSnapshotBuild) {
63+
function buildReleasePackages(useIvy: boolean, distPath: string,
64+
isSnapshotBuild: boolean): BuiltPackage[] {
65+
6366
console.log('######################################');
6467
console.log(' Building release packages...');
6568
console.log(` Compiling with Ivy: ${useIvy}`);
@@ -109,15 +112,15 @@ function buildReleasePackages(useIvy, distPath, isSnapshotBuild) {
109112
return {
110113
name: `@angular/${pkg}`,
111114
outputPath
112-
}
113-
})
115+
};
116+
});
114117
}
115118

116119
/**
117120
* Gets the package names of the specified Bazel targets.
118-
* e.g. //src/material:npm_package -> material
121+
* e.g. //src/material:npm_package = material
119122
*/
120-
function getPackageNamesOfTargets(targets) {
123+
function getPackageNamesOfTargets(targets: string[]): string[] {
121124
return targets.map(targetName => {
122125
const matches = targetName.match(/\/\/src\/(.*):npm_package/);
123126
if (matches === null) {
@@ -128,13 +131,11 @@ function getPackageNamesOfTargets(targets) {
128131
});
129132
}
130133

131-
/**
132-
* Executes the given command in the project directory.
133-
* @param {string} command The command to run
134-
* @param {boolean=} captureStdout Whether the stdout should be captured and
135-
* returned.
136-
*/
137-
function exec(command, captureStdout) {
134+
/** Executes the given command in the project directory. */
135+
function exec(command: string): void;
136+
/** Executes the given command in the project directory and returns its stdout. */
137+
function exec(command: string, captureStdout: true): string;
138+
function exec(command: string, captureStdout?: true) {
138139
const stdout = execSync(command, {
139140
cwd: projectDir,
140141
stdio: ['inherit', captureStdout ? 'pipe' : 'inherit', 'inherit'],

src/cdk-experimental/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,5 @@
1818
"dependencies": {
1919
"tslib": "0.0.0-TSLIB"
2020
},
21-
"sideEffects": false,
22-
"publishConfig":{
23-
"registry":"https://wombat-dressing-room.appspot.com"
24-
}
21+
"sideEffects": false
2522
}

src/cdk/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,5 @@
3333
"ng-update": {
3434
"migrations": "./schematics/migration.json"
3535
},
36-
"sideEffects": false,
37-
"publishConfig":{
38-
"registry":"https://wombat-dressing-room.appspot.com"
39-
}
36+
"sideEffects": false
4037
}

src/google-maps/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,5 @@
2626
"rxjs": "0.0.0-RXJS"
2727
},
2828
"sideEffects": false,
29-
"publishConfig": {
30-
"registry": "https://wombat-dressing-room.appspot.com"
31-
},
3229
"ng-update": {}
3330
}

src/material-date-fns-adapter/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,5 @@
2626
"@angular/material-date-fns-adapter"
2727
]
2828
},
29-
"sideEffects": false,
30-
"publishConfig": {
31-
"registry":"https://wombat-dressing-room.appspot.com"
32-
}
29+
"sideEffects": false
3330
}

src/material-experimental/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,5 @@
1919
"dependencies": {
2020
"tslib": "0.0.0-TSLIB"
2121
},
22-
"sideEffects": false,
23-
"publishConfig":{
24-
"registry":"https://wombat-dressing-room.appspot.com"
25-
}
22+
"sideEffects": false
2623
}

src/material-luxon-adapter/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,5 @@
2626
"@angular/material-luxon-adapter"
2727
]
2828
},
29-
"sideEffects": false,
30-
"publishConfig": {
31-
"registry":"https://wombat-dressing-room.appspot.com"
32-
}
29+
"sideEffects": false
3330
}

src/material-moment-adapter/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,5 @@
2626
"@angular/material-moment-adapter"
2727
]
2828
},
29-
"sideEffects": false,
30-
"publishConfig":{
31-
"registry":"https://wombat-dressing-room.appspot.com"
32-
}
29+
"sideEffects": false
3330
}

src/material/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
"@angular/material-date-fns-adapter"
4040
]
4141
},
42-
"sideEffects": false,
43-
"publishConfig":{
44-
"registry":"https://wombat-dressing-room.appspot.com"
45-
}
42+
"sideEffects": false
4643
}
4744

src/youtube-player/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,5 @@
2626
"rxjs": "0.0.0-RXJS"
2727
},
2828
"sideEffects": false,
29-
"publishConfig":{
30-
"registry":"https://wombat-dressing-room.appspot.com"
31-
},
3229
"ng-update": {}
3330
}

tools/bazel-stamp-vars.js

Lines changed: 0 additions & 57 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)