| 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. 先更新版本号(生成新 tag)
- run(`npm version ${versionType} -m "new version published: v%s"`)
- // 3. 全量生成 changelog(覆盖原文件)
- console.log('📝 正在全量生成 changelog...')
- run('npx conventional-changelog -p angular -i CHANGELOG.md -s -r 0')
- // 4. 自动提交 changelog
- run('git add CHANGELOG.md')
- run('git commit --amend --no-edit') // 直接加到刚才的版本提交里
- // 5. 推送代码 & tag(tag 不变,提交更新了)
- run('git push --force-with-lease')
- run('git push --tags')
- console.log('✅ 发布完成!')
- }
- main()
|