Skip to content

Commit 8139358

Browse files
devversionmmalerba
authored andcommitted
build: option to ignore ci checks when staging release (#16262)
Closes #16139
1 parent 11a4ff0 commit 8139358

File tree

1 file changed

+40
-26
lines changed

1 file changed

+40
-26
lines changed

tools/release/stage-release.ts

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const CHANGELOG_FILE_NAME = 'CHANGELOG.md';
3232
* 11) Create a commit that includes all changes in the staging branch.
3333
*/
3434
class StageReleaseTask extends BaseReleaseTask {
35-
3635
/** Path to the project package JSON. */
3736
packageJsonPath: string;
3837

@@ -48,19 +47,18 @@ class StageReleaseTask extends BaseReleaseTask {
4847
/** Octokit API instance that can be used to make Github API calls. */
4948
githubApi: OctokitApi;
5049

51-
constructor(public projectDir: string,
52-
public repositoryOwner: string,
53-
public repositoryName: string) {
54-
super(new GitClient(projectDir,
55-
`https://github.com/${repositoryOwner}/${repositoryName}.git`));
50+
constructor(
51+
public projectDir: string, public repositoryOwner: string, public repositoryName: string) {
52+
super(new GitClient(projectDir, `https://github.com/${repositoryOwner}/${repositoryName}.git`));
5653

5754
this.packageJsonPath = join(projectDir, 'package.json');
5855
this.packageJson = JSON.parse(readFileSync(this.packageJsonPath, 'utf-8'));
59-
this.currentVersion = parseVersionName(this.packageJson.version);
56+
this.currentVersion = parseVersionName(this.packageJson.version)!;
6057

6158
if (!this.currentVersion) {
62-
console.error(red(`Cannot parse current version in ${italic('package.json')}. Please ` +
63-
`make sure "${this.packageJson.version}" is a valid Semver version.`));
59+
console.error(
60+
red(`Cannot parse current version in ${italic('package.json')}. Please ` +
61+
`make sure "${this.packageJson.version}" is a valid Semver version.`));
6462
process.exit(1);
6563
}
6664

@@ -101,18 +99,21 @@ class StageReleaseTask extends BaseReleaseTask {
10199
if (needsVersionBump) {
102100
this._updatePackageJsonVersion(newVersionName);
103101

104-
console.log(green(` ✓ Updated the version to "${bold(newVersionName)}" inside of the ` +
105-
`${italic('package.json')}`));
102+
console.log(green(
103+
` ✓ Updated the version to "${bold(newVersionName)}" inside of the ` +
104+
`${italic('package.json')}`));
106105
console.log();
107106
}
108107

109108
await promptAndGenerateChangelog(join(this.projectDir, CHANGELOG_FILE_NAME));
110109

111110
console.log();
112-
console.log(green(` ✓ Updated the changelog in ` +
113-
`"${bold(CHANGELOG_FILE_NAME)}"`));
114-
console.log(yellow(` ⚠ Please review CHANGELOG.md and ensure that the log contains only ` +
115-
`changes that apply to the public library release. When done, proceed to the prompt below.`));
111+
console.log(green(
112+
` ✓ Updated the changelog in ` +
113+
`"${bold(CHANGELOG_FILE_NAME)}"`));
114+
console.log(yellow(
115+
` ⚠ Please review CHANGELOG.md and ensure that the log contains only changes ` +
116+
`that apply to the public library release. When done, proceed to the prompt below.`));
116117
console.log();
117118

118119
if (!await this.promptConfirm('Do you want to proceed and commit the changes?')) {
@@ -148,23 +149,37 @@ class StageReleaseTask extends BaseReleaseTask {
148149
/** Verifies that the latest commit of the current branch is passing all Github statuses. */
149150
private async _verifyPassingGithubStatus(expectedPublishBranch: string) {
150151
const commitRef = this.git.getLocalCommitSha('HEAD');
151-
const githubCommitsUrl = getGithubBranchCommitsUrl(this.repositoryOwner, this.repositoryName,
152-
expectedPublishBranch);
152+
const githubCommitsUrl =
153+
getGithubBranchCommitsUrl(this.repositoryOwner, this.repositoryName, expectedPublishBranch);
153154
const {state} = (await this.githubApi.repos.getCombinedStatusForRef({
154-
owner: this.repositoryOwner,
155-
repo: this.repositoryName,
156-
ref: commitRef,
157-
})).data;
155+
owner: this.repositoryOwner,
156+
repo: this.repositoryName,
157+
ref: commitRef,
158+
})).data;
158159

159160
if (state === 'failure') {
160-
console.error(red(` ✘ Cannot stage release. Commit "${commitRef}" does not pass all ` +
161-
`github status checks. Please make sure this commit passes all checks before re-running.`));
161+
console.error(
162+
red(` ✘ Cannot stage release. Commit "${commitRef}" does not pass all github ` +
163+
`status checks. Please make sure this commit passes all checks before re-running.`));
162164
console.error(red(` Please have a look at: ${githubCommitsUrl}`));
165+
if (await this.promptConfirm('Do you want to ignore the Github status and proceed?')) {
166+
console.info(green(
167+
` ⚠ Upstream commit is failing CI checks, but status has been ` +
168+
`forcibly ignored.`));
169+
return;
170+
}
163171
process.exit(1);
164172
} else if (state === 'pending') {
165-
console.error(red(` ✘ Commit "${commitRef}" still has pending github statuses that ` +
166-
`need to succeed before staging a release.`));
173+
console.error(
174+
red(` ✘ Commit "${commitRef}" still has pending github statuses that ` +
175+
`need to succeed before staging a release.`));
167176
console.error(red(` Please have a look at: ${githubCommitsUrl}`));
177+
if (await this.promptConfirm('Do you want to ignore the Github status and proceed?')) {
178+
console.info(green(
179+
` ⚠ Upstream commit is pending CI, but status has been ` +
180+
`forcibly ignored.`));
181+
return;
182+
}
168183
process.exit(0);
169184
}
170185

@@ -176,4 +191,3 @@ class StageReleaseTask extends BaseReleaseTask {
176191
if (require.main === module) {
177192
new StageReleaseTask(join(__dirname, '../../'), 'angular', 'components').run();
178193
}
179-

0 commit comments

Comments
 (0)