mirror of
https://git.bjxgj.com/xgj/xgj-actions.git
synced 2025-10-14 23:33:37 +08:00
feat(trigger-version): 添加标签过滤功能支持通配符匹配和排除
新增 `tag-match` 和 `tag-exclude` 输入参数,支持通过通配符模式匹配和排除特定标签 更新 README 文档并添加示例配置文件展示标签过滤功能的使用场景
This commit is contained in:
137
trigger-version/examples/tag-filtering-demo.yml
Normal file
137
trigger-version/examples/tag-filtering-demo.yml
Normal file
@@ -0,0 +1,137 @@
|
||||
name: Tag Filtering Demo
|
||||
|
||||
# 演示如何使用 tagMatch 和 tagExclude 功能来过滤版本标签
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
# 示例1:只匹配稳定版本(排除预发布版本)
|
||||
stable-versions-only:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # 获取完整的 git 历史
|
||||
|
||||
- name: Get stable version (exclude alpha/beta/rc)
|
||||
id: stable-version
|
||||
uses: ./trigger-version
|
||||
with:
|
||||
version-prefix: 'v'
|
||||
use-latest-version: 'true'
|
||||
tag-exclude: '*-alpha*|*-beta*|*-rc*'
|
||||
|
||||
- name: Display stable version info
|
||||
run: |
|
||||
echo "Latest stable version: ${{ steps.stable-version.outputs.latest-version }}"
|
||||
echo "Version with dash: ${{ steps.stable-version.outputs.latest-version-with-dash }}"
|
||||
|
||||
# 示例2:只匹配特定模式的版本
|
||||
specific-pattern-match:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get version matching specific pattern
|
||||
id: pattern-version
|
||||
uses: ./trigger-version
|
||||
with:
|
||||
version-prefix: 'v'
|
||||
use-latest-version: 'true'
|
||||
tag-match: 'v[0-9]*.[0-9]*.[0-9]*' # 只匹配标准的语义版本格式
|
||||
|
||||
- name: Display pattern matched version
|
||||
run: |
|
||||
echo "Pattern matched version: ${{ steps.pattern-version.outputs.latest-version }}"
|
||||
|
||||
# 示例3:复杂过滤 - 匹配主版本号并排除预发布
|
||||
complex-filtering:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get v2.x versions excluding pre-releases
|
||||
id: v2-stable
|
||||
uses: ./trigger-version
|
||||
with:
|
||||
version-prefix: 'v'
|
||||
use-latest-version: 'true'
|
||||
tag-match: 'v2.*.*' # 只匹配 v2.x.x 版本
|
||||
tag-exclude: '*-*' # 排除所有包含连字符的版本(预发布版本)
|
||||
|
||||
- name: Display filtered version
|
||||
run: |
|
||||
echo "Latest v2.x stable version: ${{ steps.v2-stable.outputs.latest-version }}"
|
||||
|
||||
# 示例4:获取预发布版本
|
||||
prerelease-versions:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get latest beta version
|
||||
id: beta-version
|
||||
uses: ./trigger-version
|
||||
with:
|
||||
version-prefix: 'v'
|
||||
use-latest-version: 'true'
|
||||
tag-match: '*-beta*' # 只匹配包含 beta 的版本
|
||||
|
||||
- name: Display beta version
|
||||
run: |
|
||||
echo "Latest beta version: ${{ steps.beta-version.outputs.latest-version }}"
|
||||
|
||||
# 示例5:多条件排除
|
||||
multi-exclude:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get version excluding multiple patterns
|
||||
id: multi-exclude
|
||||
uses: ./trigger-version
|
||||
with:
|
||||
version-prefix: 'v'
|
||||
use-latest-version: 'true'
|
||||
# 注意:多个排除模式需要在 shell 脚本中处理,这里展示单个模式
|
||||
tag-exclude: '*-alpha*' # 排除 alpha 版本
|
||||
|
||||
- name: Display filtered version
|
||||
run: |
|
||||
echo "Version (excluding alpha): ${{ steps.multi-exclude.outputs.latest-version }}"
|
||||
|
||||
# 示例6:在版本触发时的行为
|
||||
version-trigger-behavior:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref_type == 'tag'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Process version trigger
|
||||
id: version-trigger
|
||||
uses: ./trigger-version
|
||||
with:
|
||||
version-prefix: 'v'
|
||||
# 注意:当通过标签触发时,tag-match 和 tag-exclude 主要影响 latest-version 的获取
|
||||
# 而不影响当前触发的版本
|
||||
tag-exclude: '*-alpha*'
|
||||
|
||||
- name: Display trigger info
|
||||
run: |
|
||||
echo "Triggered by tag: ${{ steps.version-trigger.outputs.trigger-version }}"
|
||||
echo "Latest stable version: ${{ steps.version-trigger.outputs.latest-version }}"
|
||||
echo "Is version trigger: ${{ steps.version-trigger.outputs.is-version-trigger }}"
|
Reference in New Issue
Block a user