Skip to content

Commit acc8ac8

Browse files
committed
chore: fix publish script for v4
1 parent 01436d4 commit acc8ac8

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

scripts/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ export const packages: Package[] = [
7777
},
7878
]
7979

80-
export const latestBranch = 'main'
81-
8280
export const branchConfigs: Record<string, BranchConfig> = {
8381
main: {
8482
prerelease: false,
@@ -95,6 +93,10 @@ export const branchConfigs: Record<string, BranchConfig> = {
9593
rc: {
9694
prerelease: true,
9795
},
96+
v4: {
97+
prerelease: false,
98+
previousVersion: true,
99+
},
98100
}
99101

100102
export const rootDir = path.resolve(__dirname, '..')

scripts/publish.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import log from 'git-log-parser'
1010
import streamToArray from 'stream-to-array'
1111
import axios from 'axios'
1212
import { DateTime } from 'luxon'
13-
import { branchConfigs, latestBranch, packages, rootDir } from './config'
14-
import type { BranchConfig, Commit, Package } from './types'
13+
import { branchConfigs, packages, rootDir } from './config'
14+
import type { BranchConfig, Commit } from './types'
1515

1616
import type { PackageJson } from 'type-fest'
1717

@@ -22,8 +22,10 @@ async function run() {
2222
process.env.BRANCH ??
2323
// (process.env.PR_NUMBER ? `pr-${process.env.PR_NUMBER}` : currentGitBranch())
2424
currentGitBranch()
25+
const branchConfig: BranchConfig | undefined = branchConfigs[branchName]
2526

2627
const isMainBranch = branchName === 'main'
28+
const isPreviousRelease = branchConfig?.previousVersion
2729
const npmTag = isMainBranch ? 'latest' : branchName
2830

2931
// Get tags
@@ -33,6 +35,10 @@ async function run() {
3335
tags = tags
3436
.filter((tag) => semver.valid(tag))
3537
.filter((tag) => {
38+
// If this is an older release, filter to only include that version
39+
if (isPreviousRelease) {
40+
return tag.startsWith(branchName)
41+
}
3642
if (semver.prerelease(tag) === null) {
3743
return isMainBranch
3844
} else {
@@ -286,8 +292,6 @@ async function run() {
286292
recommendedReleaseLevel = 0
287293
}
288294

289-
const branchConfig: BranchConfig | undefined = branchConfigs[branchName]
290-
291295
if (!branchConfig) {
292296
console.log(`No publish config found for branch: ${branchName}`)
293297
console.log('Exiting...')
@@ -405,7 +409,7 @@ async function run() {
405409
// Stringify the markdown to excape any quotes
406410
execSync(
407411
`gh release create v${version} ${
408-
!isMainBranch ? '--prerelease' : ''
412+
branchConfig.prerelease ? '--prerelease' : ''
409413
} --notes '${changelogMd.replace(/'/g, '"')}'`,
410414
)
411415
console.info(` Github release created.`)

scripts/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ export type Package = {
4343

4444
export type BranchConfig = {
4545
prerelease: boolean
46+
previousVersion?: boolean
4647
}

0 commit comments

Comments
 (0)