Skip to content

Commit

Permalink
ci: require explicit --latest flag for stable release
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Nov 6, 2024
1 parent a9f9a60 commit 5a14cdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 12 additions & 5 deletions scripts/versions/ci-publish.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mri from 'mri'
import { publishVersion } from './src/publishVersion'
import { publishVersion, VALID_TAGS } from './src/publishVersion'

main()

Expand All @@ -25,17 +25,24 @@ function parseArgs() {

const argv = mri(process.argv.slice(2), {
boolean: ['no-push'],
string: ['tag'],
string: ['tag', 'latest'],
})

if (argv.tag && argv.tag !== 'beta' && argv.tag !== 'next') {
console.error('Error: --tag must be beta or next')
if (argv.latest && argv.tag) {
console.error('Error: --latest and --tag cannot be specified together')
process.exit(1)
}

if (!argv.latest && !VALID_TAGS.includes(argv.tag)) {
console.error(
`Error: --tag must be one of [${VALID_TAGS.join(', ')}] or --latest must be specified instead`,
)
process.exit(1)
}

return {
push: !argv['no-push'],
tag: argv.tag as 'beta' | 'next',
tag: argv.tag as (typeof VALID_TAGS)[number],
gitCliffToken,
npmToken,
radashiBotToken,
Expand Down
4 changes: 3 additions & 1 deletion scripts/versions/src/publishVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import { trackVersion } from './trackVersion'
// This is the commit that Radashi's changelog is based on.
const changelogBaseSha = '2be4acf455ebec86e846854dbab57bd0bfbbceb7'

export const VALID_TAGS = ['beta', 'next'] as const

export async function publishVersion(args: {
/**
* Use "beta" for pre-release minor/patch versions and "next" for
* pre-release major versions.
*/
tag?: 'beta' | 'next'
tag?: (typeof VALID_TAGS)[number]
push: boolean
gitCliffToken?: string
npmToken?: string
Expand Down

0 comments on commit 5a14cdd

Please sign in to comment.