Skip to content

Commit f96dcc5

Browse files
devversionalxhub
authored andcommitted
feat(dev-infra): tool for staging and publishing releases (angular#38656)
Creates a tool for staging and publishing releases as per the new branching and versioning that has been outlined in the following document. The tool is intended to be used across the organization to ensure consistent branching/versioning and labeling: https://docs.google.com/document/d/197kVillDwx-RZtSVOBtPb4BBIAw0E9RT3q3v6DZkykU/edit#heading=h.s3qlps8f4zq7dd The tool implements the actions as outlined in the following initial plan: https://hackmd.io/2Le8leq0S6G_R5VEVTNK9A. The implementation slightly diverged in so far that it performs staging and publishing together so that releasing is a single convenient command. In case of errors for which re-running the full command is not sufficient, we want to consider adding recover functionality. e.g. when the staging completed, but the actual NPM publishing aborted unexpectedly due to build errors. PR Close angular#38656
1 parent 372a6cf commit f96dcc5

36 files changed

+2825
-0
lines changed

dev-infra/release/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ts_library(
99
visibility = ["//dev-infra:__subpackages__"],
1010
deps = [
1111
"//dev-infra/release/build",
12+
"//dev-infra/release/publish",
1213
"//dev-infra/release/set-dist-tag",
1314
"//dev-infra/utils",
1415
"@npm//@types/yargs",

dev-infra/release/cli.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import * as yargs from 'yargs';
99

1010
import {ReleaseBuildCommandModule} from './build/cli';
11+
import {ReleasePublishCommandModule} from './publish/cli';
1112
import {ReleaseSetDistTagCommand} from './set-dist-tag/cli';
1213
import {buildEnvStamp} from './stamping/env-stamp';
1314

@@ -16,6 +17,7 @@ export function buildReleaseParser(localYargs: yargs.Argv) {
1617
return localYargs.help()
1718
.strict()
1819
.demandCommand()
20+
.command(ReleasePublishCommandModule)
1921
.command(ReleaseBuildCommandModule)
2022
.command(ReleaseSetDistTagCommand)
2123
.command(
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
load("@npm_bazel_typescript//:index.bzl", "ts_library")
2+
3+
ts_library(
4+
name = "publish",
5+
srcs = glob([
6+
"**/*.ts",
7+
]),
8+
module_name = "@angular/dev-infra-private/release/publish",
9+
visibility = ["//dev-infra:__subpackages__"],
10+
deps = [
11+
"//dev-infra/pr/merge",
12+
"//dev-infra/release/config",
13+
"//dev-infra/release/versioning",
14+
"//dev-infra/utils",
15+
"@npm//@octokit/rest",
16+
"@npm//@types/inquirer",
17+
"@npm//@types/node",
18+
"@npm//@types/semver",
19+
"@npm//@types/yargs",
20+
"@npm//inquirer",
21+
"@npm//ora",
22+
"@npm//semver",
23+
"@npm//typed-graphqlify",
24+
],
25+
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
/** Error that will be thrown if the user manually aborted a release action. */
10+
export class UserAbortedReleaseActionError extends Error {
11+
constructor() {
12+
super();
13+
// Set the prototype explicitly because in ES5, the prototype is accidentally lost due to
14+
// a limitation in down-leveling.
15+
// https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work.
16+
Object.setPrototypeOf(this, UserAbortedReleaseActionError.prototype);
17+
}
18+
}
19+
20+
/** Error that will be thrown if the action has been aborted due to a fatal error. */
21+
export class FatalReleaseActionError extends Error {
22+
constructor() {
23+
super();
24+
// Set the prototype explicitly because in ES5, the prototype is accidentally lost due to
25+
// a limitation in down-leveling.
26+
// https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work.
27+
Object.setPrototypeOf(this, FatalReleaseActionError.prototype);
28+
}
29+
}

0 commit comments

Comments
 (0)