1. 安装standard-version或conventional-changelog工具:
npm install --save-dev standard-version@9.5.0
2. 在package.json中添加版本管理脚本release命令:
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build && electron-builder",
"preview": "vite preview",
"release": "standard-version"//新增
},
3. 创建.versionrc配置文件定义提交规范:
//.versionrc
{
"types": [
{"type": "feat", "section": "Features"},
{"type": "fix", "section": "Bug Fixes"},
{"type": "chore", "hidden": true},
{"type": "docs", "section": "Documentation"},
{"type": "style", "hidden": true},
{"type": "refactor", "section": "Code Refactoring"},
{"type": "perf", "section": "Performance Improvements"},
{"type": "test", "hidden": true}
],
"commitUrlFormat": "https://github.com/electron-vite/electron-vite-vue/commit/{{hash}}",
"issueUrlFormat": "https://github.com/electron-vite/electron-vite-vue/issues/{{id}}"
}
使用方法:
1. 按约定格式提交代码(如:git commit -m "feat: 添加新功能")
2. 执行 npm run release 自动生成版本号和更新日志
3. 查看CHANGELOG.md文件中的自动更新内容