-
Notifications
You must be signed in to change notification settings - Fork 91
210 lines (180 loc) · 7.66 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
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:
os:
- windows-2019
- ubuntu-20.04
- macos-12 # x86_64
- macos-14 # aarch64
include:
# matrix properties can be booleans. Check for plain true and false.
- os: windows-2019
name: Windows x86_64
uploadApk: false
arch: x64
anitorrent: true
anitorrent_separate_build: false # windows 单线程构建 anitorrent, 要一起跑节约时间
compose_resource_triple: windows-x64
- os: ubuntu-20.04
name: Ubuntu x86_64
uploadApk: false
arch: x64
anitorrent: false
anitorrent_separate_build: false
compose_resource_triple: linux-x64
- os: macos-12
name: macOS x86_64
uploadApk: false
arch: x64
anitorrent: true
anitorrent_separate_build: true # macOS 构建快, 先构建 anitorrent, 再 assemble
compose_resource_triple: macos-x64
- os: macos-14
name: macOS aarch64
uploadApk: true
arch: aarch64
anitorrent: true
anitorrent_separate_build: true
compose_resource_triple: macos-arm64
env:
enableLocalPublishingTest: 'false'
gradleArgs: >-
--scan
"-Dorg.gradle.jvmargs=-Xmx4096m"
"-Dfile.encoding=UTF-8"
--no-configuration-cache
"-Pbangumi.oauth.client.android.appId=${{ secrets.BANGUMI_OAUTH_CLIENT_ANDROID_ID }}"
"-Pbangumi.oauth.client.android.secret=${{ secrets.BANGUMI_OAUTH_CLIENT_ANDROID_SECRET }}"
"-Pbangumi.oauth.client.desktop.appId=${{ secrets.BANGUMI_OAUTH_CLIENT_DESKTOP_ID }}"
"-Pbangumi.oauth.client.desktop.secret=${{ secrets.BANGUMI_OAUTH_CLIENT_DESKTOP_SECRET }}"
${{ 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'
- uses: actions/setup-java@v4
if: ${{ env.isWindows != 'true' }}
with:
distribution: zulu
java-version: 17
architecture: ${{ matrix.arch }}
- uses: actions/setup-java@v4
if: ${{ env.isWindows == 'true' }}
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.sh && ./ci-helper/install-deps-macos.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: ${{ env.isWindows == 'true' }} # Windows 上这个缓存会花费 8 分钟, 还不如直接下载
- 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 }}
# 备注: 这个可能已经不需要了, Compose 可能已经修复了这个 bug
- name: Explicitly generate Compose resources
run: ./gradlew generateComposeResClass ${{ env.gradleArgs }}
- if: ${{ env.isMac == 'true' }}
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
if: ${{ matrix.anitorrent && matrix.anitorrent_separate_build }}
run: ./gradlew :torrent:anitorrent:build :torrent:anitorrent:buildAnitorrent ${{ env.gradleArgs }}
- name: 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
uses: actions/upload-artifact@v4
with:
name: ani-android-release
path: app/android/build/outputs/apk/release/android-release.apk
- name: Check
run: ./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