semantic-release plugin,
which generates git tag and changelog based on commit history.
semantic-release: 24.2.6
Automatically runs the semantic-release tool in the working directory.
For the workflow of semantic-release,
refer to semantic-release#release-steps.
The current tool automatically executes the following semantic-release plugins:
@semantic-release/commit-analyzer@semantic-release/release-notes-generator@semantic-release/changelog@semantic-release/npm (loaded only when npm.npmPublish=true)@semantic-release/gitv${version}Specifies the tag format, where ${version} will be replaced by the generated target tag,
e.g., 1.2.3. Thus, v${version} becomes v1.2.3.
falseRuns in dry-run mode, generating a new version number but without executing git tag or publishing.
The branch used to generate the tag. The commit logs from this branch are used to determine the tag.
CHANGELOG.mdSpecifies the filename for the generated changelog file.
-Specifies the title (first line) of the changelog file.
true if npm_token is set, otherwise falseWhether to publish the npm package.
The token used to publish the npm package.
.The root directory of the npm package to be published.
falseThe directory path to write the package tarball.
If set to false, the tarball will not be saved to the file system.
chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}The commit message for the release commit.
['CHANGELOG.md', 'package.json', 'package-lock.json', 'npm-shrinkwrap.json']Files to include in the release commit.
Set to false to disable adding files to the release commit.
semantic-release-result.jsonThe file path to store the execution result, which can later be read using the cnb:read-file built-in task.
{
// https://github.com/semantic-release/semantic-release/blob/v20.1.1/docs/developer-guide/js-api.md#lastrelease
lastRelease.version, // Last release version
lastRelease.gitHead, // Last release commit
lastRelease.gitTag, // Last release tag
lastRelease.channel, // Last release channel
// https://github.com/semantic-release/semantic-release/blob/v20.1.1/docs/developer-guide/js-api.md#commits
commits,
// https://github.com/semantic-release/semantic-release/blob/v20.1.1/docs/developer-guide/js-api.md#nextrelease
nextRelease.type, // Semver type of this release
nextRelease.version, // Version of this release
nextRelease.gitHead, // Commit of this release
nextRelease.gitTag, // Tag of this release
nextRelease.notes, // Changelog of this release
// https://github.com/semantic-release/semantic-release/blob/v20.1.1/docs/developer-guide/js-api.md#releases
releases,
}
docker run --rm \ -v $(pwd):$(pwd) \ -w $(pwd) \ \ -e PLUGIN_DRYRUN="true" \ \ tencentcom/semantic-release:dev
main:
push:
- stages:
- name: semantic-release
image: tencentcom/semantic-release:dev
# Secret repository file with NPM_TOKEN configured
imports: https://cnb.cool/xxx/xxx/-/blob/main/npm_secret.yml
settings:
tagFormat: v\${version} # Escape $ to avoid being treated as an environment variable
branch: main
dryRun: false
changelog_changelogFile: CHANGELOG.md
changelog_changelogTitle: "-"
# Retrieved from the imported file
npm_token: $NPM_TOKEN
npm_pkgRoot: "."
npm_tarballDir: false
git_message: |
chore(release): ${nextRelease.version} [skip ci]
\${nextRelease.notes}
git_assets:
- CHANGELOG.md
- package.json
- package-lock.json
- npm-shrinkwrap.json
# The above task outputs the result to semantic-release-result.json,
# which is then parsed to export environment variables
- name: read file
type: cnb:read-file
options:
filePath: semantic-release-result.json
exports:
nextRelease.version: VERSION
- name: echo VERSION
script: echo $VERSION
This plugin has upgraded its dependent npm libraries and adjusted parameter names.
Parameters that originally contained . have been changed to _.
If you are using an older version, you can use tencentcom/semantic-release:v1.2.0.