standard-version可以进行版本自动化,以及生成CHANGELOG.md,使用git tag 也会自动更新package.json的version版本。
安装
npm i standard-version -D
在 package.json 中编写响应的脚本:
"scripts": {
"release": "standard-version"
},
CHANGELOG.md配置
新建.versionrc
{
"types": [
{"type": "chore", "section":"'🎫 Chores | 其他更新", "hidden": false},
{"type": "revert", "section":"⏪ Reverts | 回退", "hidden": false},
{"type": "feat", "section": "✨ Features | 新功能", "hidden": false},
{"type": "fix", "section": "🐛 Bug Fixes | Bug 修复", "hidden": false},
{"type": "improvement", "section": "Feature Improvements", "hidden": false},
{"type": "docs", "section":"📝 Documentation | 文档", "hidden": false},
{"type": "style", "section":"💄 Styles | 风格", "hidden": false},
{"type": "refactor", "section":"💄 Styles | 风格", "hidden": false},
{"type": "perf", "section":"⚡ Performance Improvements | 性能优化", "hidden": false},
{"type": "test", "section":"✅ Tests | 测试", "hidden": false},
{"type": "build", "section":"👷 Build System | 构建", "hidden": false},
{"type": "ci", "section":"🔧 Continuous Integration | CI 配置", "hidden":false}
]
}
执行:
1、git add
2、git commit
3、npm run release
4、git push
PS:也可以配合GITHUBS ACTIONS 去使用
gitlab.yml如下
PR到master时会执行
也可以执行npm run pubilsh发布到npm