logo
0
0
WeChat Login
docs: 修改默认版本升级规则说明文档

git-auto-tag

基于 semantic-release 分析工具制作的自动打 TAG 命令。

semantic-release 使用 @semantic-release/commit-analyzer 插件 来实现自动分析提交信息(commit messages)中的关键字(如 feat:fix:perf: 等), 并决定版本升级类型(majorminorpatch)。 默认版本升级规则 如果想自定义版本升级规则,可配置 releaseRules 参数。

使用 git-auto-tag 需要团队约定 提交格式, 建议配合 commit-lint 相关插件使用。

参数

message

  • type: string
  • 默认值: "Release {tag 名}"
  • 必填: 否

生成 tag 时通过 -m 添加的 message,例如:git tag -a v0.0.1 -m "Release v0.0.1"

tagFormat

  • type: string
  • 默认值: v${version}
  • 必填: 否

指定 tag 格式,其中 ${version} 会由生成的 tag 替换。如 tag1.2.3,那么 v${version}v1.2.3

dryRun

  • type: boolean
  • 默认值: false
  • 必填: 否

是否只得到下一个版本号等变量,而非真正的生成 tag

blockWhenFail

  • type: boolean
  • 默认值: false
  • 必填: 否

releaseRules

  • type: string
  • 必填: 否

从指定的文件中读取自定义发布规则,如果没有指定,则使用默认规则,仅 featfixperf 三种格式的提交注释会生成 tag

如需扩充发布规则可自定义 releaseRules

规则如何配置详见文档

示例文件 release-rules.json

[ { "type": "docs", "scope": "README", "release": "patch" }, { "type": "refactor", "scope": "core-*", "release": "minor" }, { "type": "refactor", "release": "patch" }, { "scope": "no-release", "release": false } ];

toFile

  • type: string
  • 默认值: auto_tag.json
  • 必填: 否

指定文件保存执行结果,有如下字段

{ //`Object` with `version`, `gitTag` and `gitHead` // of the last release. lastRelease, //`Object` with `version`, `gitTag`, `gitHead` and `notes` // of the release being done. nextRelease, commits, releases, }

branch

  • type: string
  • 默认值: main
  • 必填: 否

自动生成 tag 依据的分支,根据这个分支获取提交日志,根据提交日志生成 tag

repoUrlHttps

  • type: string
  • 必填: 否
  • 默认值:通过 git config --list 获取到的 git 配置中的 remote.origin.url 的值

目标仓库仓库 https 地址

输出

{ tag, // 生成的 tag }

在 云原生构建 上使用

# .cnb.yml main: push: - stages: - name: auto-tag image: cnbcool/git-auto-tag:latest settings: tagFormat: v\${version} toFile: tag_info.json dryRun: false blockWhenFail: false branch: $CNB_BRANCH repoUrlHttps: $CNB_REPO_URL_HTTPS exports: tag: NEW_TAG - name: show tag script: echo $NEW_TAG - name: show tag res script: cat tag_info.json