Skip to content

Commit b7e121b

Browse files
authored
chore(workflow): support alpha release (#8170)
1 parent 46d5e67 commit b7e121b

File tree

3 files changed

+60
-33
lines changed

3 files changed

+60
-33
lines changed

scripts/publishCI.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ async function main() {
2222
)
2323

2424
step('Publishing package...')
25-
await publishPackage(pkgDir, version.includes('beta') ? 'beta' : undefined)
25+
const releaseTag = version.includes('beta')
26+
? 'beta'
27+
: version.includes('alpha')
28+
? 'alpha'
29+
: undefined
30+
await publishPackage(pkgDir, releaseTag)
2631
}
2732

2833
main().catch((err) => {

scripts/release.ts

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ async function main(): Promise<void> {
6262
if (targetVersion.includes('beta') && !args.tag) {
6363
args.tag = 'beta'
6464
}
65+
if (targetVersion.includes('alpha') && !args.tag) {
66+
args.tag = 'alpha'
67+
}
6568

6669
const { yes }: { yes: boolean } = await prompts({
6770
type: 'confirm',

scripts/releaseUtils.ts

+51-32
Original file line numberDiff line numberDiff line change
@@ -94,42 +94,61 @@ export function step(msg: string) {
9494

9595
export function getVersionChoices(currentVersion: string) {
9696
const currentBeta = currentVersion.includes('beta')
97+
const currentAlpha = currentVersion.includes('alpha')
98+
const isStable = !currentBeta && !currentAlpha
9799

98-
const inc: (i: ReleaseType) => string = (i) =>
99-
semver.inc(currentVersion, i, 'beta')!
100+
function inc(i: ReleaseType, tag = currentAlpha ? 'alpha' : 'beta') {
101+
return semver.inc(currentVersion, i, tag)!
102+
}
100103

101-
const versionChoices = [
104+
let versionChoices = [
102105
{
103106
title: 'next',
104-
value: inc(currentBeta ? 'prerelease' : 'patch')
105-
},
106-
...(currentBeta
107-
? [
108-
{
109-
title: 'stable',
110-
value: inc('patch')
111-
}
112-
]
113-
: [
114-
{
115-
title: 'beta-minor',
116-
value: inc('preminor')
117-
},
118-
{
119-
title: 'beta-major',
120-
value: inc('premajor')
121-
},
122-
{
123-
title: 'minor',
124-
value: inc('minor')
125-
},
126-
{
127-
title: 'major',
128-
value: inc('major')
129-
}
130-
]),
131-
{ value: 'custom', title: 'custom' }
132-
].map((i) => {
107+
value: inc(isStable ? 'patch' : 'prerelease')
108+
}
109+
]
110+
111+
if (isStable) {
112+
versionChoices.push(
113+
{
114+
title: 'beta-minor',
115+
value: inc('preminor')
116+
},
117+
{
118+
title: 'beta-major',
119+
value: inc('premajor')
120+
},
121+
{
122+
title: 'alpha-minor',
123+
value: inc('preminor', 'alpha')
124+
},
125+
{
126+
title: 'alpha-major',
127+
value: inc('premajor', 'alpha')
128+
},
129+
{
130+
title: 'minor',
131+
value: inc('minor')
132+
},
133+
{
134+
title: 'major',
135+
value: inc('major')
136+
}
137+
)
138+
} else if (currentAlpha) {
139+
versionChoices.push({
140+
title: 'beta',
141+
value: inc('patch') + '-beta.0'
142+
})
143+
} else {
144+
versionChoices.push({
145+
title: 'stable',
146+
value: inc('patch')
147+
})
148+
}
149+
versionChoices.push({ value: 'custom', title: 'custom' })
150+
151+
versionChoices = versionChoices.map((i) => {
133152
i.title = `${i.title} (${i.value})`
134153
return i
135154
})

0 commit comments

Comments
 (0)