优化 Bun 安装脚本,支持多个下载源
This commit is contained in:
@@ -56,6 +56,8 @@ jobs:
|
||||
|
||||
- name: Install Bun
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
case "$(uname -m)" in
|
||||
x86_64)
|
||||
BUN_ARCH="x64"
|
||||
@@ -70,9 +72,28 @@ jobs:
|
||||
esac
|
||||
|
||||
BUN_ASSET="bun-linux-${BUN_ARCH}.zip"
|
||||
BUN_MIRROR_URL="https://ghproxy.net/https://github.com/oven-sh/bun/releases/latest/download/${BUN_ASSET}"
|
||||
BUN_URLS="
|
||||
https://ghproxy.net/https://github.com/oven-sh/bun/releases/latest/download/${BUN_ASSET}
|
||||
https://ghfast.top/https://github.com/oven-sh/bun/releases/latest/download/${BUN_ASSET}
|
||||
https://github.moeyy.xyz/https://github.com/oven-sh/bun/releases/latest/download/${BUN_ASSET}
|
||||
https://github.com/oven-sh/bun/releases/latest/download/${BUN_ASSET}
|
||||
"
|
||||
|
||||
rm -f /tmp/bun.zip
|
||||
download_success=0
|
||||
for bun_url in $BUN_URLS; do
|
||||
echo "Trying Bun download: ${bun_url}"
|
||||
if curl -fL --connect-timeout 15 --max-time 180 --retry 2 --retry-delay 3 "$bun_url" -o /tmp/bun.zip; then
|
||||
download_success=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$download_success" -ne 1 ]; then
|
||||
echo "Failed to download Bun from all configured mirrors."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl -fL --retry 3 --retry-delay 5 "$BUN_MIRROR_URL" -o /tmp/bun.zip
|
||||
rm -rf "$HOME/.bun"
|
||||
mkdir -p "$HOME/.bun/bin"
|
||||
unzip -qo /tmp/bun.zip -d /tmp
|
||||
|
||||
Reference in New Issue
Block a user