1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/usr/bin/env node
- import { execSync } from 'child_process'
- import inquirer from 'inquirer'
- function run(cmd) {
- execSync(cmd, { stdio: 'inherit' })
- }
- async function main() {
- console.log('🚀 开始发布流程...')
- // 1. 选择版本类型
- const { versionType } = await inquirer.prompt([
- {
- type: 'list',
- name: 'versionType',
- message: '请选择版本类型:',
- choices: [
- { name: '补丁版本 (patch)', value: 'patch' },
- { name: '小版本 (minor)', value: 'minor' },
- { name: '大版本 (major)', value: 'major' },
- ],
- },
- ])
- // 2. 全量生成 changelog
- console.log('📝 正在全量生成 changelog...')
- run('npx conventional-changelog -p angular -i CHANGELOG.md -s -r 0')
- // 3. 自动提交 changelog
- run('git add CHANGELOG.md')
- run('git commit -m "chore: update changelog"')
- // 4. 更新版本号
- run(`npm version ${versionType} -m "new version published: v%s"`)
- // 5. 推送代码 & tag
- run('git push')
- run('git push --tags')
- console.log('✅ 发布完成!')
- }
- main()
|