1
0
forked from Eeveid/lightOps
Files
lightOps/.gitea/workflows/release.yml

112 lines
3.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: 发布 Linux 二进制
on:
push:
tags:
- "v*"
jobs:
release-linux-x86_64:
runs-on: runner_admin
steps:
- name: 检出代码
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
set -eux
TAG="${GITHUB_REF_NAME:-${GITEA_REF_NAME:-}}"
if [ -z "$TAG" ] && [ -n "${GITHUB_REF:-}" ]; then
TAG="${GITHUB_REF##*/}"
fi
if [ -z "$TAG" ]; then
echo "无法识别触发标签"
env | sort
exit 1
fi
printf '%s' "$TAG" > /tmp/lightops-release-tag
rm -rf lightops-src
if [ -n "${GITEA_TOKEN:-}" ]; then
git clone "https://oauth2:${GITEA_TOKEN}@gitea.kmux.cn/Eeveid/lightOps.git" lightops-src
else
git clone https://gitea.kmux.cn/Eeveid/lightOps.git lightops-src
fi
cd lightops-src
git fetch --tags --force
git checkout "$TAG"
- name: 安装系统依赖
run: |
set -eux
if command -v apt-get >/dev/null 2>&1; then
apt-get update
apt-get install -y build-essential pkg-config sqlite3 curl tar ca-certificates nodejs npm
elif command -v apk >/dev/null 2>&1; then
apk add --no-cache build-base pkgconf sqlite curl wget tar ca-certificates nodejs npm bash git
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
elif command -v yum >/dev/null 2>&1; then
yum install -y gcc gcc-c++ make pkgconfig sqlite curl tar ca-certificates nodejs npm
elif command -v pacman >/dev/null 2>&1; then
pacman -Sy --noconfirm base-devel pkgconf sqlite curl tar ca-certificates nodejs npm
else
echo "未找到支持的包管理器,当前系统信息:"
uname -a || true
cat /etc/os-release || true
echo "PATH=$PATH"
exit 1
fi
command -v git
command -v tar
command -v node
command -v npm
command -v curl || command -v wget
- name: 安装 Rust
run: |
set -eux
if ! command -v cargo >/dev/null 2>&1; then
if command -v curl >/dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal
elif command -v wget >/dev/null 2>&1; then
wget -qO- https://sh.rustup.rs | sh -s -- -y --profile minimal
else
echo "缺少 curl/wget无法安装 Rust"
exit 1
fi
. "$HOME/.cargo/env"
fi
rustc -V
cargo -V
if command -v rustup >/dev/null 2>&1; then
rustup target add x86_64-unknown-linux-gnu
fi
- name: 构建发布包
run: |
set -eux
. "$HOME/.cargo/env" 2>/dev/null || true
cd lightops-src
TAG="$(cat /tmp/lightops-release-tag)"
VERSION="${TAG#v}"
bash scripts/build-release.sh --version "$VERSION" --target x86_64-unknown-linux-gnu
- name: 发布到 Gitea Release
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_URL: https://gitea.kmux.cn
GITEA_OWNER: Eeveid
GITEA_REPO: lightOps
run: |
set -eux
cd lightops-src
TAG="$(cat /tmp/lightops-release-tag)"
TARGET_SHA="$(git rev-parse HEAD)"
bash scripts/publish-gitea-release.sh \
--tag "$TAG" \
--title "LightOps ${TAG}" \
--target "$TARGET_SHA" \
--no-create-tag \
--no-push-tag \
--package target/releases/*.tar.gz \
--package target/releases/*.tar.gz.sha256