该篇文章实施应建立在规范化 commit msg 的基础上 规范 commit msg 详见之前的文章 《前端代码风格统一规范(项目依赖版)》
接入教程
安装依赖
yarn add standard-version -D
在 package.json 的 srcipt字段中添加
"release": "standard-version",

根目录创建.versionrc.js文件,例如:(详见 standard-version 官方文档)
module.exports = {
skip: {
tag: false, // 不跳过生成tag
},
//types为Conventional Commits标准中定义,目前支持
//https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
types: [
{ type: "feat", section: "新特性" },
{ type: "fix", section: "Bug修复" },
{ type: "docs", section: "文档" },
{ type: "chore", section: "配置项" },
{ type: "style", section: "格式" },
{ type: "refactor", section: "重构" },
{ type: "perf", section: "代码优化" },
{ type: "test", section: "测试", hidden: true },
{ type: "revert", section: "回滚", hidden: true },
],
//hash链接
commitUrlFormat:
"http://git.genecast.com.cn/{{owner}}/{{repository}}/commit/{{hash}}",
};
发布版本时执行yarn release即可
假设按照上图文件配置,将自动迭代版本号,生成 changelog 和 tag

额外话题
想要生成测试版本,即发布前的版本,可做下面配置
package.json 的 srcipt字段中添加
"release-beta": "standard-version -p release --skip.changelog false --skip.tag false",
将去迭代版本并在后缀加上 release.0 字样,但是不会生成 changelog 和 tags

交流与讨论
使用 GitHub 账号参与讨论,评论内容公开可见。
GitHub 讨论区 · 邮件联系