@@ -9,6 +9,7 @@ import {GitClient} from './git/git-client';
9
9
import { getGithubNewReleaseUrl } from './git/github-urls' ;
10
10
import { isNpmAuthenticated , runInteractiveNpmLogin , runNpmPublish } from './npm/npm-client' ;
11
11
import { promptForNpmDistTag } from './prompt/npm-dist-tag-prompt' ;
12
+ import { promptForUpstreamRemote } from './prompt/upstream-remote-prompt' ;
12
13
import { releasePackages } from './release-output/release-packages' ;
13
14
import { CHANGELOG_FILE_NAME } from './stage-release' ;
14
15
import { parseVersionName , Version } from './version-name/parse-version' ;
@@ -76,6 +77,7 @@ class PublishReleaseTask extends BaseReleaseTask {
76
77
this . verifyLastCommitVersionBump ( ) ;
77
78
this . verifyLocalCommitsMatchUpstream ( publishBranch ) ;
78
79
80
+ const upstreamRemote = await this . getProjectUpstreamRemote ( ) ;
79
81
const npmDistTag = await promptForNpmDistTag ( newVersion ) ;
80
82
81
83
// In case the user wants to publish a stable version to the "next" npm tag, we want
@@ -101,7 +103,7 @@ class PublishReleaseTask extends BaseReleaseTask {
101
103
102
104
// Create and push the release tag before publishing to NPM.
103
105
this . createReleaseTag ( newVersionName , releaseNotes ) ;
104
- this . pushReleaseTag ( newVersionName ) ;
106
+ this . pushReleaseTag ( newVersionName , upstreamRemote ) ;
105
107
106
108
// Ensure that we are authenticated before running "npm publish" for each package.
107
109
this . checkNpmAuthentication ( ) ;
@@ -250,7 +252,7 @@ class PublishReleaseTask extends BaseReleaseTask {
250
252
}
251
253
252
254
/** Pushes the release tag to the remote repository. */
253
- private pushReleaseTag ( tagName : string ) {
255
+ private pushReleaseTag ( tagName : string , upstreamRemote : string ) {
254
256
const remoteTagSha = this . git . getShaOfRemoteTag ( tagName ) ;
255
257
const expectedSha = this . git . getLocalCommitSha ( 'HEAD' ) ;
256
258
@@ -267,15 +269,27 @@ class PublishReleaseTask extends BaseReleaseTask {
267
269
return ;
268
270
}
269
271
270
- if ( ! this . git . pushTagToRemote ( tagName ) ) {
271
- console . error ( red ( ` ✘ Could not push the "${ tagName } " tag upstream.` ) ) ;
272
+ if ( ! this . git . pushTagToRemote ( tagName , upstreamRemote ) ) {
273
+ console . error ( red ( ` ✘ Could not push the "${ tagName } " tag upstream.` ) ) ;
272
274
console . error ( red ( ` Please make sure you have permission to push to the ` +
273
275
`"${ this . git . remoteGitUrl } " remote.` ) ) ;
274
276
process . exit ( 1 ) ;
275
277
}
276
278
277
279
console . info ( green ( ` ✓ Pushed release tag upstream.` ) ) ;
278
280
}
281
+
282
+ /**
283
+ * Determines the name of the Git remote that is used for pushing changes
284
+ * upstream to github.
285
+ */
286
+ private async getProjectUpstreamRemote ( ) {
287
+ const remoteName = this . git . hasRemote ( 'upstream' ) ?
288
+ 'upstream' : await promptForUpstreamRemote ( this . git . getAvailableRemotes ( ) ) ;
289
+
290
+ console . info ( green ( ` ✓ Using the "${ remoteName } " remote for pushing changes upstream.` ) ) ;
291
+ return remoteName ;
292
+ }
279
293
}
280
294
281
295
/** Entry-point for the create release script. */
0 commit comments