fix(ci): 🐛 fix draft release detection to avoid multiple release IDs for same tag

This commit is contained in:
Dawn
2026-01-19 15:43:24 +08:00
parent 1f661eaaec
commit 342eae600c

View File

@@ -66,14 +66,14 @@ jobs:
fail-fast: false # 某个平台构建失败不影响其他平台
matrix:
include:
- platform: "macos-latest" # for Arm based macs (M1 and above).
args: "--target aarch64-apple-darwin"
- platform: "macos-latest" # for Intel based macs.
args: "--target x86_64-apple-darwin"
- platform: "ubuntu-22.04"
args: ""
- platform: "windows-latest"
args: ""
- platform: 'macos-latest' # for Arm based macs (M1 and above).
args: '--target aarch64-apple-darwin'
- platform: 'macos-latest' # for Intel based macs.
args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04'
args: ''
- platform: 'windows-latest'
args: ''
runs-on: ${{ matrix.platform }}
steps:
@@ -268,9 +268,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# 获取当前 tag 对应的 draft release
RELEASE=$(gh api repos/${{ github.repository }}/releases --jq '.[] | select(.tag_name == "${{ github.ref_name }}" and .draft == true)')
if [ -n "$RELEASE" ]; then
# 直接按 tag 获取 release避免同 tag 多个草稿导致多个 ID
RELEASE=$(gh api repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} 2>/dev/null || true)
if [ -n "$RELEASE" ] && [ "$(echo "$RELEASE" | jq -r '.draft')" = "true" ]; then
RELEASE_ID=$(echo "$RELEASE" | jq -r '.id')
echo "Publishing draft release with ID: $RELEASE_ID"