Skip to content

Commit f59c1ee

Browse files
devversionvivian-hu-zz
authored andcommitted
build: print url to commits if staging script fails due to failing status (#14509)
* Based on a recent chat with Miles, it would be good if we default the `Is pre-release?` question to `false` and also print an URL if the status checks for a given branch fail (this should be just more convenient to see what failed)
1 parent c460728 commit f59c1ee

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

tools/release/git/github-urls.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** Gets a Github URL that refers to a lists of recent commits within a specified branch. */
2+
export function getGithubBranchCommitsUrl(owner: string, repository: string, branchName: string) {
3+
return `https://github.com/${owner}/${repository}/commits/${branchName}`;
4+
}

tools/release/prompt/new-version-prompt.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export async function promptForNewVersion(currentVersion: Version): Promise<Vers
5050
message: 'Should this be a pre-release?',
5151
// Prompt whether this should a pre-release if the current release is not a pre-release
5252
when: !currentVersion.prereleaseLabel,
53+
default: false,
5354
}, {
5455
type: 'list',
5556
name: 'prereleaseLabel',

tools/release/stage-release.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {prompt} from 'inquirer';
55
import {join} from 'path';
66
import {promptAndGenerateChangelog} from './changelog';
77
import {GitClient} from './git/git-client';
8+
import {getGithubBranchCommitsUrl} from './git/github-urls';
89
import {promptForNewVersion} from './prompt/new-version-prompt';
910
import {parseVersionName, Version} from './version-name/parse-version';
1011
import {getExpectedPublishBranch} from './version-name/publish-branch';
@@ -93,7 +94,7 @@ class StageReleaseTask {
9394
this.switchToPublishBranch(expectedPublishBranch);
9495

9596
this.verifyLocalCommitsMatchUpstream(expectedPublishBranch);
96-
await this.verifyPassingGithubStatus();
97+
await this.verifyPassingGithubStatus(expectedPublishBranch);
9798

9899
const newVersionName = newVersion.format();
99100
const stagingBranch = `release-stage/${newVersionName}`;
@@ -195,8 +196,10 @@ class StageReleaseTask {
195196
}
196197

197198
/** Verifies that the latest commit of the current branch is passing all Github statuses. */
198-
private async verifyPassingGithubStatus() {
199+
private async verifyPassingGithubStatus(expectedPublishBranch: string) {
199200
const commitRef = this.git.getLocalCommitSha('HEAD');
201+
const githubCommitsUrl = getGithubBranchCommitsUrl(this.repositoryOwner, this.repositoryName,
202+
expectedPublishBranch);
200203
const {state} = (await this.githubApi.repos.getCombinedStatusForRef({
201204
owner: this.repositoryOwner,
202205
repo: this.repositoryName,
@@ -206,10 +209,12 @@ class StageReleaseTask {
206209
if (state === 'failure') {
207210
console.error(red(` ✘ Cannot stage release. Commit "${commitRef}" does not pass all ` +
208211
`github status checks. Please make sure this commit passes all checks before re-running.`));
212+
console.error(red(` Please have a look at: ${githubCommitsUrl}`));
209213
process.exit(1);
210214
} else if (state === 'pending') {
211215
console.error(red(` ✘ Cannot stage release yet. Commit "${commitRef}" still has ` +
212216
`pending github statuses that need to succeed before staging a release.`));
217+
console.error(red(` Please have a look at: ${githubCommitsUrl}`));
213218
process.exit(0);
214219
}
215220

0 commit comments

Comments
 (0)