fix: 修复 Gitea 发布工作流在 fork/镜像仓库中的兼容性问题 #1

Merged
Eeveid merged 24 commits from zhilv/lightOps:main into main 2026-05-28 18:53:16 +08:00
Showing only changes of commit f1491ba114 - Show all commits

View File

@@ -48,40 +48,24 @@ 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
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
@@ -97,24 +81,7 @@ jobs:
- name: 构建发布包 - name: 构建发布包
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}"