@@ -270,8 +270,23 @@ async function main() {
270
270
271
271
// publish packages
272
272
step ( '\nPublishing packages...' )
273
+
274
+ const additionalPublishFlags = [ ]
275
+ if ( isDryRun ) {
276
+ additionalPublishFlags . push ( '--dry-run' )
277
+ }
278
+ if ( skipGit ) {
279
+ additionalPublishFlags . push ( '--no-git-checks' )
280
+ }
281
+ // bypass the pnpm --publish-branch restriction which isn't too useful to us
282
+ // otherwise it leads to a prompt and blocks the release script
283
+ const branch = await getBranch ( )
284
+ if ( branch !== 'main' ) {
285
+ additionalPublishFlags . push ( '--publish-branch' , branch )
286
+ }
287
+
273
288
for ( const pkg of packages ) {
274
- await publishPackage ( pkg , targetVersion )
289
+ await publishPackage ( pkg , targetVersion , additionalPublishFlags )
275
290
}
276
291
277
292
// push to GitHub
@@ -300,7 +315,7 @@ async function main() {
300
315
301
316
async function getCIResult ( ) {
302
317
try {
303
- const { stdout : sha } = await execa ( 'git' , [ 'rev-parse' , 'HEAD' ] )
318
+ const sha = await getSha ( )
304
319
const res = await fetch (
305
320
`https://api.github.com/repos/vuejs/core/actions/runs?head_sha=${ sha } ` +
306
321
`&status=success&exclude_pull_requests=true`
@@ -315,17 +330,12 @@ async function getCIResult() {
315
330
316
331
async function isInSyncWithRemote ( ) {
317
332
try {
318
- const { stdout : sha } = await execa ( 'git' , [ 'rev-parse' , 'HEAD' ] )
319
- const { stdout : branch } = await execa ( 'git' , [
320
- 'rev-parse' ,
321
- '--abbrev-ref' ,
322
- 'HEAD'
323
- ] )
333
+ const branch = await getBranch ( )
324
334
const res = await fetch (
325
335
`https://api.github.com/repos/vuejs/core/commits/${ branch } ?per_page=1`
326
336
)
327
337
const data = await res . json ( )
328
- return data . sha === sha
338
+ return data . sha === ( await getSha ( ) )
329
339
} catch ( e ) {
330
340
console . error (
331
341
'Failed to check whether local HEAD is up-to-date with remote.'
@@ -334,6 +344,14 @@ async function isInSyncWithRemote() {
334
344
}
335
345
}
336
346
347
+ async function getSha ( ) {
348
+ return ( await execa ( 'git' , [ 'rev-parse' , 'HEAD' ] ) ) . stdout
349
+ }
350
+
351
+ async function getBranch ( ) {
352
+ return ( await execa ( 'git' , [ 'rev-parse' , '--abbrev-ref' , 'HEAD' ] ) ) . stdout
353
+ }
354
+
337
355
function updateVersions ( version , getNewPackageName = keepThePackageName ) {
338
356
// 1. update root package.json
339
357
updatePackage ( path . resolve ( __dirname , '..' ) , version , getNewPackageName )
@@ -371,7 +389,7 @@ function updateDeps(pkg, depType, version, getNewPackageName) {
371
389
} )
372
390
}
373
391
374
- async function publishPackage ( pkgName , version ) {
392
+ async function publishPackage ( pkgName , version , additionalFlags ) {
375
393
if ( skippedPackages . includes ( pkgName ) ) {
376
394
return
377
395
}
@@ -402,8 +420,7 @@ async function publishPackage(pkgName, version) {
402
420
...( releaseTag ? [ '--tag' , releaseTag ] : [ ] ) ,
403
421
'--access' ,
404
422
'public' ,
405
- ...( isDryRun ? [ '--dry-run' ] : [ ] ) ,
406
- ...( skipGit ? [ '--no-git-checks' ] : [ ] )
423
+ ...additionalFlags
407
424
] ,
408
425
{
409
426
cwd : pkgRoot ,
0 commit comments