fix(ci): 修复多平台构建流程 - 每个平台单独编译 libcore

**问题:**
- Windows/macOS/Linux 构建不依赖 libcore 编译
- 这些平台没有下载对应的 libcore 库文件
- 导致桌面平台构建时缺少必需的 native 库

**修复:**
- 为每个平台创建独立的 libcore 编译任务:
  * build-libcore-android → libcore.aar
  * build-libcore-windows → libcore.dll + HiddifyCli.exe
  * build-libcore-macos → libcore.dylib + HiddifyCli
  * build-libcore-linux → libcore.so + HiddifyCli

**正确的流程:**
1. 并行编译各平台的 libcore
2. 上传 libcore artifacts
3. 各平台构建任务下载对应的 libcore
4. 安装 Flutter 依赖
5. 构建 Flutter 应用

**影响:**
- 所有平台现在都会正确编译和使用 libcore
- libcore 版本锁定在 v3.1.7 (f993a57)
- 桌面平台现在可以正常构建和运行

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Rust 2025-10-27 23:30:52 +08:00
parent ed8afecf85
commit 2648fcc44f

View File

@ -52,10 +52,11 @@ on:
type: string
jobs:
# ==================== 编译 libcore ====================
build-libcore:
name: 编译 libcore
# ==================== 编译 libcore (Android) ====================
build-libcore-android:
name: 编译 libcore (Android)
runs-on: ubuntu-latest
if: contains(inputs.platforms || 'android', 'android')
steps:
- name: 📥 Checkout 代码
@ -87,7 +88,7 @@ jobs:
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
- name: 📦 编译 libcore.aar (Android)
- name: 📦 编译 libcore.aar
working-directory: libcore
run: |
echo "🚀 开始编译 Android libcore..."
@ -95,8 +96,7 @@ jobs:
if [ -f "bin/libcore.aar" ]; then
echo "✅ libcore.aar 生成成功"
mkdir -p ../android/app/libs/
cp bin/libcore.aar ../android/app/libs/
ls -lh bin/libcore.aar
else
echo "❌ libcore.aar 未找到"
exit 1
@ -105,14 +105,165 @@ jobs:
- name: 📤 上传 libcore.aar
uses: actions/upload-artifact@v4
with:
name: libcore-aar
path: android/app/libs/libcore.aar
name: libcore-android
path: libcore/bin/libcore.aar
retention-days: 7
# ==================== 编译 libcore (Windows) ====================
build-libcore-windows:
name: 编译 libcore (Windows)
runs-on: ubuntu-latest
if: contains(inputs.platforms || 'windows', 'windows')
steps:
- name: 📥 Checkout 代码
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: 🔧 设置 Go 环境
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: libcore/go.sum
- name: 🔧 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 🔧 安装 MinGW (交叉编译工具)
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64
- name: 📦 编译 libcore.dll
working-directory: libcore
run: |
echo "🚀 开始编译 Windows libcore..."
make windows-amd64
if [ -f "bin/libcore.dll" ] && [ -f "bin/HiddifyCli.exe" ]; then
echo "✅ Windows libcore 编译成功"
ls -lh bin/libcore.dll bin/HiddifyCli.exe
else
echo "❌ Windows libcore 编译失败"
exit 1
fi
- name: 📤 上传 Windows libcore
uses: actions/upload-artifact@v4
with:
name: libcore-windows
path: |
libcore/bin/libcore.dll
libcore/bin/HiddifyCli.exe
libcore/bin/webui/**
retention-days: 7
# ==================== 编译 libcore (macOS) ====================
build-libcore-macos:
name: 编译 libcore (macOS)
runs-on: macos-latest
if: contains(inputs.platforms || 'macos', 'macos')
steps:
- name: 📥 Checkout 代码
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: 🔧 设置 Go 环境
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: libcore/go.sum
- name: 🔧 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 📦 编译 libcore.dylib
working-directory: libcore
run: |
echo "🚀 开始编译 macOS libcore..."
make macos-universal
if [ -f "bin/libcore.dylib" ] && [ -f "bin/HiddifyCli" ]; then
echo "✅ macOS libcore 编译成功"
ls -lh bin/libcore.dylib bin/HiddifyCli
else
echo "❌ macOS libcore 编译失败"
exit 1
fi
- name: 📤 上传 macOS libcore
uses: actions/upload-artifact@v4
with:
name: libcore-macos
path: |
libcore/bin/libcore.dylib
libcore/bin/HiddifyCli
retention-days: 7
# ==================== 编译 libcore (Linux) ====================
build-libcore-linux:
name: 编译 libcore (Linux)
runs-on: ubuntu-latest
if: contains(inputs.platforms || 'linux', 'linux')
steps:
- name: 📥 Checkout 代码
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: 🔧 设置 Go 环境
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: libcore/go.sum
- name: 🔧 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: 📦 编译 libcore.so
working-directory: libcore
run: |
echo "🚀 开始编译 Linux libcore..."
make linux-amd64
if [ -f "bin/lib/libcore.so" ] && [ -f "bin/HiddifyCli" ]; then
echo "✅ Linux libcore 编译成功"
ls -lh bin/lib/libcore.so bin/HiddifyCli
else
echo "❌ Linux libcore 编译失败"
exit 1
fi
- name: 📤 上传 Linux libcore
uses: actions/upload-artifact@v4
with:
name: libcore-linux
path: |
libcore/bin/lib/libcore.so
libcore/bin/HiddifyCli
libcore/bin/webui/**
retention-days: 7
# ==================== Android 构建 ====================
build-android:
name: 构建 Android APK
needs: build-libcore
needs: build-libcore-android
runs-on: ubuntu-latest
if: contains(inputs.platforms || 'android', 'android')
@ -139,7 +290,7 @@ jobs:
- name: 📥 下载 libcore.aar
uses: actions/download-artifact@v4
with:
name: libcore-aar
name: libcore-android
path: android/app/libs/
- name: ⚙️ 配置 API 和 OSS
@ -163,7 +314,7 @@ jobs:
echo "✅ 配置完成"
- name: 📦 安装依赖
- name: 📦 安装 Flutter 依赖
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
@ -197,6 +348,7 @@ jobs:
# ==================== Windows 构建 ====================
build-windows:
name: 构建 Windows
needs: build-libcore-windows
runs-on: windows-latest
if: contains(inputs.platforms || 'windows', 'windows')
@ -214,6 +366,12 @@ jobs:
channel: 'stable'
cache: true
- name: 📥 下载 Windows libcore
uses: actions/download-artifact@v4
with:
name: libcore-windows
path: libcore/bin/
- name: ⚙️ 配置 API 和 OSS
shell: bash
run: |
@ -230,7 +388,7 @@ jobs:
sed -i "s|https://xpp4\.oss-ap-northeast-2\.aliyuncs\.com/bear1\.txt|$OSS_URL_3|g" "$CONFIG_FILE"
sed -i "s|https://xpp5\.oss-ap-southeast-1\.aliyuncs\.com/bear1\.txt|$OSS_URL_4|g" "$CONFIG_FILE"
- name: 📦 安装依赖
- name: 📦 安装 Flutter 依赖
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
@ -258,6 +416,7 @@ jobs:
# ==================== macOS 构建 ====================
build-macos:
name: 构建 macOS
needs: build-libcore-macos
runs-on: macos-latest
if: contains(inputs.platforms || 'macos', 'macos')
@ -275,6 +434,16 @@ jobs:
channel: 'stable'
cache: true
- name: 📥 下载 macOS libcore
uses: actions/download-artifact@v4
with:
name: libcore-macos
path: libcore/bin/
- name: 🔧 设置 libcore 执行权限
run: |
chmod +x libcore/bin/HiddifyCli
- name: ⚙️ 配置 API 和 OSS
run: |
CONFIG_FILE="lib/app/common/app_config.dart"
@ -290,7 +459,7 @@ jobs:
sed -i '' "s|https://xpp4\.oss-ap-northeast-2\.aliyuncs\.com/bear1\.txt|$OSS_URL_3|g" "$CONFIG_FILE"
sed -i '' "s|https://xpp5\.oss-ap-southeast-1\.aliyuncs\.com/bear1\.txt|$OSS_URL_4|g" "$CONFIG_FILE"
- name: 📦 安装依赖
- name: 📦 安装 Flutter 依赖
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
@ -317,6 +486,7 @@ jobs:
# ==================== Linux 构建 ====================
build-linux:
name: 构建 Linux
needs: build-libcore-linux
runs-on: ubuntu-latest
if: contains(inputs.platforms || 'linux', 'linux')
@ -347,6 +517,16 @@ jobs:
channel: 'stable'
cache: true
- name: 📥 下载 Linux libcore
uses: actions/download-artifact@v4
with:
name: libcore-linux
path: libcore/bin/
- name: 🔧 设置 libcore 执行权限
run: |
chmod +x libcore/bin/HiddifyCli
- name: ⚙️ 配置 API 和 OSS
run: |
CONFIG_FILE="lib/app/common/app_config.dart"
@ -362,7 +542,7 @@ jobs:
sed -i "s|https://xpp4\.oss-ap-northeast-2\.aliyuncs\.com/bear1\.txt|$OSS_URL_3|g" "$CONFIG_FILE"
sed -i "s|https://xpp5\.oss-ap-southeast-1\.aliyuncs\.com/bear1\.txt|$OSS_URL_4|g" "$CONFIG_FILE"
- name: 📦 安装依赖
- name: 📦 安装 Flutter 依赖
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
@ -419,7 +599,7 @@ jobs:
### ✨ 主要特性
- ✅ 支持 Shadowsocks/VLESS/Trojan/Hysteria2
- ✅ 内置 sing-box 核心
- ✅ 内置 sing-box 核心 v3.1.7
- ✅ 跨平台支持
- ✅ 自定义路由规则
@ -436,6 +616,7 @@ jobs:
- 提交: ${GITHUB_SHA::7}
- 时间: $(date '+%Y-%m-%d %H:%M:%S UTC')
- Flutter: 3.24.5
- sing-box: v3.1.7
EOF
echo "release_notes<<EOF" >> $GITHUB_OUTPUT