@@ -10,8 +10,8 @@ import log from 'git-log-parser'
10
10
import streamToArray from 'stream-to-array'
11
11
import axios from 'axios'
12
12
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'
15
15
16
16
import type { PackageJson } from 'type-fest'
17
17
@@ -22,8 +22,10 @@ async function run() {
22
22
process . env . BRANCH ??
23
23
// (process.env.PR_NUMBER ? `pr-${process.env.PR_NUMBER}` : currentGitBranch())
24
24
currentGitBranch ( )
25
+ const branchConfig : BranchConfig | undefined = branchConfigs [ branchName ]
25
26
26
27
const isMainBranch = branchName === 'main'
28
+ const isPreviousRelease = branchConfig ?. previousVersion
27
29
const npmTag = isMainBranch ? 'latest' : branchName
28
30
29
31
// Get tags
@@ -33,6 +35,10 @@ async function run() {
33
35
tags = tags
34
36
. filter ( ( tag ) => semver . valid ( tag ) )
35
37
. filter ( ( tag ) => {
38
+ // If this is an older release, filter to only include that version
39
+ if ( isPreviousRelease ) {
40
+ return tag . startsWith ( branchName )
41
+ }
36
42
if ( semver . prerelease ( tag ) === null ) {
37
43
return isMainBranch
38
44
} else {
@@ -286,8 +292,6 @@ async function run() {
286
292
recommendedReleaseLevel = 0
287
293
}
288
294
289
- const branchConfig : BranchConfig | undefined = branchConfigs [ branchName ]
290
-
291
295
if ( ! branchConfig ) {
292
296
console . log ( `No publish config found for branch: ${ branchName } ` )
293
297
console . log ( 'Exiting...' )
@@ -405,7 +409,7 @@ async function run() {
405
409
// Stringify the markdown to excape any quotes
406
410
execSync (
407
411
`gh release create v${ version } ${
408
- ! isMainBranch ? '--prerelease' : ''
412
+ branchConfig . prerelease ? '--prerelease' : ''
409
413
} --notes '${ changelogMd . replace ( / ' / g, '"' ) } '`,
410
414
)
411
415
console . info ( ` Github release created.` )
0 commit comments