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

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
  }
}
相关推荐
bellus-6 分钟前
win11使用ubuntu 26.04
linux·运维·ubuntu
HAHAXX81 小时前
ChatGPT 4o + RPA 自动化工具:一站式业务流程开发实战指南
chatgpt·自动化·rpa
略略略咯咯1 小时前
centos更换镜像源
linux·运维·centos
IKUN家族1 小时前
Spring MVC(三)
运维·服务器·spring boot·spring·servlet·java-ee
Leon-Ning Liu2 小时前
【真实经验分享】ORA-12516 排查实录:共享服务器模式下 SHARED_SERVER_SESSIONS 不足引发的监听故障
运维·服务器·oracle
运维大师2 小时前
【K8S 运维实战】34-多集群管理Karmada
java·运维·kubernetes
东方护航数据恢复(深圳)2 小时前
服务器硬盘黄灯/红灯故障排查与处理命令全指南_东方护航数据恢复深圳店
运维·服务器·chrome
爱码少年2 小时前
SSH密钥登录完整流程与原理详解
运维·ssh
枳实-叶2 小时前
Linux 环境下段错误出现的原因及调试方法
linux·运维·服务器
Chief_fly3 小时前
ARM 麒麟系统服务器构建docker镜像
运维·服务器·docker