发布版本自动化记录版本功能方法

bash 复制代码
# 安装commitizen

npm install --save-dev commitizen

# 初始化Conventional Commits规范适配器

npx commitizen init cz-conventional-changelog --save-dev --save-exact

最后一步,需要在package.json中添加一个script

"scripts": {
    ..., // 此处省略其它配置
    "commit": "cz"
}
bash 复制代码
此时你的package.json应该是这样的:
{
  "name": "changelog",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "commit": "cz"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "commitizen": "^4.2.4",
    "cz-conventional-changelog": "^3.3.0"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  }
}

使用release-it自动生成变更日志
安装release-it:

npm init release-it

bash 复制代码
 当前不需要在npm进行发布,因此需要在.release-it.json中添加下面的配置,禁用npm发布:
"npm": {
  "publish": false
}

为了兼容当前的提交信息格式,还需要执行下面的指令安装一个插件:

npm install @release-it/conventional-changelog --save-dev

如果想使用angular默认的changelog生成规范,只需要进行下面的配置就可以了:

创建.release-it.json

bash 复制代码
{
  "plugins": {
    "@release-it/conventional-changelog": {
      "infile": "CHANGELOG.md",
      "ignoreRecommendedBump": true,
      "strictSemVer": true,
      "preset": {
        "name": "conventionalcommits",
        "types": [
          { "type": "feat", "section": "功能" },
          { "type": "fix", "section": "修复BUG" },
          { "type": "docs", "section": "文档" },
          { "type": "style", "section": "样式" },
          { "type": "refactor", "section": "重构" },
          { "type": "perf", "section": "性能优化" },
          { "type": "test", "section": "测试" }
        ]
      }
    }
  },
  "git": {
    "commitMessage": "版本号 v${version}",
    "commit": true,
    "tag": true,
    "push": true
  },
  "npm": {
    "publish": false
  }
}
相关推荐
XMAIPC_Robot1 小时前
基于ARM+FPGA的光栅尺精密位移加速度测试解决方案
arm开发·人工智能·fpga开发·自动化·边缘计算
还是奇怪2 小时前
Linux - 安全排查 2
linux·运维·安全
牛奶咖啡132 小时前
Linux系统的常用操作命令——文件远程传输、文件编辑、软件安装的四种方式
运维·服务器·软件安装·linux云计算·scp文件远程传输·vi文件编辑·设置yum的阿里云源
难受啊马飞2.02 小时前
如何判断 AI 将优先自动化哪些任务?
运维·人工智能·ai·语言模型·程序员·大模型·大模型学习
会又不会2 小时前
Jenkins-Email Extension 插件插件
运维·jenkins
电脑能手3 小时前
[保姆级教程] 解决不同局域网电脑无法SSH的问题
运维·ssh·电脑
czhc11400756633 小时前
Linux 76 rsync
linux·运维·python
你不知道我是谁?4 小时前
负载均衡--四层、七层负载均衡的区别
运维·服务器·负载均衡
dyj0955 小时前
【Rancher Server + Kubernets】- Nginx-ingress日志持久化至宿主机
运维·nginx·rancher
码出钞能力6 小时前
linux内核模块的查看
linux·运维·服务器