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

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
  }
}
相关推荐
lwx9148522 小时前
Linux-特殊权限SUID,SGID,SBIT
linux·运维·服务器
炘爚4 小时前
深入解析printf缓冲区与fork进程复制机制
linux·运维·算法
workflower4 小时前
注塑机行业目前自动化现状分析
运维·人工智能·语言模型·自动化·集成测试·软件工程·软件需求
小义_5 小时前
随笔 3(Linux)
linux·运维·服务器·云原生·红帽
#六脉神剑5 小时前
MySQL参数调优:十个关键参数助力数据库性能数倍提升
运维·mysql
cccccc语言我来了5 小时前
Linux(10)进程概念
linux·运维·服务器
伐尘5 小时前
【linux】查看空间(内存、磁盘、文件目录、分区)的几个命令
linux·运维·网络
笨笨饿6 小时前
30_泰勒级数
c语言·stm32·嵌入式硬件·线性代数·机器学习·自动化·概率论
倔强的胖蚂蚁6 小时前
x2openEuler 辅助机完整部署教程
运维·云原生
原来是猿6 小时前
Linux进程信号详解(二):信号产生
linux·运维·服务器