Files
admin 4f3bcf4e52
Build Debug / Build Android Debug APK (push) Failing after 15m5s
Build iOS / Build iOS IPA (push) Failing after 2s
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
Split workflows: Create build-ios.yml and disable Android build in main workflow
2026-07-04 21:13:48 +08:00

307 lines
10 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
# 暂时禁用 Android 构建,使用 build-android.yml
if: ${{ false && 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.yml
build-ios:
name: Build iOS IPA
runs-on: ubuntu
if: ${{ false }}
steps:
- name: Disabled
run: echo "iOS build moved to build-ios.yml"
# ==================== 发布到 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 }}"