logo
0
0
WeChat Login

CNB Auto Release Plugin

CNB automatic release plugin that automatically manages repository tags and release version numbers.

Features

  • Automatically fetches all repository tags and sorts them by semantic version
  • Smart version number increment (with customizable rules)
  • Supports custom tag format templates
  • Supports dry-run mode (calculate version only, don't create)
  • Automatically creates tags and releases
  • Outputs pipeline variables for subsequent steps

Version Increment Rules

  • If repository has no tags, generate initial version v1.0.1
  • Otherwise, take the latest tag (sorted by semantic version), increment rules:
    • Patch number increases by 1
    • If patch reaches 100, increment minor version and reset patch to 0
    • If minor reaches 100, increment major version and reset minor and patch to 0

Examples:

  • v1.0.1v1.0.2
  • v1.0.99v1.1.0
  • v1.99.99v2.0.0

Usage

Use in .cnb.yml pipeline configuration:

stages: - name: auto-release image: docker.cnb.cool/r_r/auto-release:latest settings: tagFormat: "v@{version}" dryRun: false

Parameters

tagFormat

  • Type: string
  • Default: v@{version}
  • Required: No
  • Description: Specifies the tag format where @{version} will be replaced by the generated version number. E.g., if version is 1.2.3, v@{version} generates v1.2.3.

Example:

stages: - name: auto-release image: docker.cnb.cool/r_r/auto-release:latest settings: tagFormat: "release-@{version}"

dryRun

  • Type: boolean
  • Default: false
  • Required: No
  • Description: Whether to only calculate the next version number without actually creating the tag and release.

Example:

stages: - name: auto-release image: docker.cnb.cool/r_r/auto-release:latest settings: dryRun: true

slug

  • Type: string
  • Default: Current repository path
  • Required: No
  • Description: Repository path. Not needed for same-repository operations, specify this parameter for cross-repository operations.

endpoint

  • Type: string
  • Default: Current platform's OPENAPI address
  • Required: No
  • Description: Platform API address. Not needed for same-platform operations, specify for cross-platform operations, e.g., https://api.cnb.cool.

token

  • Type: string
  • Default: Current user's temporary token
  • Required: No
  • Description: Platform token. Pass this parameter for cross-platform creation. Must include the following permissions: repo-contents:r, repo-code:rw

Output Variables

Whether dry-run or not, the following pipeline variables are output:

##[set-output auto-tag=v1.0.1] ##[set-output auto-release=v1.0.1]

Can be referenced in subsequent steps via @{auto-tag} and @{auto-release}.

Complete Example

main: push: - stages: - name: auto-release image: docker.cnb.cool/r_r/auto-release:latest settings: tagFormat: "v@{version}" dryRun: false exports: auto-tag: AUTO_TAG auto-release: AUTO_RELEASE - name: echo env script: - echo "AUTO_TAG $AUTO_TAG" - echo "AUTO_RELEASE $AUTO_RELEASE"

Cross-Repository Example

main: push: - stages: - name: auto-release-other-repo image: docker.cnb.cool/r_r/auto-release:latest settings: slug: "other-owner/other-repo" endpoint: "https://api.cnb.cool" token: "${OTHER_REPO_TOKEN}"

Error Handling

When encountering API errors or missing parameters, the plugin will exit with a non-zero status code, causing the pipeline to fail.

License

MIT License

About

- 自动获取仓库所有 tags,按语义化版本排序 - 智能版本号递增(支持自定义规则) - 支持自定义 tag 格式模板 - 支持 dry-run 模式(仅计算版本号,不实际创建) - 自动创建 tag 和 release - 输出流水线变量供后续步骤使用

400.00 KiB
0 forks0 stars1 branches5 TagREADMEMIT license
Language
Go97.9%
Dockerfile2.1%