diff --git a/scripts/config.ts b/scripts/config.ts index 2101c34c2e..ccbe8660f9 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -77,8 +77,6 @@ export const packages: Package[] = [ }, ] -export const latestBranch = 'main' - export const branchConfigs: Record = { main: { prerelease: false, @@ -95,6 +93,10 @@ export const branchConfigs: Record = { rc: { prerelease: true, }, + v4: { + prerelease: false, + previousVersion: true, + }, } export const rootDir = path.resolve(__dirname, '..') diff --git a/scripts/publish.ts b/scripts/publish.ts index ef8178e146..0184105d7c 100644 --- a/scripts/publish.ts +++ b/scripts/publish.ts @@ -10,8 +10,8 @@ import log from 'git-log-parser' import streamToArray from 'stream-to-array' import axios from 'axios' import { DateTime } from 'luxon' -import { branchConfigs, latestBranch, packages, rootDir } from './config' -import type { BranchConfig, Commit, Package } from './types' +import { branchConfigs, packages, rootDir } from './config' +import type { BranchConfig, Commit } from './types' import type { PackageJson } from 'type-fest' @@ -22,8 +22,10 @@ async function run() { process.env.BRANCH ?? // (process.env.PR_NUMBER ? `pr-${process.env.PR_NUMBER}` : currentGitBranch()) currentGitBranch() + const branchConfig: BranchConfig | undefined = branchConfigs[branchName] const isMainBranch = branchName === 'main' + const isPreviousRelease = branchConfig?.previousVersion const npmTag = isMainBranch ? 'latest' : branchName // Get tags @@ -33,6 +35,10 @@ async function run() { tags = tags .filter((tag) => semver.valid(tag)) .filter((tag) => { + // If this is an older release, filter to only include that version + if (isPreviousRelease) { + return tag.startsWith(branchName) + } if (semver.prerelease(tag) === null) { return isMainBranch } else { @@ -286,8 +292,6 @@ async function run() { recommendedReleaseLevel = 0 } - const branchConfig: BranchConfig | undefined = branchConfigs[branchName] - if (!branchConfig) { console.log(`No publish config found for branch: ${branchName}`) console.log('Exiting...') @@ -405,7 +409,7 @@ async function run() { // Stringify the markdown to excape any quotes execSync( `gh release create v${version} ${ - !isMainBranch ? '--prerelease' : '' + branchConfig.prerelease ? '--prerelease' : '' } --notes '${changelogMd.replace(/'/g, '"')}'`, ) console.info(` Github release created.`) diff --git a/scripts/types.ts b/scripts/types.ts index b4c6f9edb9..3c2ab7a8ff 100644 --- a/scripts/types.ts +++ b/scripts/types.ts @@ -43,4 +43,5 @@ export type Package = { export type BranchConfig = { prerelease: boolean + previousVersion?: boolean }