huhan3000/tools/setup/install-gitea-runner.sh

68 lines
1.8 KiB
Bash
Executable File
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.

#!/bin/bash
# Gitea Runner 安装脚本
# 胡汉三千年项目 CI/CD 工具安装
set -e
RUNNER_VERSION="v0.2.6"
ARCH="linux-amd64"
BINARY_NAME="act_runner-${RUNNER_VERSION}-${ARCH}"
DOWNLOAD_URL="https://github.com/gitea/act_runner/releases/download/${RUNNER_VERSION}/${BINARY_NAME}"
echo "🚀 安装 Gitea Runner ${RUNNER_VERSION}..."
# 创建工具目录
mkdir -p tools/bin
# 检查是否已经安装
if [ -f "tools/bin/gitea-runner" ]; then
echo "✅ Gitea Runner 已存在"
CURRENT_VERSION=$(tools/bin/gitea-runner --version 2>/dev/null || echo "unknown")
echo "当前版本: $CURRENT_VERSION"
read -p "是否重新下载?(y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "跳过安装"
exit 0
fi
fi
# 下载二进制文件
echo "📥 下载 Gitea Runner..."
if command -v wget >/dev/null 2>&1; then
wget -O "tools/bin/gitea-runner" "$DOWNLOAD_URL"
elif command -v curl >/dev/null 2>&1; then
curl -L -o "tools/bin/gitea-runner" "$DOWNLOAD_URL"
else
echo "❌ 错误: 需要 wget 或 curl"
exit 1
fi
# 设置执行权限
chmod +x tools/bin/gitea-runner
# 验证安装
echo "🔍 验证安装..."
if tools/bin/gitea-runner --version; then
echo "✅ Gitea Runner 安装成功!"
echo "📍 位置: $(pwd)/tools/bin/gitea-runner"
else
echo "❌ 安装失败"
exit 1
fi
# 创建符号链接(可选)
read -p "是否创建全局符号链接到 /usr/local/bin(需要sudo权限) (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo ln -sf "$(pwd)/tools/bin/gitea-runner" /usr/local/bin/gitea-runner
echo "✅ 全局符号链接已创建"
fi
echo "🎉 安装完成!"
echo ""
echo "使用方法:"
echo " 本地使用: ./tools/bin/gitea-runner"
echo " 全局使用: gitea-runner (如果创建了符号链接)"