ci: fix runner probe curl error and re-sync RELEASE_TOKEN
Some checks failed
Secrets CLI - Build & Release / 版本 & Release (push) Successful in 2s
Secrets CLI - Build & Release / 探测 Runner (push) Successful in 1s
Secrets CLI - Build & Release / 质量检查 (fmt / clippy / test) (push) Successful in 23s
Secrets CLI - Build & Release / Build (aarch64-apple-darwin) (push) Successful in 20s
Secrets CLI - Build & Release / Build (x86_64-unknown-linux-musl) (push) Successful in 27s
Secrets CLI - Build & Release / 通知 (push) Has been cancelled
Secrets CLI - Build & Release / Build (x86_64-pc-windows-msvc) (push) Has been cancelled

- Replace curl -fsS with HTTP status code check in probe-runners to avoid ugly 401 errors
- Graceful fallback: API failure defaults to trying all platforms
- RELEASE_TOKEN re-synced with correct PAT value

Made-with: Cursor
This commit is contained in:
voson
2026-03-18 15:18:03 +08:00
parent 2ad1abe846
commit 1aef267bbd

View File

@@ -141,28 +141,31 @@ jobs:
env: env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: | run: |
if [ -z "$RELEASE_TOKEN" ]; then fallback_all() {
echo "has_linux=true" >> "$GITHUB_OUTPUT" echo "has_linux=true" >> "$GITHUB_OUTPUT"
echo "has_macos=true" >> "$GITHUB_OUTPUT" echo "has_macos=true" >> "$GITHUB_OUTPUT"
echo "has_windows=true" >> "$GITHUB_OUTPUT" echo "has_windows=true" >> "$GITHUB_OUTPUT"
exit 0 }
if [ -z "$RELEASE_TOKEN" ]; then
echo "未配置 RELEASE_TOKEN默认尝试所有平台"
fallback_all; exit 0
fi fi
command -v jq >/dev/null 2>&1 || (sudo apt-get update -qq && sudo apt-get install -y -qq jq) command -v jq >/dev/null 2>&1 || (sudo apt-get update -qq && sudo apt-get install -y -qq jq)
runners=$(curl -fsS -H "Authorization: token $RELEASE_TOKEN" \ http_code=$(curl -sS -o /tmp/runners.json -w '%{http_code}' \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/runners" || true) -H "Authorization: token $RELEASE_TOKEN" \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/actions/runners")
if [ -z "$runners" ]; then if [ "$http_code" != "200" ]; then
echo "has_linux=true" >> "$GITHUB_OUTPUT" echo "Runner API 返回 HTTP ${http_code},默认尝试所有平台"
echo "has_macos=true" >> "$GITHUB_OUTPUT" fallback_all; exit 0
echo "has_windows=true" >> "$GITHUB_OUTPUT"
exit 0
fi fi
has_runner() { has_runner() {
local label="$1" local label="$1"
printf '%s' "$runners" | jq -e --arg label "$label" ' jq -e --arg label "$label" '
(.runners // .data // . // []) (.runners // .data // . // [])
| any( | any(
( (
@@ -175,26 +178,17 @@ jobs:
| index($label) | index($label)
) != null ) != null
) )
' >/dev/null ' /tmp/runners.json >/dev/null
} }
if has_runner "debian"; then for pair in "debian:has_linux" "darwin-arm64:has_macos" "windows:has_windows"; do
echo "has_linux=true" >> "$GITHUB_OUTPUT" label="${pair%%:*}"; key="${pair##*:}"
if has_runner "$label"; then
echo "${key}=true" >> "$GITHUB_OUTPUT"
else else
echo "has_linux=false" >> "$GITHUB_OUTPUT" echo "${key}=false" >> "$GITHUB_OUTPUT"
fi
if has_runner "darwin-arm64"; then
echo "has_macos=true" >> "$GITHUB_OUTPUT"
else
echo "has_macos=false" >> "$GITHUB_OUTPUT"
fi
if has_runner "windows"; then
echo "has_windows=true" >> "$GITHUB_OUTPUT"
else
echo "has_windows=false" >> "$GITHUB_OUTPUT"
fi fi
done
check: check:
name: 质量检查 (fmt / clippy / test) name: 质量检查 (fmt / clippy / test)