Skip to content

Commit

Permalink
Add npm release script to automatically create release PR (#1392)
Browse files Browse the repository at this point in the history
* Add release script

* nit
  • Loading branch information
huchenlei authored Oct 31, 2024
1 parent 0c8fe41 commit d11d073
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dev": "vite",
"build": "npm run typecheck && vite build",
"deploy": "npm run build && node scripts/deploy.js",
"release": "node scripts/release.js",
"zipdist": "node scripts/zipdist.js",
"typecheck": "tsc --noEmit && tsc-strict",
"format": "prettier --write './**/*.{js,ts,tsx,vue}'",
Expand Down
23 changes: 23 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit d11d073

Please sign in to comment.