Skip to content

Commit e29763d

Browse files
authored
Update release.yml
Signed-off-by: 大可 <[email protected]>
1 parent 851778d commit e29763d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/workflows/release.yml

+17-3
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,31 @@ jobs:
3939
- name: Delete existing prerelease
4040
if: github.event_name != 'push' || startsWith(github.ref, 'refs/heads/') # 触发条件为手动或非 tag 的 push
4141
run: |
42-
RELEASE_ID=$(gh api -X GET repos/${{ github.repository }}/releases --jq '.[] | select(.prerelease) | .id' | head -n 1)
42+
TAG_NAME="prerelease-nightly"
43+
44+
# 删除已有的 Release
45+
RELEASE_ID=$(gh api -X GET repos/${{ github.repository }}/releases --jq '.[] | select(.tag_name=="'"$TAG_NAME"'") | .id')
4346
if [ -n "$RELEASE_ID" ]; then
47+
echo "Deleting existing release with ID $RELEASE_ID"
4448
gh api -X DELETE repos/${{ github.repository }}/releases/$RELEASE_ID
4549
fi
50+
51+
# 删除已有的 Tag
52+
git push --delete origin "$TAG_NAME" || true
53+
gh api -X DELETE repos/${{ github.repository }}/git/refs/tags/"$TAG_NAME" || true
54+
4655
env:
4756
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4857

4958
- name: Create new prerelease and upload artifacts
5059
if: github.event_name != 'push' || startsWith(github.ref, 'refs/heads/') # 触发条件为手动或非 tag 的 push
5160
run: |
52-
TAG_NAME="prerelease-$(date +%Y%m%d%H%M%S)"
61+
TAG_NAME="prerelease-nightly"
62+
63+
# 创建新的 Tag 并推送到远程
64+
git tag -a "$TAG_NAME" -m "Nightly Build $(date +'%Y-%m-%d %H:%M:%S')"
65+
git push origin "$TAG_NAME"
66+
5367
gh release create $TAG_NAME --prerelease --title "Nightly Build $(date +'%Y-%m-%d %H:%M:%S')" \
5468
--notes "This is an automated nightly build." \
5569
./dist/*.tar.gz ./dist/*_checksums.txt
@@ -63,4 +77,4 @@ jobs:
6377
version: latest
6478
args: release --clean # 正式发布
6579
env:
66-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)