Files
UUVPN/.github/workflows/build-debug.yml
T
admin 5eaa8c2b49
Build Debug / Build Android Debug APK (push) Successful in 3m53s
Build UUVPN / Build Android APK (push) Successful in 2m48s
Build UUVPN / Cleanup old artifacts (push) Failing after 1s
Build Debug / Build iOS Debug App (push) Has been cancelled
Build UUVPN / Build iOS IPA (push) Has been cancelled
Build UUVPN / Create GitHub Release (push) Has been cancelled
Build UUVPN / Upload to TestFlight (push) Has been cancelled
Build UUVPN / Send Notification (push) Has been cancelled
Fix: Replace upload-artifact action in build-debug.yml with simple file copy
2026-07-04 14:36:29 +08:00

305 lines
11 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
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Install Node.js
run: |
export PATH="/toolcache/bin:$PATH"
if ! command -v node &> /dev/null; then
if command -v apk &> /dev/null; then
apk add --no-cache nodejs npm
else
curl -fsSL https://nodejs.org/dist/v20.0.0/node-v20.0.0-linux-x64.tar.xz | tar -xJ -C /tmp
mkdir -p /toolcache
cp -r /tmp/node-v20.0.0-linux-x64/{bin,lib,share} /toolcache/
fi
fi
node --version
- name: Install Git LFS
run: |
if command -v apk &> /dev/null; then
apk add --no-cache git-lfs
elif command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y git-lfs
else
curl -sL https://github.com/git-lfs/git-lfs/releases/download/v3.5.1/git-lfs-linux-amd64-v3.5.1.tar.gz | tar xz -C /tmp
mv /tmp/git-lfs-3.5.1/git-lfs /toolcache/bin/
fi
git lfs install
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Pull Git LFS files
run: |
git lfs install
git lfs pull || echo "LFS pull failed, continuing without LFS files (Android build doesn't need them)"
- name: Install Java 17
run: |
if command -v apk &> /dev/null; then
# Enable community repository for openjdk17-jdk
sed -i 's/^#.*\/community\/.*$/\0/' /etc/apk/repositories || true
echo "https://dl-cdn.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
apk update
apk add --no-cache openjdk17-jdk
echo "JAVA_HOME=/usr/lib/jvm/java-17-openjdk" >> $GITHUB_ENV
elif command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y openjdk-17-jdk
echo "JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" >> $GITHUB_ENV
else
curl -sL https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jdk_x64_linux_hotspot_17.0.9_9.tar.gz | tar xz -C /toolcache
echo "JAVA_HOME=/toolcache/jdk-17.0.9+9" >> $GITHUB_ENV
echo "/toolcache/jdk-17.0.9+9/bin" >> $GITHUB_PATH
fi
java -version
- name: Install Go 1.23
run: |
# Create toolcache directory if not exists
mkdir -p /toolcache
# Install curl if not available (Alpine uses apk)
if ! command -v curl &> /dev/null; then
if command -v apk &> /dev/null; then
apk add --no-cache curl
fi
fi
# Download Go 1.23 directly to ensure correct version
curl -sL https://go.dev/dl/go1.23.0.linux-amd64.tar.gz | tar xz -C /toolcache
echo "/toolcache/go/bin" >> $GITHUB_PATH
echo "GOROOT=/toolcache/go" >> $GITHUB_ENV
/toolcache/go/bin/go version
- 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: List APK files
run: |
echo "Listing APK files..."
find Android-kotlin-Code/app/build/outputs/apk -name "*.apk" -type f || echo "No APK files found"
ls -la Android-kotlin-Code/app/build/outputs/apk/ || true
- name: Copy APK to artifacts
run: |
mkdir -p /tmp/artifacts
find Android-kotlin-Code/app/build/outputs/apk -name "*.apk" -type f -exec cp {} /tmp/artifacts/ \;
ls -la /tmp/artifacts/
echo "APK files copied to /tmp/artifacts"
# ==================== 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
- name: Setup Git LFS
run: |
git lfs install
git lfs pull
- name: Verify Libbox framework before build
run: |
echo "========================================"
echo "Checking Libbox.xcframework..."
echo "========================================"
cd iOS-SwiftUI-Code
if [ -d "Libbox.xcframework" ]; then
echo "✅ Libbox.xcframework directory exists"
ls -lh Libbox.xcframework/
# 检查模拟器版本
if [ -d "Libbox.xcframework/ios-arm64_x86_64-simulator/Libbox.framework/Versions/A" ]; then
echo "✅ Simulator framework structure exists"
# 检查二进制文件
LIBBOX_BINARY="Libbox.xcframework/ios-arm64_x86_64-simulator/Libbox.framework/Versions/A/Libbox"
if [ -f "$LIBBOX_BINARY" ]; then
echo "✅ Libbox binary file exists"
# 获取文件大小 (macOS 和 Linux 兼容)
FILE_SIZE=$(stat -f%z "$LIBBOX_BINARY" 2>/dev/null || stat -c%s "$LIBBOX_BINARY" 2>/dev/null)
echo "Binary file size: $FILE_SIZE bytes ($(( FILE_SIZE / 1024 / 1024 )) MB)"
# 检查文件是否是真实的二进制文件 (不是 Git placeholder)
if [ "$FILE_SIZE" -lt 1000 ]; then
echo "❌ ERROR: File size is too small! This is likely a Git placeholder"
echo "File content (first 200 bytes):"
head -c 200 "$LIBBOX_BINARY"
echo ""
echo "This means Git did not download the actual binary file."
exit 1
else
echo "✅ File size is normal, binary appears to be downloaded correctly"
echo "File type:"
file "$LIBBOX_BINARY" || echo "Binary file exists"
fi
else
echo "❌ ERROR: Libbox binary file NOT found at: $LIBBOX_BINARY"
echo "Listing directory contents:"
ls -la Libbox.xcframework/ios-arm64_x86_64-simulator/Libbox.framework/Versions/A/ || true
exit 1
fi
else
echo "❌ ERROR: Simulator framework structure NOT found"
echo "Listing Libbox.xcframework contents:"
find Libbox.xcframework -type d -name "*.framework" || true
exit 1
fi
else
echo "❌ ERROR: Libbox.xcframework directory NOT found!"
echo "Listing iOS-SwiftUI-Code directory:"
ls -la
exit 1
fi
- 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: List available schemes
run: |
cd iOS-SwiftUI-Code
xcodebuild -list -project uuvpn.xcodeproj
- name: Diagnose Libbox module
run: |
cd iOS-SwiftUI-Code
echo "=== Libbox.xcframework Info.plist ==="
cat Libbox.xcframework/Info.plist
echo ""
echo "=== Simulator module.modulemap ==="
cat Libbox.xcframework/ios-arm64_x86_64-simulator/Libbox.framework/Versions/A/Modules/module.modulemap
echo ""
echo "=== Simulator Headers ==="
ls -la Libbox.xcframework/ios-arm64_x86_64-simulator/Libbox.framework/Versions/A/Headers/
echo ""
echo "=== Check for Swift module interface ==="
find Libbox.xcframework/ios-arm64_x86_64-simulator -name "*.swiftmodule" -o -name "*.swiftinterface" 2>/dev/null || echo "No Swift module interface found"
echo ""
echo "=== Check Modules directory ==="
ls -la Libbox.xcframework/ios-arm64_x86_64-simulator/Libbox.framework/Versions/A/Modules/
- name: Build iOS Debug App
id: build
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 "=== Error lines from build log ==="
grep -i "error:" build_output.log || echo "No 'error:' lines found"
echo ""
echo "=== Last 100 lines of build log ==="
tail -100 build_output.log
echo "build_status=failed" >> $GITHUB_OUTPUT
exit 1
fi
- name: Find and upload iOS Debug App
if: success()
run: |
cd iOS-SwiftUI-Code
# 查找 .app 文件
echo "Searching for .app files in DerivedData..."
APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData -name "SFI.app" -type d | head -n 1)
if [ -z "$APP_PATH" ]; then
APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData -name "*.app" -type d | head -n 1)
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 DerivedData"
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