@@ -88,9 +88,8 @@ class PublishReleaseTask extends BaseReleaseTask {
88
88
this . checkReleaseOutput ( ) ;
89
89
console . info ( green ( ` ✓ Release output passed validation checks.` ) ) ;
90
90
91
- // TODO(devversion): find a way to extract the changelog part just for this version.
92
- this . git . createTag ( 'HEAD' , newVersionName , '' ) ;
93
- console . info ( green ( ` ✓ Created release tag: "${ italic ( newVersionName ) } "` ) ) ;
91
+ // Create and push the release tag before publishing to NPM.
92
+ this . createAndPushReleaseTag ( newVersionName ) ;
94
93
95
94
// Ensure that we are authenticated before running "npm publish" for each package.
96
95
this . checkNpmAuthentication ( ) ;
@@ -105,8 +104,7 @@ class PublishReleaseTask extends BaseReleaseTask {
105
104
106
105
console . log ( ) ;
107
106
console . info ( green ( bold ( ` ✓ Published all packages successfully` ) ) ) ;
108
- console . info ( yellow ( ` ⚠ Please push the newly created tag to Github and draft a new ` +
109
- `release.` ) ) ;
107
+ console . info ( yellow ( ` ⚠ Please draft a new release of the version on Github.` ) ) ;
110
108
console . info ( yellow (
111
109
` ${ getGithubReleasesUrl ( this . repositoryOwner , this . repositoryName ) } ` ) ) ;
112
110
}
@@ -230,6 +228,27 @@ class PublishReleaseTask extends BaseReleaseTask {
230
228
231
229
console . info ( green ( ` ✓ Successfully published "${ packageName } "` ) ) ;
232
230
}
231
+
232
+ /** Creates a specified tag and pushes it to the remote repository */
233
+ private createAndPushReleaseTag ( tagName : string ) {
234
+ // TODO(devversion): find a way to extract the changelog part just for this version.
235
+ if ( ! this . git . createTag ( 'HEAD' , tagName , '' ) ) {
236
+ console . error ( red ( ` ✘ Could not create the "${ tagName } " tag.` ) ) ;
237
+ console . error ( red ( ` Please make sure there is no existing tag with the same name.` ) ) ;
238
+ process . exit ( 1 ) ;
239
+ }
240
+
241
+ console . info ( green ( ` ✓ Created release tag: "${ italic ( tagName ) } "` ) ) ;
242
+
243
+ if ( ! this . git . pushTagToRemote ( tagName ) ) {
244
+ console . error ( red ( ` ✘ Could not push the "${ tagName } "tag upstream.` ) ) ;
245
+ console . error ( red ( ` Please make sure you have permission to push to the ` +
246
+ `"${ this . git . remoteGitUrl } " remote.` ) ) ;
247
+ process . exit ( 1 ) ;
248
+ }
249
+
250
+ console . info ( green ( ` ✓ Pushed release tag upstream.` ) ) ;
251
+ }
233
252
}
234
253
235
254
/** Entry-point for the create release script. */
0 commit comments