@@ -18,16 +18,16 @@ import type { PackageJson } from 'type-fest'
1818const releaseCommitMsg = ( version : string ) => `release: v${ version } `
1919
2020async 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 ( )
2722 const isMainBranch = branchName === 'main'
28- const isPreviousRelease = branchConfig ?. previousVersion
2923 const npmTag = isMainBranch ? 'latest' : branchName
3024
25+ const branchConfig : BranchConfig | undefined = branchConfigs [ branchName ]
26+
27+ if ( ! branchConfig ) {
28+ throw new Error ( `No publish config found for branch: ${ branchName } ` )
29+ }
30+
3131 // Get tags
3232 let tags : string [ ] = execSync ( 'git tag' ) . toString ( ) . split ( '\n' )
3333
@@ -36,7 +36,7 @@ async function run() {
3636 . filter ( ( tag ) => semver . valid ( tag ) )
3737 . filter ( ( tag ) => {
3838 // If this is an older release, filter to only include that version
39- if ( isPreviousRelease ) {
39+ if ( branchConfig . previousVersion ) {
4040 return tag . startsWith ( branchName )
4141 }
4242 if ( semver . prerelease ( tag ) === null ) {
@@ -292,12 +292,6 @@ async function run() {
292292 recommendedReleaseLevel = 0
293293 }
294294
295- if ( ! branchConfig ) {
296- console . log ( `No publish config found for branch: ${ branchName } ` )
297- console . log ( 'Exiting...' )
298- process . exit ( 0 )
299- }
300-
301295 const releaseType = branchConfig . prerelease
302296 ? 'prerelease'
303297 : ( { 0 : 'patch' , 1 : 'minor' , 2 : 'major' } as const ) [ recommendedReleaseLevel ]
@@ -371,14 +365,14 @@ async function run() {
371365 }
372366
373367 console . info ( )
374- console . info ( `Publishing all packages to npm` )
368+ console . info ( `Publishing all packages to npm with tag " ${ npmTag } " ` )
375369
376370 // Publish each package
377371 changedPackages . forEach ( ( pkg ) => {
378372 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...` )
382376 execSync ( cmd , {
383377 stdio : [ process . stdin , process . stdout , process . stderr ] ,
384378 } )
0 commit comments