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

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
  }
}
相关推荐
杜子不疼.1 小时前
【Linux】基础IO(二):系统文件IO
linux·运维·服务器
Justice link9 小时前
K8S基本配置
运维·docker·容器
观熵9 小时前
SaaS 系统的自动化部署结构设计实战指南:基于 K8s + Helm 的工程落地路径
运维·kubernetes·自动化·saas 架构
chinesegf9 小时前
ubuntu中虚拟环境的简单创建和管理
linux·运维·ubuntu
若涵的理解9 小时前
一文读懂K8S kubectl 命令,运维小白必看!
运维·docker·kubernetes
java_logo9 小时前
2025 年 11 月最新 Docker 镜像源加速列表与使用指南
linux·运维·docker·容器·运维开发·kylin
峰顶听歌的鲸鱼10 小时前
Kubernetes管理
运维·笔记·云原生·容器·kubernetes·云计算
霖霖总总10 小时前
[小技巧42]InnoDB 索引与 MVCC 的协同工作原理
运维·数据库·mysql
CRMEB系统商城10 小时前
CRMEB多商户系统(PHP)- 移动端二开之基本容器组件使用
运维·开发语言·小程序·php
HIT_Weston11 小时前
103、【Ubuntu】【Hugo】搭建私人博客:搜索功能(四)
linux·运维·ubuntu