Files
UUVPN/.github/workflows/build.yml
T
admin a911f25a28
Build Debug / Build Android Debug APK (push) Successful in 4m24s
Build UUVPN / Build Android APK (push) Successful in 3m8s
Build UUVPN / Build iOS IPA (push) Failing after 1s
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
WIP: Add real iOS build steps with Docker-OSX and LFS check
2026-07-04 20:37:32 +08:00

382 lines
13 KiB
YAML

name: Build UUVPN
on:
push:
branches:
- main
- develop
tags:
- 'v*'
pull_request:
branches:
- main
workflow_dispatch:
inputs:
build_android:
description: 'Build Android APK'
required: false
default: true
type: boolean
build_ios:
description: 'Build iOS IPA'
required: false
default: true
type: boolean
release_type:
description: 'Release type'
required: false
default: 'alpha'
type: choice
options:
- alpha
- beta
- release
env:
# Android 配置
ANDROID_COMPILE_SDK: "33"
ANDROID_BUILD_TOOLS: "33.0.0"
ANDROID_TARGET_SDK: "33"
ANDROID_JDK_VERSION: "17"
# iOS 配置
IOS_XCODE_VERSION: "16.0"
IOS_DEPLOYMENT_TARGET: "15.0"
jobs:
# ==================== Android 构建 ====================
build-android:
name: Build Android APK
runs-on: ubuntu
if: ${{ github.event.inputs.build_android != 'false' }}
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 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
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: |
mkdir -p /toolcache
if ! command -v curl &> /dev/null; then
if command -v apk &> /dev/null; then
apk add --no-cache curl
fi
fi
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: Install gcompat (for NDK on Alpine)
run: |
# Install gcompat for running glibc binaries on Alpine (required for NDK clang)
if command -v apk &> /dev/null; then
apk add --no-cache gcompat libstdc++
fi
- 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: Create signing.properties (Debug)
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' }}
run: |
cd Android-kotlin-Code
echo "keystore.path=debug.keystore" > signing.properties
echo "keystore.password=android" >> signing.properties
echo "key.alias=androiddebugkey" >> signing.properties
echo "key.password=android" >> signing.properties
- name: Create signing.properties (Release)
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
cd Android-kotlin-Code
echo "keystore.path=release.keystore" > signing.properties
echo "keystore.password=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> signing.properties
echo "key.alias=${{ secrets.ANDROID_KEY_ALIAS }}" >> signing.properties
echo "key.password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> signing.properties
- name: Decode Android keystore
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
cd Android-kotlin-Code
echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > release.keystore
- name: Build Android Debug APK
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' }}
run: |
cd Android-kotlin-Code
./gradlew assembleAlphaDebug --stacktrace
- name: Build Android Release APK
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
cd Android-kotlin-Code
./gradlew assembleAlphaRelease --stacktrace
- name: Build Android APK (Default)
if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v') && github.ref != 'refs/heads/develop' }}
run: |
cd Android-kotlin-Code
./gradlew assembleAlphaRelease --stacktrace
- name: Upload Android APK Artifact
run: |
# Copy APK to a known location for artifact upload
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"
- name: Get APK filename
id: apk_name
run: |
if [ "${{ startsWith(github.ref, 'refs/tags/v') }}" = "true" ]; then
APK_NAME="UUVPN-Android-${{ github.ref_name }}.apk"
else
APK_NAME="UUVPN-Android-${{ github.sha }}.apk"
fi
echo "apk_name=$APK_NAME" >> $GITHUB_OUTPUT
# Find the APK file
APK_PATH=$(find Android-kotlin-Code/app/build/outputs/apk -name "*.apk" -type f | head -1)
echo "apk_path=$APK_PATH" >> $GITHUB_OUTPUT
echo "Found APK: $APK_PATH"
- name: Rename APK for release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
cd Android-kotlin-Code/app/build/outputs/apk
find . -name "*.apk" -type f -exec mv {} "${{ steps.apk_name.outputs.apk_name }}" \;
# ==================== iOS 构建 (Docker-OSX) ====================
build-ios:
name: Build iOS IPA
runs-on: ubuntu
if: ${{ github.event.inputs.build_ios != 'false' }}
steps:
- name: Install dependencies
run: |
apt-get update && apt-get install -y qemu-utils wget
- name: Check virtualization support
run: |
echo "Checking virtualization support..."
ls -la /dev/kvm || echo "KVM not available - will use QEMU emulation"
cat /proc/cpuinfo | grep -E "vmx|svm" || echo "No hardware virtualization detected"
- name: Download macOS base image
run: |
echo "Downloading macOS base image..."
mkdir -p /tmp/osx
# Use a pre-built macOS image with Xcode
wget -q --show-progress "https://images.sick.codes/osx-kvm/mac_os_x_13_high_sierra.iso" -O /tmp/osx/macos.iso || \
echo "Download failed - will skip actual build"
ls -la /tmp/osx/ || true
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup Git LFS
run: |
apt-get update && apt-get install -y git-lfs
git lfs install
git config --global lfs.url "https://admin:${{ secrets.GITEA_TOKEN }}@git.viaeon.com/admin/UUVPN.git/info/lfs"
git lfs pull || echo "LFS pull failed - checking if framework exists"
ls -la iOS-SwiftUI-Code/uuvpn/Libbox.xcframework/ || echo "Libbox.xcframework not found"
- name: Check if Libbox framework exists
id: check_lfs
run: |
if [ -f "iOS-SwiftUI-Code/uuvpn/Libbox.xcframework/ios-arm64/Libbox.framework/Libbox" ]; then
echo "lfs_ready=true" >> $GITHUB_OUTPUT
echo "LFS files downloaded successfully"
else
echo "lfs_ready=false" >> $GITHUB_OUTPUT
echo "LFS files not available - cannot build iOS"
fi
- name: Build iOS with Docker-OSX (if LFS ready)
if: ${{ steps.check_lfs.outputs.lfs_ready == 'true' }}
run: |
echo "Starting macOS container for iOS build..."
# Mount repository and build
docker run --rm \
--privileged \
-e RAM=8192 \
-e SMP=4 \
-v $PWD:/workspace \
sickcodes/docker-osx:sonoma \
bash -c "
echo 'Waiting for macOS to boot...'
sleep 60
echo 'Checking Xcode...'
xcodebuild -version || echo 'Xcode not installed'
echo 'Building iOS app...'
cd /workspace/iOS-SwiftUI-Code
xcodebuild -project uuvpn.xcodeproj -scheme SFI -sdk iphoneos -configuration Debug build
" || echo "Docker-OSX build failed or not available"
- name: iOS build status
run: |
echo "========================================"
echo "iOS Build Summary"
echo "========================================"
echo "LFS files 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 "Please ensure Gitea LFS is properly configured"
else
echo "Build attempted - check logs above for details"
fi
# ==================== 发布到 GitHub Releases ====================
release:
name: Create GitHub Release
needs: [build-android]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download Android APK
uses: actions/download-artifact@v4
with:
name: android-apk-${{ github.sha }}
path: artifacts/android
- name: Get version from tag
id: get_version
run: |
VERSION=${{ github.ref_name }}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create Release Notes
id: release_notes
run: |
cat > release_notes.md << EOF
# UUVPN ${{ steps.get_version.outputs.version }}
## 🎉 新版本发布
### 📱 Android 版本
- 支持 Android 5.0+ (推荐 Android 7.0+)
- 支持 armeabi-v7a, arm64-v8a, x86, x86_64 架构
- 基于 CLASH (mihomo) 核心
### 🍎 iOS 版本
- 支持 iOS 15.0+
- 基于 SINGBOX 核心
- 支持 iPhone 和 iPad
## 📥 下载说明
### Android
下载 APK 文件并安装,首次安装需要授予必要权限。
### iOS
IPA 文件需要通过 TestFlight 或第三方工具安装。
## 🔄 更新内容
请查看 [Commits](https://github.com/${{ github.repository }}/commits/${{ github.ref_name }}) 了解详细更新内容。
## 📝 问题反馈
如遇到问题,请在 [Issues](https://github.com/${{ github.repository }}/issues) 中反馈。
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: UUVPN ${{ steps.get_version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') }}
files: |
artifacts/android/*.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ==================== 通知 ====================
notify:
name: Send Notification
needs: [build-android]
runs-on: ubuntu
if: ${{ always() && github.event_name == 'push' }}
steps:
- name: Send Telegram Notification
if: ${{ secrets.TELEGRAM_BOT_TOKEN != '' }}
run: |
echo "Telegram notification would be sent here"
echo "Build status: ${{ needs.build-android.result }}"