Add release script (#252)

This commit is contained in:
Chenlei Hu
2024-10-31 21:56:26 -04:00
committed by GitHub
parent 020c912a8d
commit ca5a4f37c6
2 changed files with 24 additions and 0 deletions

View File

@@ -23,6 +23,7 @@
"build": "tsc && vite build",
"dev": "vite",
"preview": "vite preview",
"release": "node scripts/release.js",
"test": "jest",
"deprecated-test:allVersions": "./utils/test.sh",
"deprecated-prettier": "npx prettier --write src/**/*.* css/**/*.*",

23
scripts/release.js Normal file
View File

@@ -0,0 +1,23 @@
import { execSync } from 'child_process'
import { readFileSync } from 'fs'
try {
// Run npm version patch and capture the output
console.log('Bumping version...')
execSync('npm version patch', { stdio: 'inherit' })
// Read the new version from package.json
const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'))
const newVersion = packageJson.version
// Create the PR
console.log('Creating PR...')
execSync(
`gh pr create --title "${newVersion}" --label "Release" --body "Automated version bump to ${newVersion}"`,
{ stdio: 'inherit' }
)
console.log(`✅ Successfully created PR for version ${newVersion}`)
} catch (error) {
console.error('❌ Error during release process:', error.message)
}