Files
UUVPN/.github/workflows/build-debug.yml
T

241 lines
7.9 KiB
YAML

name: Build Debug
on:
push:
branches:
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:
jobs:
# ==================== Android Debug 构建 ====================
build-android-debug:
name: Build Android Debug APK
runs-on: ubuntu-latest
if: false # 暂时禁用 Android 构建
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
lfs: true
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Grant execute permission for gradlew
run: |
cd Android-kotlin-Code
chmod +x gradlew
- name: Create local.properties
run: |
cd Android-kotlin-Code
echo "sdk.dir=$ANDROID_HOME" > local.properties
- name: Build Android Debug APK
run: |
cd Android-kotlin-Code
./gradlew app:assembleDebug --stacktrace
- name: Upload Android Debug APK
uses: actions/upload-artifact@v4
with:
name: android-debug-apk
path: Android-kotlin-Code/app/build/outputs/apk/**/*.apk
retention-days: 7
# ==================== iOS Debug 构建 ====================
build-ios-debug:
name: Build iOS Debug App
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
lfs: true
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '26.3'
- name: Show Xcode version
run: |
xcodebuild -version
swift --version
- name: Resolve Swift Package Dependencies
run: |
cd iOS-SwiftUI-Code
xcodebuild -resolvePackageDependencies -project uuvpn.xcodeproj -scheme SFI
- name: Verify Libbox framework exists
run: |
cd iOS-SwiftUI-Code
echo "Checking Libbox.xcframework..."
if [ -d "Libbox.xcframework" ]; then
echo "✅ Libbox.xcframework exists"
ls -lh Libbox.xcframework/
echo "Checking simulator variant..."
if [ -d "Libbox.xcframework/ios-arm64_x86_64-simulator" ]; then
echo "✅ Simulator variant exists"
ls -lh Libbox.xcframework/ios-arm64_x86_64-simulator/Libbox.framework/
file Libbox.xcframework/ios-arm64_x86_64-simulator/Libbox.framework/Versions/A/Libbox || echo "Binary file check"
else
echo "❌ Simulator variant NOT found!"
exit 1
fi
else
echo "❌ Libbox.xcframework NOT found!"
exit 1
fi
- name: List available schemes
run: |
cd iOS-SwiftUI-Code
xcodebuild -list -project uuvpn.xcodeproj
- name: Build iOS Debug App (attempt 1 - with verbose output)
id: build_attempt_1
run: |
cd iOS-SwiftUI-Code
xcodebuild clean build \
-project uuvpn.xcodeproj \
-scheme SFI \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone Air,OS=26.2' \
-configuration Debug \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
2>&1 | tee build_output.log
# 检查构建结果
if grep -q "BUILD SUCCEEDED" build_output.log; then
echo "✅ BUILD SUCCEEDED"
echo "build_status=succeeded" >> $GITHUB_OUTPUT
else
echo "❌ BUILD FAILED"
echo "Last 50 lines of build log:"
tail -50 build_output.log
echo "build_status=failed" >> $GITHUB_OUTPUT
exit 1
fi
# 显示构建产物目录
echo "Checking DerivedData directory for .app files..."
find ~/Library/Developer/Xcode/DerivedData -name "*.app" -type d || echo "No .app found in DerivedData"
- name: Check if build succeeded
if: failure()
run: |
echo "Build failed. Checking error messages..."
cd iOS-SwiftUI-Code
cat build_output.log | grep -A 10 "error:" || echo "No specific error found"
exit 1
- name: Find and upload iOS Debug App
run: |
cd iOS-SwiftUI-Code
# 显示 DerivedData 目录结构
echo "Searching for .app files in DerivedData..."
find ~/Library/Developer/Xcode/DerivedData -name "*.app" -type d
# 显示 Build 目录结构
echo "Searching for .app files in Build directory..."
find ./build -name "*.app" -type d || echo "No build directory found"
# 尝试多个可能的路径
APP_PATH=""
# 方法1: 从 DerivedData 查找
APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData -name "SFI.app" -type d | head -n 1)
# 方法2: 如果没找到,查找任何 .app 文件
if [ -z "$APP_PATH" ]; then
APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData -name "*.app" -type d | head -n 1)
fi
# 方法3: 从 Build 目录查找
if [ -z "$APP_PATH" ]; then
APP_PATH=$(find ./build -name "*.app" -type d | head -n 1)
fi
# 方法4: 使用 xcodebuild 显示构建产物路径
if [ -z "$APP_PATH" ]; then
echo "Getting build settings to find target build dir..."
# 获取模拟器构建目录 (Debug-iphonesimulator)
BUILD_DIR=$(xcodebuild -project uuvpn.xcodeproj -scheme SFI -sdk iphonesimulator -showBuildSettings | grep "TARGET_BUILD_DIR" | cut -d '=' -f 2 | tr -d ' ')
echo "TARGET_BUILD_DIR (Simulator): $BUILD_DIR"
if [ -n "$BUILD_DIR" ] && [ -d "$BUILD_DIR" ]; then
echo "Contents of TARGET_BUILD_DIR:"
ls -la "$BUILD_DIR" || true
APP_PATH=$(find "$BUILD_DIR" -name "*.app" -type d | head -n 1)
fi
fi
# 方法5: 直接查找模拟器构建目录
if [ -z "$APP_PATH" ]; then
echo "Searching in Debug-iphonesimulator directory..."
APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData -path "*Debug-iphonesimulator*.app" -type d | head -n 1)
fi
# 方法6: 列出所有 DerivedData 内容
if [ -z "$APP_PATH" ]; then
echo "Listing ALL contents in DerivedData..."
find ~/Library/Developer/Xcode/DerivedData -type d -name "*.app" 2>/dev/null || true
find ~/Library/Developer/Xcode/DerivedData -type d -name "Build" 2>/dev/null || true
ls -R ~/Library/Developer/Xcode/DerivedData/ 2>/dev/null | head -100 || true
fi
if [ -n "$APP_PATH" ] && [ -d "$APP_PATH" ]; then
echo "✅ Found app at: $APP_PATH"
echo "App size:"
du -sh "$APP_PATH"
# 复制到 build 目录
mkdir -p build
cp -R "$APP_PATH" build/
# 创建 zip 文件
cd build
APP_NAME=$(basename "$APP_PATH")
zip -r ios-debug-app.zip "$APP_NAME"
echo "✅ Created zip file: ios-debug-app.zip"
ls -lh ios-debug-app.zip
else
echo "❌ No .app file found in any location"
echo "Listing all files in DerivedData..."
ls -R ~/Library/Developer/Xcode/DerivedData/uuvpn*/Build/Products/ || true
exit 1
fi
- name: Upload iOS Debug App
uses: actions/upload-artifact@v4
with:
name: ios-debug-app
path: iOS-SwiftUI-Code/build/ios-debug-app.zip
retention-days: 7