Skip to content

Commit dcf1d9e

Browse files
committed
build: publish script should print a better URL for drafting the release
Currently when the publish script completes, the caretaker still needs to draft the release online in the GitHub UI. In order to make this easier for the caretaker, we generate an URL that automatically fills in the proper release tag and the release name. Note we can also look into attaching the release notes automatically, but since the release notes are making the URL too large and Github denies too large URL's, this is something we can explore in a follow-ups.
1 parent aa000eb commit dcf1d9e

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

tools/release/extract-release-notes.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ export function extractReleaseNotes(changelogPath: string, versionName: string)
1010
// section of a version by starting with the release header which can either use the markdown
1111
// "h1" or "h2" syntax. The end of the section will be matched by just looking for the first
1212
// subsequent release header.
13-
const releaseNotesRegex = new RegExp(`(##? ${escapedVersion}.*?)##? 7\\.`, 's');
13+
const releaseNotesRegex = new RegExp(`(##? ${escapedVersion} "(.*?)" \\(.*?)##? \\d+\\.\\d+`, 's');
1414
const matches = releaseNotesRegex.exec(changelogContent);
1515

16-
return matches ? matches[1].trim() : null;
16+
return matches ? {
17+
releaseTitle: matches[2],
18+
releaseNotes: matches[1].trim(),
19+
} : null;
1720
}

tools/release/git/github-urls.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ export function getGithubBranchCommitsUrl(owner: string, repository: string, bra
33
return `https://github.com/${owner}/${repository}/commits/${branchName}`;
44
}
55

6-
/** Gets a Github URL that refers list of releases within the specified repository. */
7-
export function getGithubReleasesUrl(owner: string, repository: string) {
8-
return `https://github.com/${owner}/${repository}/releases`;
6+
/** Gets a Github URL that can be used to create a new release from a given tag. */
7+
export function getGithubNewReleaseUrl(options: {owner: string, repository: string,
8+
tagName: string, releaseTitle: string}) {
9+
10+
return `https://github.com/${options.owner}/${options.repository}/releases/new?` +
11+
`tag=${encodeURIComponent(options.tagName)}&` +
12+
`title=${encodeURIComponent(options.releaseTitle)}&`;
913
}

tools/release/publish-release.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {BaseReleaseTask} from './base-release-task';
66
import {checkReleaseOutput} from './check-release-output';
77
import {extractReleaseNotes} from './extract-release-notes';
88
import {GitClient} from './git/git-client';
9-
import {getGithubReleasesUrl} from './git/github-urls';
9+
import {getGithubNewReleaseUrl} from './git/github-urls';
1010
import {isNpmAuthenticated, runInteractiveNpmLogin, runNpmPublish} from './npm/npm-client';
1111
import {promptForNpmDistTag} from './prompt/npm-dist-tag-prompt';
1212
import {releasePackages} from './release-output/release-packages';
@@ -91,7 +91,7 @@ class PublishReleaseTask extends BaseReleaseTask {
9191
checkReleaseOutput(this.releaseOutputPath);
9292

9393
// Extract the release notes for the new version from the changelog file.
94-
const releaseNotes = extractReleaseNotes(
94+
const {releaseNotes, releaseTitle} = extractReleaseNotes(
9595
join(this.projectDir, CHANGELOG_FILE_NAME), newVersionName);
9696

9797
if (!releaseNotes) {
@@ -114,11 +114,17 @@ class PublishReleaseTask extends BaseReleaseTask {
114114
this.publishPackageToNpm(packageName, npmDistTag);
115115
}
116116

117+
const newReleaseUrl = getGithubNewReleaseUrl({
118+
owner: this.repositoryOwner,
119+
repository: this.repositoryName,
120+
tagName: newVersionName,
121+
releaseTitle: releaseTitle,
122+
});
123+
117124
console.log();
118125
console.info(green(bold(` ✓ Published all packages successfully`)));
119126
console.info(yellow(` ⚠ Please draft a new release of the version on Github.`));
120-
console.info(yellow(
121-
` ${getGithubReleasesUrl(this.repositoryOwner, this.repositoryName)}`));
127+
console.info(yellow(` ${newReleaseUrl}`));
122128
}
123129

124130
/**

0 commit comments

Comments
 (0)