|
5 | 5 | tags: |
6 | 6 | - "v*" |
7 | 7 | branches: |
8 | | - - main # 正式版分支 |
9 | | - - beta # 公测版分支 |
| 8 | + - main |
| 9 | + - beta |
10 | 10 | paths: |
11 | 11 | - ".github/workflows/install.yml" |
12 | 12 | - "assets/**" |
@@ -37,46 +37,27 @@ jobs: |
37 | 37 | run: | |
38 | 38 | current_branch=${{ github.ref_name }} |
39 | 39 | is_release=${{ startsWith(github.ref, 'refs/tags/v') }} |
40 | | - tag=$(git describe --tags --match "v*" ${{ github.ref }} || true) |
41 | | -
|
42 | | - # 初始标签获取逻辑 |
43 | | - if [[ $tag != v* ]]; then |
44 | | - tag=$(curl -sX GET "https://api.github.com/repos/${{ github.repository }}/releases/latest" --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | awk -F'"' '/tag_name/{print $4}') |
45 | | - if [[ $tag != v* ]]; then |
46 | | - tag="v0.0.0" |
47 | | - fi |
48 | | - tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)") |
49 | | - fi |
50 | 40 |
|
51 | | - # 分支逻辑处理 |
52 | | - if [[ "$current_branch" == "beta" ]]; then |
53 | | - # Beta 分支自动递增序号 |
54 | | - if [[ "$is_release" == "false" ]]; then |
55 | | - latest_beta_tag=$(git describe --tags --match "v*-beta.*" --abbrev=0 2>/dev/null || true) |
56 | | - if [[ -z "$latest_beta_tag" ]]; then |
57 | | - latest_main_tag=$(git describe --tags --match "v*" --abbrev=0 2>/dev/null || echo "v0.0.0") |
58 | | - base_version=$(echo "$latest_main_tag" | sed 's/-.*//') |
59 | | - new_tag="${base_version}-beta.1" |
60 | | - else |
61 | | - base_version=$(echo "$latest_beta_tag" | cut -d'-' -f1) |
62 | | - beta_num=$(echo "$latest_beta_tag" | awk -F'.' '{print $NF}') |
63 | | - new_tag="${base_version}-beta.$((beta_num + 1))" |
64 | | - fi |
65 | | - tag="$new_tag" |
| 41 | + if [[ "$is_release" == "true" ]]; then |
| 42 | + tag=$(git describe --tags --exact-match ${{ github.ref }}) |
| 43 | + |
| 44 | + # 分支标签格式校验 |
| 45 | + if [[ "$current_branch" == "main" ]] && [[ "$tag" == *-beta* ]]; then |
| 46 | + echo "::error::Main branch cannot have beta tags" |
| 47 | + exit 1 |
| 48 | + elif [[ "$current_branch" == "beta" ]] && [[ "$tag" != *-beta* ]]; then |
| 49 | + echo "::error::Beta branch tags must contain '-beta' suffix" |
| 50 | + exit 1 |
66 | 51 | fi |
67 | | - is_prerelease=true |
68 | 52 |
|
69 | | - elif [[ "$current_branch" == "main" ]]; then |
70 | | - # Main 分支清理 beta 后缀 |
71 | | - tag=$(echo "$tag" | sed 's/-beta.*//') |
72 | 53 | is_prerelease=false |
73 | | - fi |
74 | | -
|
75 | | - # 非 Release 标签添加 CI 后缀 |
76 | | - if [[ "$is_release" == "false" ]]; then |
77 | | - prefix=${tag%-*-*} |
78 | | - suffix=${tag#$prefix-} |
79 | | - tag="$prefix-ci.$suffix" |
| 54 | + if [[ "$tag" == *-beta* ]]; then |
| 55 | + is_prerelease=true |
| 56 | + fi |
| 57 | + else |
| 58 | + tag="" |
| 59 | + is_release="false" |
| 60 | + is_prerelease="false" |
80 | 61 | fi |
81 | 62 |
|
82 | 63 | echo "tag=$tag" | tee -a $GITHUB_OUTPUT |
|
0 commit comments