fix(ci): pnpm 改用 linuxstatic 单文件二进制,绕开 npm registry 安装
Build and Publish Commercial Web / build (push) Failing after 20s
Build and Publish Commercial Web / build (push) Failing after 20s
This commit is contained in:
@@ -108,15 +108,31 @@ jobs:
|
|||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
run: |
|
run: |
|
||||||
export HOME="$RUNNER_WORKSPACE"
|
export HOME="$RUNNER_WORKSPACE"
|
||||||
# pnpm 随工具链缓存,避免每次重复下载
|
# pnpm 随工具链缓存;linuxstatic 单文件二进制不依赖 npm registry
|
||||||
|
# 且同时兼容 glibc/musl runner(npm install -g 在多个 runner 上不稳定)
|
||||||
TOOLDIR="$RUNNER_WORKSPACE/.lunar-toolchain"
|
TOOLDIR="$RUNNER_WORKSPACE/.lunar-toolchain"
|
||||||
|
mkdir -p "$TOOLDIR/pnpm/bin"
|
||||||
|
PNPM_VER=11.13.1
|
||||||
if [ ! -x "$TOOLDIR/pnpm/bin/pnpm" ]; then
|
if [ ! -x "$TOOLDIR/pnpm/bin/pnpm" ]; then
|
||||||
rm -rf "$TOOLDIR/pnpm"
|
DL_OK=""
|
||||||
# 版本与本地一致(pnpm 11):web/ 工作区的 allowBuilds 配置
|
for url in \
|
||||||
# 是 pnpm 10.9+ 才支持的字段,pnpm 9 会导致 esbuild 构建脚本被忽略
|
"https://registry.npmmirror.com/-/binary/pnpm/v$PNPM_VER/pnpm-linuxstatic-x64" \
|
||||||
# 亚洲 runner 优先走 npmmirror,失败回落官方源
|
"https://github.com/pnpm/pnpm/releases/download/v$PNPM_VER/pnpm-linuxstatic-x64"; do
|
||||||
npm install -g --prefix "$TOOLDIR/pnpm" --registry=https://registry.npmmirror.com pnpm@11 \
|
echo "尝试下载: $url"
|
||||||
|| npm install -g --prefix "$TOOLDIR/pnpm" --registry=https://registry.npmjs.org pnpm@11
|
if wget -q -t 2 -T 60 -O "$TOOLDIR/pnpm/bin/pnpm" "$url"; then
|
||||||
|
chmod +x "$TOOLDIR/pnpm/bin/pnpm"
|
||||||
|
if "$TOOLDIR/pnpm/bin/pnpm" --version >/dev/null 2>&1; then
|
||||||
|
DL_OK=1
|
||||||
|
echo "下载成功"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "二进制无法执行,尝试下一源"
|
||||||
|
else
|
||||||
|
echo "下载失败,尝试下一源"
|
||||||
|
fi
|
||||||
|
rm -f "$TOOLDIR/pnpm/bin/pnpm"
|
||||||
|
done
|
||||||
|
test -n "$DL_OK" || { echo "::error::pnpm 所有下载源均失败"; exit 1; }
|
||||||
fi
|
fi
|
||||||
echo "PATH=$TOOLDIR/pnpm/bin:$PATH" >> "$GITEA_ENV"
|
echo "PATH=$TOOLDIR/pnpm/bin:$PATH" >> "$GITEA_ENV"
|
||||||
"$TOOLDIR/pnpm/bin/pnpm" --version
|
"$TOOLDIR/pnpm/bin/pnpm" --version
|
||||||
|
|||||||
Reference in New Issue
Block a user