Skip to content

Commit d11d073

Browse files
authored
Add npm release script to automatically create release PR (#1392)
* Add release script * nit
1 parent 0c8fe41 commit d11d073

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"dev": "vite",
88
"build": "npm run typecheck && vite build",
99
"deploy": "npm run build && node scripts/deploy.js",
10+
"release": "node scripts/release.js",
1011
"zipdist": "node scripts/zipdist.js",
1112
"typecheck": "tsc --noEmit && tsc-strict",
1213
"format": "prettier --write './**/*.{js,ts,tsx,vue}'",

scripts/release.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { execSync } from 'child_process'
2+
import { readFileSync } from 'fs'
3+
4+
try {
5+
// Run npm version patch and capture the output
6+
console.log('Bumping version...')
7+
execSync('npm version patch', { stdio: 'inherit' })
8+
9+
// Read the new version from package.json
10+
const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'))
11+
const newVersion = packageJson.version
12+
13+
// Create the PR
14+
console.log('Creating PR...')
15+
execSync(
16+
`gh pr create --title "${newVersion}" --label "Release" --body "Automated version bump to ${newVersion}"`,
17+
{ stdio: 'inherit' }
18+
)
19+
20+
console.log(`✅ Successfully created PR for version ${newVersion}`)
21+
} catch (error) {
22+
console.error('❌ Error during release process:', error.message)
23+
}

0 commit comments

Comments
 (0)