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:
@@ -60,14 +60,17 @@ jobs:
|
||||
- name: 安装 Rust
|
||||
run: |
|
||||
set -eux
|
||||
if [ -f "$HOME/.cargo/env" ]; then
|
||||
. "$HOME/.cargo/env"
|
||||
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
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
if ! command -v cargo >/dev/null 2>&1; then
|
||||
if ! command -v cargo >/dev/null 2>&1 || ! command -v rustc >/dev/null 2>&1; then
|
||||
curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal
|
||||
. "$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
|
||||
rustc -V
|
||||
cargo -V
|
||||
@@ -75,7 +78,11 @@ jobs:
|
||||
- name: 构建发布包
|
||||
run: |
|
||||
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
|
||||
TAG="$(cat /tmp/lightops-release-tag)"
|
||||
VERSION="${TAG#v}"
|
||||
|
||||
Reference in New Issue
Block a user