An automatic TAG command based on the semantic-release analysis tool.
semantic-release uses the @semantic-release/commit-analyzer plugin
to automatically analyze keywords in commit messages (such as feat:, fix:, perf:, etc.),
and determine the type of version upgrade (major, minor, or patch).
Default version upgrade rules
If you want to customize version upgrade rules, you can configure the releaseRules parameter.
Using git-auto-tag requires the team to agree on a
commit format,
it is recommended to use it with commit-lint related plugins.
The message added via -m when generating a tag, for example: git tag -a v0.0.1 -m "Release v0.0.1"
Specify the tag format, where ${version} will be replaced by the generated tag. For example,
if the tag is 1.2.3, then v${version} will be v1.2.3.
Whether to only get the next version number and other variables, rather than actually generating a tag.
Read custom release rules from the specified file. If not specified, the default rules will be used,
where only commit messages with feat, fix, and perf formats will generate a tag.
If you need to expand the release rules, you can customize releaseRules.
For details on how to configure rules, see the documentation
Example file release-rules.json:
[
{ "type": "docs", "scope": "README", "release": "patch" },
{ "type": "refactor", "scope": "core-*", "release": "minor" },
{ "type": "refactor", "release": "patch" },
{ "scope": "no-release", "release": false }
];
Specify a file to save the execution results, with the following fields
{
//`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,
}
The branch on which the tag is automatically generated. This branch is used to get the commit logs, and the tag is generated based on these commit logs.
remote.origin.url obtained from the git configuration via git config --listThe HTTPS address of the target repository
{
tag, // Generated 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