@@ -18,16 +18,16 @@ import type { PackageJson } from 'type-fest'
18
18
const releaseCommitMsg = ( version : string ) => `release: v${ version } `
19
19
20
20
async function run ( ) {
21
- const branchName : string =
22
- process . env . BRANCH ??
23
- // (process.env.PR_NUMBER ? `pr-${process.env.PR_NUMBER}` : currentGitBranch())
24
- currentGitBranch ( )
25
- const branchConfig : BranchConfig | undefined = branchConfigs [ branchName ]
26
-
21
+ const branchName : string = process . env . BRANCH ?? currentGitBranch ( )
27
22
const isMainBranch = branchName === 'main'
28
- const isPreviousRelease = branchConfig ?. previousVersion
29
23
const npmTag = isMainBranch ? 'latest' : branchName
30
24
25
+ const branchConfig : BranchConfig | undefined = branchConfigs [ branchName ]
26
+
27
+ if ( ! branchConfig ) {
28
+ throw new Error ( `No publish config found for branch: ${ branchName } ` )
29
+ }
30
+
31
31
// Get tags
32
32
let tags : string [ ] = execSync ( 'git tag' ) . toString ( ) . split ( '\n' )
33
33
@@ -36,7 +36,7 @@ async function run() {
36
36
. filter ( ( tag ) => semver . valid ( tag ) )
37
37
. filter ( ( tag ) => {
38
38
// If this is an older release, filter to only include that version
39
- if ( isPreviousRelease ) {
39
+ if ( branchConfig . previousVersion ) {
40
40
return tag . startsWith ( branchName )
41
41
}
42
42
if ( semver . prerelease ( tag ) === null ) {
@@ -292,12 +292,6 @@ async function run() {
292
292
recommendedReleaseLevel = 0
293
293
}
294
294
295
- if ( ! branchConfig ) {
296
- console . log ( `No publish config found for branch: ${ branchName } ` )
297
- console . log ( 'Exiting...' )
298
- process . exit ( 0 )
299
- }
300
-
301
295
const releaseType = branchConfig . prerelease
302
296
? 'prerelease'
303
297
: ( { 0 : 'patch' , 1 : 'minor' , 2 : 'major' } as const ) [ recommendedReleaseLevel ]
@@ -371,14 +365,14 @@ async function run() {
371
365
}
372
366
373
367
console . info ( )
374
- console . info ( `Publishing all packages to npm` )
368
+ console . info ( `Publishing all packages to npm with tag " ${ npmTag } " ` )
375
369
376
370
// Publish each package
377
371
changedPackages . forEach ( ( pkg ) => {
378
372
const packageDir = path . join ( rootDir , 'packages' , pkg . packageDir )
379
- const tagParam = branchConfig . previousVersion ? `` : `--tag ${ npmTag } `
380
- const cmd = `cd ${ packageDir } && pnpm publish ${ tagParam } --access=public --no-git-checks`
381
- console . info ( ` Publishing ${ pkg . name } @${ version } to npm " ${ tagParam } " ...` )
373
+
374
+ const cmd = `cd ${ packageDir } && pnpm publish --tag ${ npmTag } --access=public --no-git-checks`
375
+ console . info ( ` Publishing ${ pkg . name } @${ version } to npm...` )
382
376
execSync ( cmd , {
383
377
stdio : [ process . stdin , process . stdout , process . stderr ] ,
384
378
} )
0 commit comments