@@ -3,12 +3,14 @@ import {execSync} from 'child_process';
3
3
import { readFileSync } from 'fs' ;
4
4
import { join } from 'path' ;
5
5
import { BaseReleaseTask } from './base-release-task' ;
6
+ import { extractReleaseNotes } from './extract-release-notes' ;
6
7
import { GitClient } from './git/git-client' ;
7
8
import { getGithubReleasesUrl } from './git/github-urls' ;
8
9
import { isNpmAuthenticated , runInteractiveNpmLogin , runNpmPublish } from './npm/npm-client' ;
9
10
import { promptForNpmDistTag } from './prompt/npm-dist-tag-prompt' ;
10
11
import { checkReleasePackage } from './release-output/check-packages' ;
11
12
import { releasePackages } from './release-output/release-packages' ;
13
+ import { CHANGELOG_FILE_NAME } from './stage-release' ;
12
14
import { parseVersionName , Version } from './version-name/parse-version' ;
13
15
14
16
/** Maximum allowed tries to authenticate NPM. */
@@ -88,8 +90,17 @@ class PublishReleaseTask extends BaseReleaseTask {
88
90
this . checkReleaseOutput ( ) ;
89
91
console . info ( green ( ` ✓ Release output passed validation checks.` ) ) ;
90
92
93
+ // Extract the release notes for the new version from the changelog file.
94
+ const releaseNotes = extractReleaseNotes (
95
+ join ( this . projectDir , CHANGELOG_FILE_NAME ) , newVersionName ) ;
96
+
97
+ if ( ! releaseNotes ) {
98
+ console . error ( red ( ` ✘ Could not find release notes in the changelog.` ) ) ;
99
+ process . exit ( 1 ) ;
100
+ }
101
+
91
102
// Create and push the release tag before publishing to NPM.
92
- this . createAndPushReleaseTag ( newVersionName ) ;
103
+ this . createAndPushReleaseTag ( newVersionName , releaseNotes ) ;
93
104
94
105
// Ensure that we are authenticated before running "npm publish" for each package.
95
106
this . checkNpmAuthentication ( ) ;
@@ -230,9 +241,9 @@ class PublishReleaseTask extends BaseReleaseTask {
230
241
}
231
242
232
243
/** Creates a specified tag and pushes it to the remote repository */
233
- private createAndPushReleaseTag ( tagName : string ) {
244
+ private createAndPushReleaseTag ( tagName : string , releaseNotes : string ) {
234
245
// TODO(devversion): find a way to extract the changelog part just for this version.
235
- if ( ! this . git . createTag ( 'HEAD' , tagName , '' ) ) {
246
+ if ( ! this . git . createTag ( 'HEAD' , tagName , releaseNotes ) ) {
236
247
console . error ( red ( ` ✘ Could not create the "${ tagName } " tag.` ) ) ;
237
248
console . error ( red ( ` Please make sure there is no existing tag with the same name.` ) ) ;
238
249
process . exit ( 1 ) ;
0 commit comments