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 }}