vitest/scripts/publish-ci.ts
Vladimir 471cf97b0c
chore: always require curly braces (#5885)
Co-authored-by: Ari Perkkiö <ari.perkkio@gmail.com>
2024-06-16 18:10:10 +02:00

40 lines
923 B
TypeScript

#!/usr/bin/env zx
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { $ } from 'zx'
let version = process.argv[2]
if (!version) {
throw new Error('No tag specified')
}
if (version.startsWith('v')) {
version = version.slice(1)
}
const pkgPath = fileURLToPath(new URL('../package.json', import.meta.url))
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
if (pkg.version !== version) {
throw new Error(
`Package version from tag "${version}" mismatches with the current version "${pkg.version}"`,
)
}
const releaseTag = version.includes('beta')
? 'beta'
: version.includes('alpha')
? 'alpha'
: undefined
console.log('Publishing version', version, 'with tag', releaseTag || 'latest')
if (releaseTag) {
await $`pnpm -r publish --access public --no-git-checks --tag ${releaseTag}`
}
else {
await $`pnpm -r publish --access public --no-git-checks`
}