Skip to content

Commit ff29d9a

Browse files
committed
👷 优化发布流程:支持 release-* 标签触发并打标 v* 产物
1 parent b3d0c26 commit ff29d9a

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

.github/workflows/publish.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Publish SDK
33
on:
44
push:
55
branches: [master]
6-
tags: ["v*"]
6+
tags: ["release-*", "release/*", "v*"]
77
workflow_dispatch:
88

99
permissions:
@@ -43,8 +43,11 @@ jobs:
4343
- name: Build SDK
4444
run: pnpm run build
4545

46+
- name: Run unit tests
47+
run: pnpm run test
48+
4649
- name: Publish to GitHub Packages
47-
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
50+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
4851
run: |
4952
pnpm publish --no-git-checks || echo "Skipping package publish or already exists"
5053
env:
@@ -72,7 +75,13 @@ jobs:
7275
git push origin release --force
7376
7477
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
75-
TAG_NAME="${{ github.ref_name }}"
76-
git tag -f "$TAG_NAME"
77-
git push origin "$TAG_NAME" --force
78+
RAW_TAG="${{ github.ref_name }}"
79+
CLEAN_TAG="${RAW_TAG#release/}"
80+
CLEAN_TAG="${CLEAN_TAG#release-}"
81+
if [[ ! "$CLEAN_TAG" =~ ^v ]]; then
82+
CLEAN_TAG="v${CLEAN_TAG}"
83+
fi
84+
85+
git tag -f "$CLEAN_TAG"
86+
git push origin "$CLEAN_TAG" --force
7887
fi

0 commit comments

Comments
 (0)