fix(ci): Alpine/musl runner 自动改用 Node musl 构建(glibc 版无法执行),缓存校验加运行测试
Publish Mini Program Dev Version / publish (push) Successful in 3m8s

This commit is contained in:
gouki
2026-08-09 18:49:06 +00:00
parent 320231808b
commit 23442017b3
+16 -8
View File
@@ -31,16 +31,24 @@ jobs:
# 优先复用 runner 宿主机缓存的工具链(工作目录持久化) # 优先复用 runner 宿主机缓存的工具链(工作目录持久化)
TOOLDIR="$RUNNER_WORKSPACE/.lunar-toolchain" TOOLDIR="$RUNNER_WORKSPACE/.lunar-toolchain"
mkdir -p "$TOOLDIR" mkdir -p "$TOOLDIR"
if [ -x "$TOOLDIR/node/bin/node" ]; then if [ -x "$TOOLDIR/node/bin/node" ] && "$TOOLDIR/node/bin/node" --version >/dev/null 2>&1; then
echo "复用缓存 Node 工具链" echo "复用缓存 Node 工具链"
else else
wget -q --tries=2 --timeout=60 -O "$TOOLDIR/node.tgz" \ rm -rf "$TOOLDIR/node" "$TOOLDIR/node-v22.12.0-linux-x64"
"https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64.tar.xz" \ # 探测 libcAlpine(musl) 用 unofficial musl 构建,其余用官方 glibc 构建(tar.gzbusybox tar 不支持 xz
|| wget -q --tries=2 --timeout=60 -O "$TOOLDIR/node.tgz" \ if ldd --version 2>&1 | grep -qi musl || [ ! -e /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ]; then
"https://mirrors.aliyun.com/nodejs-release/v22.12.0/node-v22.12.0-linux-x64.tar.xz" NODE_DIST="node-v22.12.0-linux-x64-musl"
rm -rf "$TOOLDIR/node-v22.12.0-linux-x64" wget -q --tries=2 --timeout=120 -O "$TOOLDIR/node.tgz" \
tar -C "$TOOLDIR" -xJf "$TOOLDIR/node.tgz" "https://unofficial-builds.nodejs.org/download/release/v22.12.0/$NODE_DIST.tar.gz"
mv "$TOOLDIR/node-v22.12.0-linux-x64" "$TOOLDIR/node" else
NODE_DIST="node-v22.12.0-linux-x64"
wget -q --tries=2 --timeout=120 -O "$TOOLDIR/node.tgz" \
"https://nodejs.org/dist/v22.12.0/$NODE_DIST.tar.gz" \
|| wget -q --tries=2 --timeout=120 -O "$TOOLDIR/node.tgz" \
"https://mirrors.aliyun.com/nodejs-release/v22.12.0/$NODE_DIST.tar.gz"
fi
tar -C "$TOOLDIR" -xzf "$TOOLDIR/node.tgz"
mv "$TOOLDIR/$NODE_DIST" "$TOOLDIR/node"
rm -f "$TOOLDIR/node.tgz" rm -f "$TOOLDIR/node.tgz"
fi fi
"$TOOLDIR/node/bin/node" --version "$TOOLDIR/node/bin/node" --version