1
0
forked from Eeveid/lightOps

🐛 fix(workflow): 修复发布构建的 Rust 目标配置

- 安装和构建阶段优先使用系统 rustc/cargo,避免被 ~/.cargo/bin 中的 musl 工具链覆盖
- 仅在系统工具链缺失时才加载或安装 rustup,减少 runner 现有环境带来的干扰
- 当使用 rustup 时自动补齐 x86_64-unknown-linux-gnu target,匹配发布脚本的构建目标
This commit is contained in:
2026-05-25 22:41:41 +08:00
parent b4001f5e12
commit f839ea2266

View File

@@ -60,14 +60,17 @@ jobs:
- name: 安装 Rust - name: 安装 Rust
run: | run: |
set -eux set -eux
if [ -f "$HOME/.cargo/env" ]; then PATH_WITHOUT_CARGO_BIN="$(printf '%s' "$PATH" | awk -v RS=: -v ORS=: '$0 != ENVIRON["HOME"] \"/.cargo/bin\" { print }' | sed 's/:$//')"
. "$HOME/.cargo/env" export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin${PATH_WITHOUT_CARGO_BIN:+:$PATH_WITHOUT_CARGO_BIN}"
if ! command -v cargo >/dev/null 2>&1 || ! command -v rustc >/dev/null 2>&1; then
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
fi fi
export PATH="$HOME/.cargo/bin:$PATH" if ! command -v cargo >/dev/null 2>&1 || ! command -v rustc >/dev/null 2>&1; then
if ! command -v cargo >/dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal
. "$HOME/.cargo/env" . "$HOME/.cargo/env"
export PATH="$HOME/.cargo/bin:$PATH" fi
if command -v rustup >/dev/null 2>&1; then
rustup target list --installed | grep -qx 'x86_64-unknown-linux-gnu' || rustup target add x86_64-unknown-linux-gnu
fi fi
rustc -V rustc -V
cargo -V cargo -V
@@ -75,7 +78,11 @@ jobs:
- name: 构建发布包 - name: 构建发布包
run: | run: |
set -eux set -eux
. "$HOME/.cargo/env" 2>/dev/null || true PATH_WITHOUT_CARGO_BIN="$(printf '%s' "$PATH" | awk -v RS=: -v ORS=: '$0 != ENVIRON["HOME"] \"/.cargo/bin\" { print }' | sed 's/:$//')"
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin${PATH_WITHOUT_CARGO_BIN:+:$PATH_WITHOUT_CARGO_BIN}"
if ! command -v cargo >/dev/null 2>&1 || ! command -v rustc >/dev/null 2>&1; then
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
fi
cd lightops-src cd lightops-src
TAG="$(cat /tmp/lightops-release-tag)" TAG="$(cat /tmp/lightops-release-tag)"
VERSION="${TAG#v}" VERSION="${TAG#v}"