为 3.10 删除导出配置, close #996 #2913
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
paths-ignore: | |
- '**/*.md' | |
pull_request: | |
paths-ignore: | |
- '**/*.md' | |
jobs: | |
build: | |
name: "${{ matrix.name }}" | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners | |
os: | |
- windows-2019 # 16 GB | |
- ubuntu-20.04 # 16 GB | |
- macos-13 # x86_64, 14 GB | |
# - macos-14 # aarch64, 7 GB | |
include: | |
# matrix properties can be booleans. Check for plain true and false. | |
- os: windows-2019 | |
name: Windows x86_64 | |
uploadApk: true | |
arch: x64 | |
anitorrent: true | |
anitorrent_separate_build: false # windows 单线程构建 anitorrent, 要一起跑节约时间 | |
compose_resource_triple: windows-x64 | |
run_tests: true | |
assemble: true | |
gradleArgs: '"-Dorg.gradle.jvmargs=-Xmx4096m" "-Dfile.encoding=UTF-8" "-Dkotlin.daemon.jvm.options=-Xmx4096M"' | |
- os: ubuntu-20.04 | |
name: Ubuntu x86_64 (Compile only) | |
uploadApk: false | |
arch: x64 | |
anitorrent: false | |
anitorrent_separate_build: false | |
compose_resource_triple: linux-x64 | |
run_tests: false # 只编译, 因为 test 不支持 linux | |
assemble: false | |
gradleArgs: '-Dorg.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options=-Xmx4096M' | |
- os: macos-13 | |
name: macOS x86_64 | |
uploadApk: false | |
arch: x64 | |
anitorrent: true | |
anitorrent_separate_build: true # macOS native 构建快, 先构建 anitorrent, 再 assemble | |
compose_resource_triple: macos-x64 | |
run_tests: true | |
assemble: false | |
gradleArgs: >- | |
-Dorg.gradle.jvmargs=-Xmx4g | |
-Dfile.encoding=UTF-8 | |
-Dkotlin.daemon.jvm.options=-Xmx4g | |
-Pani.build.framework=false | |
-Pani.android.abis=arm64-v8a | |
# - os: macos-14 | |
# name: macOS aarch64 | |
# uploadApk: false | |
# arch: aarch64 | |
# anitorrent: true | |
# anitorrent_separate_build: true | |
# compose_resource_triple: macos-arm64 | |
# run_tests: false | |
# gradleArgs: >- | |
# -Dorg.gradle.jvmargs=-Xmx4g | |
# -Dfile.encoding=UTF-8 | |
# -Dkotlin.daemon.jvm.options=-Xmx3g | |
# -Pani.build.framework=false | |
# -Pani.android.abis=arm64-v8a | |
# 这台机器硬盘小, 不要构建其他安卓架构 | |
env: | |
gradleArgs: >- | |
--scan | |
"--no-configuration-cache" | |
${{ matrix.gradleArgs }} | |
${{ matrix.anitorrent == true && '"-Dani.enable.anitorrent=true"' || '' }} | |
${{ matrix.anitorrent == true && '"-DCMAKE_BUILD_TYPE=Release"' || '' }} | |
${{ startsWith(matrix.os, 'windows') && '"-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"' || '' }} | |
${{ startsWith(matrix.os, 'windows') && '"-DBoost_INCLUDE_DIR=C:/vcpkg/installed/x64-windows/include"' || '' }} | |
# envs are strings, so check for 'true' or 'false' | |
isMac: ${{ startsWith(matrix.os, 'macos') }} | |
isWindows: ${{ startsWith(matrix.os, 'windows') }} | |
isUbuntu: ${{ startsWith(matrix.os, 'ubuntu') }} | |
isUnix: ${{ startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu') }} | |
doSigning: ${{ github.event_name != 'pull_request' && github.repository == 'open-ani/ani' }} # fork 和 PR 不使用签名 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- if: ${{ startsWith(matrix.os, 'macos') }} | |
name: Free space | |
run: chmod +x ./ci-helper/free-space-macos.sh && ./ci-helper/free-space-macos.sh | |
continue-on-error: true | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: 17 | |
architecture: ${{ matrix.arch }} | |
- if: ${{ env.isMac == 'true' }} | |
name: Install Native Dependencies | |
run: chmod +x ./ci-helper/install-deps-macos-ci.sh && ./ci-helper/install-deps-macos-ci.sh | |
- if: ${{ env.isWindows == 'true' }} | |
name: Setup vcpkg cache | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
- if: ${{ env.isWindows == 'true' }} | |
name: Install Native Dependencies | |
run: ./ci-helper/install-deps-windows.cmd | |
env: | |
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
with: | |
cache-disabled: true # 缓存包含旧版本的, 太占位置了 | |
- if: ${{ env.isUnix == 'true' }} | |
run: chmod -R 777 * | |
- name: Clean and download dependencies | |
run: ./gradlew clean ${{ env.gradleArgs }} | |
- name: Update version name | |
run: ./gradlew updateDevVersionNameFromGit ${{ env.gradleArgs }} | |
- name: Cache Anitorrent for Android | |
if: ${{ matrix.anitorrent }} | |
id: cache-anitorrent-android | |
uses: actions/cache@v4 | |
with: | |
path: | | |
app/android/.cxx | |
app/android/build | |
key: ${{ runner.os }}-anitorrent-android | |
- name: Cache Anitorrent for Desktop | |
if: ${{ matrix.anitorrent }} | |
id: cache-anitorrent-desktop | |
uses: actions/cache@v4 | |
with: | |
path: | | |
torrent/anitorrent/anitorrent-native/build-ci/ | |
torrent/anitorrent/anitorrent-native/build/ | |
key: ${{ runner.os }}-anitorrent-desktop | |
# 备注: 这个可能已经不需要了, Compose 可能已经修复了这个 bug | |
- name: Explicitly generate Compose resources | |
run: ./gradlew generateComposeResClass ${{ env.gradleArgs }} | |
- if: ${{ matrix.uploadApk }} | |
name: Prepare signing key | |
id: android_signing_key | |
uses: timheuer/base64-to-file@v1.1 | |
with: | |
fileName: 'android_signing_key' | |
fileDir: './' | |
encodedString: ${{ secrets.SIGNING_RELEASE_STOREFILE }} | |
continue-on-error: true | |
- name: Build Anitorrent for Desktop | |
if: ${{ matrix.anitorrent && matrix.anitorrent_separate_build }} | |
run: ./gradlew :torrent:anitorrent:build :torrent:anitorrent:anitorrent-native:buildAnitorrent ${{ env.gradleArgs }} | |
- name: Build Anitorrent for Android Debug | |
if: ${{ matrix.anitorrent }} | |
run: ./gradlew buildCMakeDebug ${{ env.gradleArgs }} | |
- name: Build Anitorrent for Android Release | |
if: ${{ matrix.anitorrent }} | |
run: ./gradlew buildCMakeRelWithDebInfo ${{ env.gradleArgs }} | |
- name: Compile Kotlin | |
run: ./gradlew compileKotlin ${{ env.gradleArgs }} | |
- name: Assemble | |
if: ${{ matrix.assemble }} | |
run: ./gradlew assemble ${{ env.gradleArgs }} | |
- if: ${{ matrix.uploadApk }} | |
name: Build Android Debug APK | |
run: ./gradlew assembleDebug ${{ env.gradleArgs }} | |
- if: ${{ matrix.uploadApk }} | |
name: Upload Android Debug APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ani-android-debug | |
path: app/android/build/outputs/apk/debug/android-debug.apk | |
- if: ${{ matrix.uploadApk && env.doSigning == 'true' }} | |
name: Build Android Release APK | |
run: ./gradlew assembleRelease ${{ env.gradleArgs }} | |
env: | |
"signing_release_storeFileFromRoot": ${{ steps.android_signing_key.outputs.filePath }} | |
"signing_release_storePassword": ${{ secrets.SIGNING_RELEASE_STOREPASSWORD }} | |
"signing_release_keyAlias": ${{ secrets.SIGNING_RELEASE_KEYALIAS }} | |
"signing_release_keyPassword": ${{ secrets.SIGNING_RELEASE_KEYPASSWORD }} | |
- if: ${{ matrix.uploadApk }} | |
name: Upload Android Release APK arm64-v8a | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ani-android-arm64-v8a-release | |
path: app/android/build/outputs/apk/release/android-arm64-v8a-release.apk | |
- if: ${{ matrix.uploadApk }} | |
name: Upload Android Release APK armeabi-v7a | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ani-android-armeabi-v7a-release | |
path: app/android/build/outputs/apk/release/android-armeabi-v7a-release.apk | |
- if: ${{ matrix.uploadApk }} | |
name: Upload Android Release APK x86_64 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ani-android-x86_64-release | |
path: app/android/build/outputs/apk/release/android-x86_64-release.apk | |
- if: ${{ matrix.uploadApk }} | |
name: Upload Android Release APK universal | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ani-android-universal-release | |
path: app/android/build/outputs/apk/release/android-universal-release.apk | |
- name: Check | |
if: ${{ matrix.run_tests }} | |
uses: nick-fields/retry@v2 | |
with: | |
max_attempts: 2 | |
timeout_minutes: 60 | |
command: ./gradlew check ${{ env.gradleArgs }} | |
- name: Package Desktop | |
run: ./gradlew createReleaseDistributable ${{ env.gradleArgs }} | |
- if: ${{ matrix.anitorrent }} | |
name: Upload Anitorrent CMakeCache.txt | |
uses: actions/upload-artifact@v4 | |
with: | |
name: anitorrent-cmake-cache-${{ matrix.os }}-${{ matrix.arch }} | |
path: torrent/anitorrent/build-ci/CMakeCache.txt | |
- if: ${{ matrix.anitorrent }} | |
name: Upload Anitorrent ${{ matrix.compose_resource_triple }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: anitorrent-${{ matrix.compose_resource_triple }} | |
path: app/desktop/appResources/${{ matrix.compose_resource_triple }}/anitorrent | |
- if: ${{ env.isMac == 'true' }} | |
name: Upload macOS packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ani-macos-dmg-${{ matrix.arch }} | |
path: app/desktop/build/compose/binaries/main-release/dmg | |
- if: ${{ env.isWindows == 'true' }} | |
name: Upload Windows packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ani-windows-portable | |
path: app/desktop/build/compose/binaries/main-release/app |