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


    # 安装commitizen
    
    npm install --save-dev commitizen
    
    # 初始化Conventional Commits规范适配器
    
    npx commitizen init cz-conventional-changelog --save-dev --save-exact
    
    最后一步,需要在package.json中添加一个script
    
    "scripts": {
        ..., // 此处省略其它配置
        "commit": "cz"
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    此时你的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"
        }
      }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23

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

     当前不需要在npm进行发布,因此需要在.release-it.json中添加下面的配置,禁用npm发布:
    "npm": {
      "publish": false
    }
    
    • 1
    • 2
    • 3
    • 4

    为了兼容当前的提交信息格式,还需要执行下面的指令安装一个插件:
    npm install @release-it/conventional-changelog --save-dev

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

    
    {
      "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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
  • 相关阅读:
    vue+element-ui el-descriptions 详情渲染组件二次封装(Vue项目)
    数据结构-核心算法
    区块链,得这样练
    【Spring】事务管理
    ViT简述【Transformer】
    ElasticSearch - () Python操作es
    小车测距避障-通过串口(可蓝牙)控制
    python【多线程、单线程、异步编程】三个版本--在爬虫中的应用
    【c++】——类和对象(中)——默认成员函数(上)
    百度Apolo自动驾驶_百度车载小程序
  • 原文地址:https://blog.csdn.net/weixin_50636536/article/details/134267151