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

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
  }
}
相关推荐
ruxshui8 分钟前
# Linux diff命令使用
linux·运维·服务器
Sheffield9 分钟前
为什么大家都用iptables,不愿碰原生firewalld?
linux·运维·安全
何中应16 分钟前
Jenkins构建完,jar包启动不起来?
linux·运维·jenkins
柏木乃一17 分钟前
Linux进程信号(1):信号概述,信号产生part 1
linux·运维·服务器·c++·信号·signal
暴力求解25 分钟前
Linux---进程(一):初识进程
linux·运维·服务器
香蕉你个不拿拿^38 分钟前
Linux中make和makefile基本使用
linux·运维·服务器
袁袁袁袁满44 分钟前
Linux怎么创建Shell脚本.sh文件
linux·运维·服务器·shell·shell脚本.sh文件·创建shell脚本·创建.sh文件
唐璜Taro1 小时前
硬核实战:内网 Windows 环境下 Jenkins + Gitee 自动化部署 Vue2 项目
gitee·自动化·jenkins
天空属于哈夫克31 小时前
企微API自动化:高效安全的群运营方案
linux·运维·服务器
dust_and_stars1 小时前
Windows 11 RDP Wrapper 配置教程与常见问题解决方法
运维·windows