diff --git a/.github/workflows/build-multiplatform.yml b/.github/workflows/build-multiplatform.yml index bcc7de4..e32cb06 100644 --- a/.github/workflows/build-multiplatform.yml +++ b/.github/workflows/build-multiplatform.yml @@ -51,12 +51,58 @@ on: default: 'c0qhq99a-nq8h-ropg-wrlc-ezj4dlkxqpzx' type: string platforms: - description: '构建平台 (多选: android,windows,macos,linux)' + description: '构建平台 (多选: android,windows,macos,linux,ios)' required: true default: 'android,windows,macos,linux' type: string jobs: + # ==================== 编译 libcore (iOS/tvOS) ==================== + build-libcore-ios: + name: 编译 libcore (iOS/tvOS) + runs-on: macos-latest + if: contains(inputs.platforms || 'ios', 'ios') + + 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.xcframework (支持 iOS/tvOS) + working-directory: libcore + run: | + echo "🚀 开始编译 iOS/tvOS libcore..." + make ios-full + + if [ -d "bin/Libcore.xcframework" ]; then + echo "✅ iOS/tvOS libcore 编译成功" + ls -lh bin/ + else + echo "❌ iOS/tvOS libcore 编译失败" + exit 1 + fi + + - name: 📤 上传 iOS libcore + uses: actions/upload-artifact@v4 + with: + name: libcore-ios + path: libcore/bin/Libcore.xcframework + retention-days: 7 + # ==================== 编译 libcore (Android) ==================== build-libcore-android: name: 编译 libcore (Android) @@ -707,10 +753,90 @@ jobs: path: BearVPN-linux-*.tar.gz retention-days: 30 + # ==================== iOS 构建 ==================== + build-ios: + name: 构建 iOS + needs: build-libcore-ios + runs-on: macos-latest + if: contains(inputs.platforms || 'ios', 'ios') + + steps: + - name: 📥 Checkout 代码 + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: 🔧 设置 Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.24.5' + channel: 'stable' + cache: true + + - name: 📥 下载 iOS libcore + uses: actions/download-artifact@v4 + with: + name: libcore-ios + path: ios/Frameworks/ + + - name: ⚙️ 配置 API、OSS 和加密密钥 + run: | + CONFIG_FILE="lib/app/common/app_config.dart" + API_DOMAIN="${{ inputs.api_domain || 'api.maodag.top' }}" + OSS_URL_1="${{ inputs.oss_url_1 || 'https://ppp2.oss-cn-hongkong.aliyuncs.com/bear1.txt' }}" + OSS_URL_2="${{ inputs.oss_url_2 || 'https://xgp3.oss-ap-northeast-1.aliyuncs.com/bear1.txt' }}" + OSS_URL_3="${{ inputs.oss_url_3 || 'https://xpp4.oss-ap-northeast-2.aliyuncs.com/bear1.txt' }}" + OSS_URL_4="${{ inputs.oss_url_4 || 'https://xpp5.oss-ap-southeast-1.aliyuncs.com/bear1.txt' }}" + ENCRYPTION_KEY="${{ inputs.encryption_key || 'c0qhq99a-nq8h-ropg-wrlc-ezj4dlkxqpzx' }}" + + # 使用 perl 转义特殊字符 + ENCRYPTION_KEY_ESCAPED=$(echo "$ENCRYPTION_KEY" | perl -pe 's/([\[\].*^$()+?{|\\])/\\$1/g') + + sed -i '' "s|api\.maodag\.top|$API_DOMAIN|g" "$CONFIG_FILE" + sed -i '' "s|https://ppp2\.oss-cn-hongkong\.aliyuncs\.com/bear1\.txt|$OSS_URL_1|g" "$CONFIG_FILE" + sed -i '' "s|https://xgp3\.oss-ap-northeast-1\.aliyuncs\.com/bear1\.txt|$OSS_URL_2|g" "$CONFIG_FILE" + 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" + sed -i '' "s|c0qhq99a-nq8h-ropg-wrlc-ezj4dlkxqpzx|$ENCRYPTION_KEY_ESCAPED|g" "$CONFIG_FILE" + + - name: 📦 安装 Flutter 依赖 + run: | + flutter pub get + flutter pub run build_runner build --delete-conflicting-outputs + + - name: 🔨 构建 iOS (Release) + run: | + flutter build ios --release --no-codesign + + - name: 📦 打包 iOS + run: | + COMMIT_SHA=${GITHUB_SHA::7} + DATE=$(date '+%Y%m%d') + + cd build/ios/iphoneos + + # 创建 Payload 目录 + mkdir -p Payload + cp -r Runner.app Payload/ + + # 创建 IPA 文件 + zip -r "../../../../BearVPN-ios-release-${DATE}-${COMMIT_SHA}.ipa" Payload + + echo "✅ iOS IPA 创建完成" + ls -lh BearVPN-ios-*.ipa + + - name: 📤 上传 iOS + uses: actions/upload-artifact@v4 + with: + name: ios-app + path: BearVPN-ios-*.ipa + retention-days: 30 + # ==================== 创建 Release ==================== create-release: name: 创建 Release - needs: [build-android, build-windows, build-macos, build-linux] + needs: [build-android, build-windows, build-macos, build-linux, build-ios] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') @@ -733,6 +859,7 @@ jobs: | **Android** | arm64-v8a | BearVPN-android-arm64-v8a-*.apk | | **Android** | armeabi-v7a | BearVPN-android-armeabi-v7a-*.apk | | **Android** | x86_64 | BearVPN-android-x86_64-*.apk | + | **iOS** | Universal | BearVPN-ios-*.ipa | | **Windows** | x64 | BearVPN-windows-x64-*.zip | | **macOS** | Universal | BearVPN-macos-*.zip | | **Linux** | x64 | BearVPN-linux-x64-*.tar.gz | @@ -747,6 +874,7 @@ jobs: ### 📥 安装指南 **Android:** 下载 APK 直接安装 + **iOS:** 下载 IPA 使用 AltStore/Sideloadly 安装 **Windows:** 解压 ZIP 运行 BearVPN.exe **macOS:** 解压 ZIP 拖拽到应用程序 **Linux:** 解压 tar.gz 运行可执行文件 @@ -769,6 +897,7 @@ jobs: with: files: | artifacts/android-apk/*.apk + artifacts/ios-app/*.ipa artifacts/windows-x64/*.zip artifacts/macos-app/*.zip artifacts/linux-x64/*.tar.gz