hi-client/.github/workflows/build-clash-core.yml
shanshanzhong 6dfad4544d
Some checks failed
Build Android APK / 编译 Android APK (release) (push) Has been skipped
Build Clash Core / Build Android (arm64) (push) Failing after 7s
Build Multi-Platform / 编译 libcore (iOS/tvOS) (push) Has been skipped
Build Android APK / 编译 libcore.aar (push) Failing after 10s
Build Clash Core / Build Android (armv7) (push) Failing after 7s
Build Clash Core / Build Android (x86_64) (push) Failing after 8s
Build Clash Core / Create Release (push) Has been skipped
Build Multi-Platform / 编译 libcore (Android) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Windows) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (macOS) (push) Has been cancelled
Build Multi-Platform / 编译 libcore (Linux) (push) Has been cancelled
Build Multi-Platform / 构建 Android APK (push) Has been cancelled
Build Multi-Platform / 构建 macOS (push) Has been cancelled
Build Multi-Platform / 构建 Linux (push) Has been cancelled
Build Multi-Platform / 构建 iOS (push) Has been cancelled
Build Multi-Platform / 构建 Windows (push) Has been skipped
Build Android APK / 创建 GitHub Release (push) Has been cancelled
Build Multi-Platform / 创建 Release (push) Has been cancelled
ci: 添加多平台构建工作流
添加三个 GitHub Actions 工作流文件:
1. build-clash-core.yml - 构建 Android 核心库
2. build-android-apk.yml - 构建 Android APK
3. build-multiplatform.yml - 支持多平台构建(Android/iOS/Windows/macOS/Linux)

工作流支持自动触发和手动触发,包含构建、测试、打包和发布功能
2025-11-06 17:27:25 -08:00

143 lines
4.2 KiB
YAML

name: Build Clash Core
on:
push:
paths:
- 'core/**'
- '.github/workflows/build-clash-core.yml'
pull_request:
paths:
- 'core/**'
workflow_dispatch: # 允许手动触发
jobs:
build-android:
name: Build Android (${{ matrix.arch }})
runs-on: client-server
strategy:
fail-fast: false
matrix:
include:
- arch: arm64
abi: arm64-v8a
cc: aarch64-linux-android29-clang
- arch: armv7
abi: armeabi-v7a
cc: armv7a-linux-androideabi29-clang
- arch: x86_64
abi: x86_64
cc: x86_64-linux-android29-clang
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
cache: true
cache-dependency-path: core/go.sum
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r25c
add-to-path: true
- name: Build Core
working-directory: core
run: make android-${{ matrix.arch }}
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Verify Build
run: |
echo "📦 检查编译产物..."
ls -lh android/app/src/main/jniLibs/${{ matrix.abi }}/libclash.so
file android/app/src/main/jniLibs/${{ matrix.abi }}/libclash.so
echo "🔍 验证导出函数..."
nm -D android/app/src/main/jniLibs/${{ matrix.abi }}/libclash.so | grep -E "(quickStart|getAndroidVpnOptions|startTUN)"
- name: Calculate MD5
id: md5
run: |
MD5=$(md5sum android/app/src/main/jniLibs/${{ matrix.abi }}/libclash.so | awk '{print $1}')
echo "md5=$MD5" >> $GITHUB_OUTPUT
echo "📋 MD5: $MD5"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: libclash-${{ matrix.abi }}
path: android/app/src/main/jniLibs/${{ matrix.abi }}/libclash.so
retention-days: 30
if-no-files-found: error
- name: Comment Build Info
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const stats = fs.statSync('android/app/src/main/jniLibs/${{ matrix.abi }}/libclash.so');
const sizeMB = (stats.size / 1024 / 1024).toFixed(2);
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `### 🔨 Clash Core 构建完成 (${{ matrix.abi }})
- **架构:** ${{ matrix.abi }}
- **大小:** ${sizeMB} MB
- **MD5:** ${{ steps.md5.outputs.md5 }}
- **提交:** ${context.sha.substring(0, 7)}
[下载构建产物](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`
});
create-release:
name: Create Release
needs: build-android
runs-on: client-server
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release Archive
run: |
cd artifacts
tar -czf clash-core-android-all.tar.gz libclash-*/*.so
ls -lh clash-core-android-all.tar.gz
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/clash-core-android-all.tar.gz
body: |
## Clash Meta 核心 Android 构建
此版本包含所有 Android 架构的预编译二进制文件:
- arm64-v8a (ARM64)
- armeabi-v7a (ARMv7)
- x86_64 (模拟器)
**使用方法:**
```bash
tar -xzf clash-core-android-all.tar.gz
cp libclash-*/libclash.so android/app/src/main/jniLibs/
```
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}