release.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env node
  2. import { execSync } from 'child_process'
  3. import inquirer from 'inquirer'
  4. function run(cmd) {
  5. execSync(cmd, { stdio: 'inherit' })
  6. }
  7. async function main() {
  8. console.log('🚀 开始发布流程...')
  9. // 1. 选择版本类型
  10. const { versionType } = await inquirer.prompt([
  11. {
  12. type: 'list',
  13. name: 'versionType',
  14. message: '请选择版本类型:',
  15. choices: [
  16. { name: '补丁版本 (patch)', value: 'patch' },
  17. { name: '小版本 (minor)', value: 'minor' },
  18. { name: '大版本 (major)', value: 'major' },
  19. ],
  20. },
  21. ])
  22. // 2. 全量生成 changelog
  23. console.log('📝 正在全量生成 changelog...')
  24. run('npx conventional-changelog -p angular -i CHANGELOG.md -s -r 0')
  25. // 3. 自动提交 changelog
  26. run('git add CHANGELOG.md')
  27. run('git commit -m "chore: update changelog"')
  28. // 4. 更新版本号
  29. run(`npm version ${versionType} -m "new version published: v%s"`)
  30. // 5. 推送代码 & tag
  31. run('git push')
  32. run('git push --tags')
  33. console.log('✅ 发布完成!')
  34. }
  35. main()