Skip to content

Commit e1c11a3

Browse files
devversionalxhub
authored andcommitted
feat(dev-infra): introduce new configuration for release tool (angular#38656)
Introduces a new configuration for the `ng-dev release` command. This configuration will be the source of truth for all release packages and how they can be built. Additionally, in a temporary manner where each project has its own way of generating the changelog, the changelog generation can be configured. This will be removed in the future when there is canonical changelog generation in the dev-infra shared package. PR Close angular#38656
1 parent c1b47bc commit e1c11a3

File tree

4 files changed

+112
-0
lines changed

4 files changed

+112
-0
lines changed

.ng-dev/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import {commitMessage} from './commit-message';
33
import {format} from './format';
44
import {github} from './github';
55
import {merge} from './merge';
6+
import {release} from './release';
67

78
module.exports = {
89
commitMessage,
910
format,
1011
github,
1112
merge,
1213
caretaker,
14+
release,
1315
};

.ng-dev/release.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {join} from 'path';
2+
import {exec} from 'shelljs';
3+
import {ReleaseConfig} from '../dev-infra/release/config';
4+
5+
/** Configuration for the `ng-dev release` command. */
6+
export const release: ReleaseConfig = {
7+
npmPackages: [
8+
'@angular/animations',
9+
'@angular/bazel',
10+
'@angular/common',
11+
'@angular/compiler',
12+
'@angular/compiler-cli',
13+
'@angular/core',
14+
'@angular/elements',
15+
'@angular/forms',
16+
'@angular/language-service',
17+
'@angular/localize',
18+
'@angular/platform-browser',
19+
'@angular/platform-browser-dynamic',
20+
'@angular/platform-server',
21+
'@angular/platform-webworker',
22+
'@angular/platform-webworker-dynamic',
23+
'@angular/router',
24+
'@angular/service-worker',
25+
'@angular/upgrade',
26+
],
27+
// TODO: Implement release package building here.
28+
buildPackages: async () => [],
29+
// TODO: This can be removed once there is a org-wide tool for changelog generation.
30+
generateReleaseNotesForHead: async () => {
31+
exec('yarn -s gulp changelog', {cwd: join(__dirname, '../')});
32+
},
33+
};

dev-infra/release/config/BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("@npm_bazel_typescript//:index.bzl", "ts_library")
2+
3+
ts_library(
4+
name = "config",
5+
srcs = glob([
6+
"**/*.ts",
7+
]),
8+
module_name = "@angular/dev-infra-private/release/config",
9+
visibility = ["//dev-infra:__subpackages__"],
10+
deps = [
11+
"//dev-infra/utils",
12+
"@npm//@types/semver",
13+
],
14+
)

dev-infra/release/config/index.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import * as semver from 'semver';
10+
11+
import {assertNoErrors, getConfig, NgDevConfig} from '../../utils/config';
12+
13+
/** Interface describing a built package. */
14+
export interface BuiltPackage {
15+
/** Name of the package. */
16+
name: string;
17+
/** Path to the package output directory. */
18+
outputPath: string;
19+
}
20+
21+
/** Configuration for staging and publishing a release. */
22+
export interface ReleaseConfig {
23+
/** Registry URL used for publishing release packages. Defaults to the NPM registry. */
24+
publishRegistry?: string;
25+
/** List of NPM packages that are published as part of this project. */
26+
npmPackages: string[];
27+
/** Builds release packages and returns a list of paths pointing to the output. */
28+
buildPackages: () => Promise<BuiltPackage[]|null>;
29+
/** Generates the release notes from the most recent tag to `HEAD`. */
30+
generateReleaseNotesForHead: (outputPath: string) => Promise<void>;
31+
/**
32+
* Gets a pattern for extracting the release notes of the a given version.
33+
* @returns A pattern matching the notes for a given version (including the header).
34+
*/
35+
// TODO: Remove this in favor of a canonical changelog format across the Angular organization.
36+
extractReleaseNotesPattern?: (version: semver.SemVer) => RegExp;
37+
}
38+
39+
/** Configuration for releases in the dev-infra configuration. */
40+
export type DevInfraReleaseConfig = NgDevConfig<{release: ReleaseConfig}>;
41+
42+
/** Retrieve and validate the config as `ReleaseConfig`. */
43+
export function getReleaseConfig(config: Partial<DevInfraReleaseConfig> = getConfig()):
44+
ReleaseConfig {
45+
// List of errors encountered validating the config.
46+
const errors: string[] = [];
47+
48+
if (config.release === undefined) {
49+
errors.push(`No configuration defined for "release"`);
50+
}
51+
if (config.release?.npmPackages === undefined) {
52+
errors.push(`No "npmPackages" configured for releasing.`);
53+
}
54+
if (config.release?.buildPackages === undefined) {
55+
errors.push(`No "buildPackages" function configured for releasing.`);
56+
}
57+
if (config.release?.generateReleaseNotesForHead === undefined) {
58+
errors.push(`No "generateReleaseNotesForHead" function configured for releasing.`);
59+
}
60+
61+
assertNoErrors(errors);
62+
return config.release!;
63+
}

0 commit comments

Comments
 (0)