1
0
forked from Eeveid/lightOps

5 Commits

Author SHA1 Message Date
9ffe425d6e 🐛 fix(workflow): 修复 Cargo 镜像配置的 YAML 语法
- 去掉 run 脚本中的 heredoc 写法,避免 YAML 将 TOML 内容误判为工作流字段
- 改为使用 printf 生成 ~/.cargo/config.toml
- 保持 crates-io 切换到 rsproxy sparse registry 的逻辑不变
2026-05-26 20:38:47 +08:00
7e8d4baac6 🐛 fix(workflow): 为 Cargo 配置 crates 镜像源
- 在安装 Rust 步骤写入 ~/.cargo/config.toml,将 crates-io 切换到 rsproxy sparse registry
- 避免 runner 访问 index.crates.io 超时导致依赖下载失败
- 与 rustup 镜像配置配合,统一走国内镜像完成工具链和依赖安装
2026-05-26 20:34:23 +08:00
a79ef99500 🐛 fix(workflow): 为 rustup 配置镜像下载源
- 在安装 Rust 和构建步骤中设置 RUSTUP_DIST_SERVER 与 RUSTUP_UPDATE_ROOT
- 避免 runner 直连 static.rust-lang.org 超时导致 stable 工具链安装失败
- 保持通过 rustup stable 获取新版 cargo 以兼容 Cargo.lock v4
2026-05-26 20:20:25 +08:00
f1491ba114 🐛 fix(workflow): 固定使用新版 Rust stable 工具链
- 发布工作流不再依赖 runner 自带 rustc/cargo 版本
- 改为通过 rustup 安装并默认切换到 stable 工具链,兼容 Cargo.lock v4
- 构建步骤统一加载 ~/.cargo/env,避免旧版系统 cargo 抢占路径
2026-05-26 19:54:18 +08:00
8db385cca6 fix: 修改运行环境 2026-05-26 19:39:31 +08:00

View File

@@ -7,7 +7,7 @@ on:
jobs: jobs:
release-linux-x86_64: release-linux-x86_64:
runs-on: runner_admin runs-on: ubuntu-latest
steps: steps:
- name: 检出代码 - name: 检出代码
env: env:
@@ -48,40 +48,27 @@ jobs:
set -eux set -eux
if command -v apt-get >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then
apt-get update apt-get update
apt-get install -y build-essential pkg-config sqlite3 curl tar ca-certificates nodejs npm rustc cargo apt-get install -y build-essential pkg-config sqlite3 curl tar ca-certificates nodejs npm
elif command -v dnf >/dev/null 2>&1; then elif command -v dnf >/dev/null 2>&1; then
dnf install -y gcc gcc-c++ make pkgconf-pkg-config sqlite curl tar ca-certificates nodejs npm rust cargo dnf install -y gcc gcc-c++ make pkgconf-pkg-config sqlite curl tar ca-certificates nodejs npm
elif command -v yum >/dev/null 2>&1; then elif command -v yum >/dev/null 2>&1; then
yum install -y gcc gcc-c++ make pkgconfig sqlite curl tar ca-certificates nodejs npm rust cargo yum install -y gcc gcc-c++ make pkgconfig sqlite curl tar ca-certificates nodejs npm
elif command -v pacman >/dev/null 2>&1; then elif command -v pacman >/dev/null 2>&1; then
pacman -Sy --noconfirm base-devel pkgconf sqlite curl tar ca-certificates nodejs npm rust cargo pacman -Sy --noconfirm base-devel pkgconf sqlite curl tar ca-certificates nodejs npm
fi fi
- name: 安装 Rust - name: 安装 Rust
env:
RUSTUP_DIST_SERVER: https://rsproxy.cn
RUSTUP_UPDATE_ROOT: https://rsproxy.cn/rustup
run: | run: |
set -eux set -eux
PATH_BASE="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" if ! command -v rustup >/dev/null 2>&1; then
PATH_EXTRA=""
OLD_IFS="$IFS"
IFS=':'
set -- $PATH
IFS="$OLD_IFS"
for entry in "$@"; do
[ -n "$entry" ] || continue
[ "$entry" = "$HOME/.cargo/bin" ] && continue
case ":$PATH_BASE:$PATH_EXTRA:" in
*":$entry:"*) continue ;;
esac
PATH_EXTRA="${PATH_EXTRA:+$PATH_EXTRA:}$entry"
done
export PATH="$PATH_BASE${PATH_EXTRA:+:$PATH_EXTRA}"
if ! command -v cargo >/dev/null 2>&1 || ! command -v rustc >/dev/null 2>&1; then
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
fi
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 curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal
. "$HOME/.cargo/env"
fi fi
. "$HOME/.cargo/env"
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
HOST_TARGET="$(rustc -vV | sed -n 's/^host: //p')" HOST_TARGET="$(rustc -vV | sed -n 's/^host: //p')"
BUILD_TARGET="$HOST_TARGET" BUILD_TARGET="$HOST_TARGET"
if [ "$HOST_TARGET" != "x86_64-unknown-linux-gnu" ] && command -v rustup >/dev/null 2>&1; then if [ "$HOST_TARGET" != "x86_64-unknown-linux-gnu" ] && command -v rustup >/dev/null 2>&1; then
@@ -93,28 +80,22 @@ jobs:
echo "使用 Rust 构建目标: $BUILD_TARGET" echo "使用 Rust 构建目标: $BUILD_TARGET"
rustc -V rustc -V
cargo -V cargo -V
mkdir -p "$HOME/.cargo"
printf '%s\n' \
'[source.crates-io]' \
'replace-with = "rsproxy-sparse"' \
'' \
'[source.rsproxy-sparse]' \
'registry = "sparse+https://rsproxy.cn/index/"' \
>"$HOME/.cargo/config.toml"
- name: 构建发布包 - name: 构建发布包
env:
RUSTUP_DIST_SERVER: https://rsproxy.cn
RUSTUP_UPDATE_ROOT: https://rsproxy.cn/rustup
run: | run: |
set -eux set -eux
PATH_BASE="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" . "$HOME/.cargo/env"
PATH_EXTRA=""
OLD_IFS="$IFS"
IFS=':'
set -- $PATH
IFS="$OLD_IFS"
for entry in "$@"; do
[ -n "$entry" ] || continue
[ "$entry" = "$HOME/.cargo/bin" ] && continue
case ":$PATH_BASE:$PATH_EXTRA:" in
*":$entry:"*) continue ;;
esac
PATH_EXTRA="${PATH_EXTRA:+$PATH_EXTRA:}$entry"
done
export PATH="$PATH_BASE${PATH_EXTRA:+:$PATH_EXTRA}"
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}"