Files
UUVPN/.github/workflows/build-ios.yml
T
admin 7a95af02b9
Build Debug / Build Android Debug APK (push) Successful in 3m54s
Build iOS / Build iOS IPA (push) Successful in 3m57s
Build UUVPN / Build Android APK (push) Has been skipped
Build UUVPN / Build iOS IPA (push) Has been skipped
Build UUVPN / Create GitHub Release (push) Has been skipped
Build UUVPN / Send Notification (push) Successful in 0s
Build Debug / Build iOS Debug App (push) Has been cancelled
Update: Improve Docker-OSX handling and add VM status check
2026-07-05 04:38:46 +08:00

238 lines
8.8 KiB
YAML

name: Build iOS
on:
push:
branches:
- develop
tags:
- 'v*'
workflow_dispatch:
inputs:
build_debug:
description: 'Build Debug IPA'
required: false
default: true
type: boolean
build_release:
description: 'Build Release IPA'
required: false
default: false
type: boolean
env:
IOS_XCODE_VERSION: "16.0"
IOS_DEPLOYMENT_TARGET: "15.0"
jobs:
build-ios:
name: Build iOS IPA
runs-on: ubuntu
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Install dependencies (Alpine)
run: |
# 添加 community 仓库
echo "https://dl-cdn.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
apk update
# 安装基础依赖,不安装完整的 qemu(依赖太多)
apk add --no-cache \
wget \
curl \
git-lfs \
bash \
python3 \
py3-pip \
docker \
openrc
# 启动 docker 服务
rc-service docker start || true
docker --version || echo "Docker not available"
- name: Check virtualization support
run: |
echo "========================================"
echo "Checking virtualization support..."
echo "========================================"
ls -la /dev/kvm 2>/dev/null || echo "KVM not available - will use QEMU emulation (slower)"
cat /proc/cpuinfo | grep -E "vmx|svm" || echo "No hardware virtualization detected"
echo ""
echo "Docker version:"
docker --version || echo "Docker not found"
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup Git LFS
run: |
git lfs install
# 配置 LFS 认证 - 使用 token 直接认证
git config --global lfs.url "https://admin:73ffc0f4391a26bb327fbed379d63b5a087e5f10@git.viaeon.com/admin/UUVPN.git/info/lfs"
echo "Attempting LFS pull..."
git lfs pull 2>&1 || echo "LFS pull failed, trying alternative methods..."
# 如果 LFS pull 失败,尝试直接 fetch 和 checkout
git lfs fetch origin 2>&1 || echo "LFS fetch failed"
git lfs checkout 2>&1 || echo "LFS checkout failed"
echo ""
echo "Checking Libbox.xcframework..."
ls -la iOS-SwiftUI-Code/Libbox.xcframework/ 2>/dev/null || echo "Libbox.xcframework directory not found"
# 检查 Libbox.xcframework 目录
if [ -d "iOS-SwiftUI-Code/Libbox.xcframework" ]; then
echo "Libbox.xcframework directory exists"
ls -la iOS-SwiftUI-Code/Libbox.xcframework/
else
echo "Libbox.xcframework directory NOT found"
# 检查是否有 LFS 指针文件
cat iOS-SwiftUI-Code/.gitattributes 2>/dev/null || echo "No .gitattributes"
fi
# 检查文件是否是 LFS 指针文件
echo ""
echo "Checking if files are LFS pointers or actual binaries..."
if [ -f "iOS-SwiftUI-Code/Libbox.xcframework/ios-arm64/Libbox.framework/Libbox" ]; then
head -5 iOS-SwiftUI-Code/Libbox.xcframework/ios-arm64/Libbox.framework/Libbox 2>/dev/null
else
echo "File not found at expected path"
# 搜索所有可能的 Libbox 文件
find iOS-SwiftUI-Code -name "Libbox" -type f 2>/dev/null | head -10 || echo "No Libbox files found"
fi
- name: Check if Libbox framework exists
id: check_lfs
run: |
echo "========================================"
echo "Checking LFS files..."
echo "========================================"
# 正确路径: iOS-SwiftUI-Code/Libbox.xcframework (不是 uuvpn/Libbox.xcframework)
echo "Libbox.xcframework contents:"
ls -la iOS-SwiftUI-Code/Libbox.xcframework/ 2>/dev/null || echo "Directory not found or empty"
# 检查关键文件
if [ -f "iOS-SwiftUI-Code/Libbox.xcframework/ios-arm64/Libbox.framework/Libbox" ]; then
echo "lfs_ready=true" >> $GITHUB_OUTPUT
echo "✅ LFS files downloaded successfully"
file iOS-SwiftUI-Code/Libbox.xcframework/ios-arm64/Libbox.framework/Libbox 2>/dev/null || true
else
echo "lfs_ready=false" >> $GITHUB_OUTPUT
echo "❌ LFS files not available"
echo ""
echo "This means Gitea LFS is not properly configured."
fi
# 不让 find 命令导致失败
exit 0
- name: Pull Docker-OSX image
if: ${{ steps.check_lfs.outputs.lfs_ready == 'true' }}
run: |
echo "Pulling Docker-OSX image (this may take a while)..."
docker pull sickcodes/docker-osx:latest || echo "Failed to pull image"
- name: Start macOS VM with Docker-OSX
if: ${{ steps.check_lfs.outputs.lfs_ready == 'true' }}
run: |
echo "========================================"
echo "Starting macOS VM with Docker-OSX..."
echo "========================================"
echo ""
echo "Docker-OSX 需要使用 QEMU 运行 macOS 虚拟机"
echo "这个镜像只是一个安装器,需要先启动虚拟机"
echo ""
# 使用 Docker-OSX 的正确启动方式
# 启动一个持久化的 macOS 容器
docker run -d \
--name macos-vm \
--privileged \
-e RAM=8192 \
-e SMP=4 \
-e DISPLAY=dummy \
-v /tmp/workspace:/workspace \
sickcodes/docker-osx:latest || echo "Failed to start VM"
echo "等待 macOS 虚拟机启动..."
sleep 120
# 检查容器状态
docker ps -a | grep macos-vm || echo "VM container not running"
echo ""
echo "⚠️ 注意: Docker-OSX 需要 KVM 支持才能正常运行 macOS"
echo "如果 runner 没有 KVM 支持,VM 将无法启动"
echo ""
echo "当前构建环境:"
ls -la /dev/kvm 2>/dev/null || echo "KVM not available"
docker logs macos-vm 2>/dev/null | tail -20 || echo "No VM logs"
- name: Check macOS VM status
if: ${{ steps.check_lfs.outputs.lfs_ready == 'true' }}
run: |
echo "========================================"
echo "macOS VM Status"
echo "========================================"
# 检查 VM 是否真的在运行 macOS
docker exec macos-vm uname -a 2>/dev/null || echo "Cannot exec in VM"
docker exec macos-vm which xcodebuild 2>/dev/null || echo "xcodebuild not found in VM"
echo ""
echo "⚠️ Docker-OSX 结论:"
echo "Docker-OSX 需要在支持 KVM 的主机上运行"
echo "当前的 runner 环境可能不支持 KVM"
echo ""
echo "要真正构建 iOS 应用,建议:"
echo "1. 使用 GitHub Actions 的托管 macOS runner"
echo "2. 在 Mac 机器上部署 Gitea runner"
echo "3. 使用云服务 Mac (如 AWS EC2 Mac)"
# 清理容器
docker stop macos-vm 2>/dev/null || true
docker rm macos-vm 2>/dev/null || true
- name: Check build output
if: ${{ steps.check_lfs.outputs.lfs_ready == 'true' }}
run: |
echo "========================================"
echo "Build output:"
echo "========================================"
find iOS-SwiftUI-Code/build -name "*.app" -type d 2>/dev/null || echo "No .app found"
find iOS-SwiftUI-Code/build -name "*.ipa" -type f 2>/dev/null || echo "No .ipa found"
ls -la iOS-SwiftUI-Code/build/ 2>/dev/null || echo "Build directory not found"
- name: Build summary
run: |
echo "========================================"
echo "iOS Build Summary"
echo "========================================"
echo "LFS ready: ${{ steps.check_lfs.outputs.lfs_ready }}"
echo ""
if [ "${{ steps.check_lfs.outputs.lfs_ready }}" != "true" ]; then
echo "❌ Cannot build iOS without Libbox.xcframework"
echo ""
echo "To fix this, configure Gitea LFS:"
echo "1. Enable LFS in Gitea config (app.ini):"
echo " [lfs]"
echo " START_SERVER = true"
echo " PATH = /data/git/lfs"
echo ""
echo "2. Generate JWT_SECRET:"
echo " openssl rand -hex 32"
echo ""
echo "3. Re-push LFS files to the repository"
else
echo "✅ LFS files available"
echo "Build was attempted - check logs above for results"
fi