forked from vcmi/vcmi
-
Notifications
You must be signed in to change notification settings - Fork 0
433 lines (397 loc) · 15.5 KB
/
github.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
name: VCMI
on:
# push:
# branches:
# - features/*
# - beta
# - master
# - develop
# pull_request:
workflow_dispatch:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
strategy:
matrix:
include:
- platform: linux-qt6
os: ubuntu-24.04
test: 0
preset: linux-clang-test
# - platform: linux
# os: ubuntu-24.04
# test: 1
# preset: linux-gcc-test
- platform: linux
os: ubuntu-20.04
test: 0
preset: linux-gcc-debug
- platform: mac-intel
os: macos-13
test: 0
pack: 1
pack_type: Release
extension: dmg
preset: macos-conan-ninja-release
conan_profile: macos-intel
conan_options: --options with_apple_system_libs=True
artifact_platform: intel
- platform: mac-arm
os: macos-13
test: 0
pack: 1
pack_type: Release
extension: dmg
preset: macos-arm-conan-ninja-release
conan_profile: macos-arm
conan_options: --options with_apple_system_libs=True
artifact_platform: arm
- platform: ios
os: macos-13
test: 0
pack: 1
pack_type: Release
extension: ipa
preset: ios-release-conan-ccache
conan_profile: ios-arm64
conan_options: --options with_apple_system_libs=True
- platform: msvc
os: windows-latest
test: 0
pack: 1
pack_type: RelWithDebInfo
extension: exe
preset: windows-msvc-release
- platform: mingw
os: ubuntu-22.04
test: 0
pack: 1
pack_type: Release
extension: exe
cpack_args: -D CPACK_NSIS_EXECUTABLE=`which makensis`
cmake_args: -G Ninja
preset: windows-mingw-conan-linux
conan_profile: mingw64-linux.jinja
- platform: mingw-32
os: ubuntu-22.04
test: 0
pack: 1
pack_type: Release
extension: exe
cpack_args: -D CPACK_NSIS_EXECUTABLE=`which makensis`
cmake_args: -G Ninja
preset: windows-mingw-conan-linux
conan_profile: mingw32-linux.jinja
# XXX: some runs already fail due to missing NDK 25
# https://github.com/actions/runner-images/issues/10614
# - platform: android-32
# os: macos-14
# extension: apk
# preset: android-conan-ninja-release
# conan_profile: android-32
# conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
# artifact_platform: armeabi-v7a
# - platform: android-64
# os: macos-14
# extension: apk
# preset: android-conan-ninja-release
# conan_profile: android-64
# conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
# artifact_platform: arm64-v8a
#
# MMAI builds
#
- platform: linux
os: ubuntu-20.04
test: 0
preset: linux-gcc-debug
mmai: 1
- platform: mac-intel
os: macos-13
test: 0
pack: 1
pack_type: Release
extension: dmg
preset: macos-conan-ninja-release
conan_profile: macos-intel
conan_options: --options with_apple_system_libs=True
artifact_platform: intel
mmai: 1
- platform: mac-arm
os: macos-13
test: 0
pack: 1
pack_type: Release
extension: dmg
preset: macos-arm-conan-ninja-release
conan_profile: macos-arm
conan_options: --options with_apple_system_libs=True
artifact_platform: arm
mmai: 1
- platform: ios
os: macos-13
test: 0
pack: 1
pack_type: Release
extension: ipa
preset: ios-release-conan-ccache
conan_profile: ios-arm64
conan_options: --options with_apple_system_libs=True
mmai: 1
- platform: msvc
os: windows-latest
test: 0
pack: 1
pack_type: RelWithDebInfo
extension: exe
preset: windows-msvc-release
mmai: 1
- platform: android-64
os: macos-14
extension: apk
preset: android-conan-ninja-release
conan_profile: android-64
conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
artifact_platform: arm64-v8a
mmai: 1
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Dependencies
run: source '${{github.workspace}}/CI/${{matrix.platform}}/before_install.sh'
env:
VCMI_BUILD_PLATFORM: x64
MMAI: ${{matrix.mmai}}
# # ensure the ccache for each PR is separate so they don't interfere with each other
# # fall back to ccache of the vcmi/vcmi repo if no PR-specific ccache is found
# - name: ccache for PRs
# uses: hendrikmuhs/[email protected]
# if: ${{ github.event.number != '' }}
# with:
# key: ${{ matrix.preset }}-PR-${{ github.event.number }}
# restore-keys: |
# ${{ matrix.preset }}-PR-${{ github.event.number }}
# ${{ matrix.preset }}-no-PR
# # actual cache takes up less space, at most ~1 GB
# max-size: "5G"
# verbose: 2
# - name: ccache for everything but PRs
# uses: hendrikmuhs/[email protected]
# if: ${{ (github.repository == 'vcmi/vcmi' && github.event.number == '' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/master')) || github.repository != 'vcmi/vcmi' }}
# with:
# key: ${{ matrix.preset }}-no-PR
# restore-keys: |
# ${{ matrix.preset }}-no-PR
# # actual cache takes up less space, at most ~1 GB
# max-size: "5G"
# verbose: 2
- name: Prepare Heroes 3 data
env:
HEROES_3_DATA_PASSWORD: ${{ secrets.HEROES_3_DATA_PASSWORD }}
if: ${{ env.HEROES_3_DATA_PASSWORD != '' && matrix.test == 1 }}
run: |
if [[ ${{github.repository_owner}} == vcmi ]]
then
data_url="https://github.com/vcmi-mods/vcmi-test-data/releases/download/v1.0/h3_assets.zip"
else
data_url="https://github.com/${{github.repository_owner}}/vcmi-test-data/releases/download/v1.0/h3_assets.zip"
fi
wget --progress=dot:giga "$data_url" -O h3_assets.zip
7za x h3_assets.zip -p$HEROES_3_DATA_PASSWORD
mkdir -p ~/.local/share/vcmi/
mv h3_assets/* ~/.local/share/vcmi/
- uses: actions/setup-python@v5
if: "${{ matrix.conan_profile != '' }}"
with:
python-version: '3.10'
- name: Conan setup
if: "${{ matrix.conan_profile != '' }}"
run: |
pip3 install 'conan<2.0'
conan profile new default --detect
conan install . \
--install-folder=conan-generated \
--no-imports \
--build=never \
--profile:build=default \
--profile:host=CI/conan/${{ matrix.conan_profile }} \
${{ matrix.conan_options }}
env:
GENERATE_ONLY_BUILT_CONFIG: 1
- uses: actions/setup-java@v4
if: ${{ startsWith(matrix.platform, 'android') }}
with:
distribution: 'temurin'
java-version: '11'
# a hack to build ID for x64 build in order for Google Play to allow upload of both 32 and 64 bit builds
- name: Bump Android x64 build ID
if: ${{ matrix.platform == 'android-64' }}
run: perl -i -pe 's/versionCode (\d+)/$x=$1+1; "versionCode $x"/e' android/vcmi-app/build.gradle
- name: Build Number
run: |
source '${{github.workspace}}/CI/get_package_name.sh'
if [ "${{matrix.mmai}}" == "1" ]; then
VCMI_PACKAGE_FILE_NAME+="-mmai"
fi
if [ '${{ matrix.artifact_platform }}' ]; then
VCMI_PACKAGE_FILE_NAME+="-${{ matrix.artifact_platform }}"
fi
echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
env:
PULL_REQUEST: ${{ github.event.pull_request.number }}
- name: Configure
run: |
if [ "${{matrix.mmai}}" == "1" ]
then
MMAI_FLAGS="-DENABLE_MMAI=ON"
else
MMAI_FLAGS=""
fi
if [[ ${{matrix.preset}} == linux-gcc-test ]]
then
cmake -DENABLE_CCACHE:BOOL=ON -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 $MMAI_FLAGS --preset ${{ matrix.preset }}
elif [[ (${{matrix.preset}} == android-conan-ninja-release) && (${{github.ref}} != 'refs/heads/master') ]]
then
cmake -DENABLE_CCACHE:BOOL=ON -DANDROID_GRADLE_PROPERTIES="applicationIdSuffix=.daily;signingConfig=dailySigning;applicationLabel=VCMI daily" $MMAI_FLAGS --preset ${{ matrix.preset }}
elif [[ ${{matrix.platform}} != msvc ]]
then
cmake -DENABLE_CCACHE:BOOL=ON $MMAI_FLAGS --preset ${{ matrix.preset }}
else
cmake $MMAI_FLAGS --preset ${{ matrix.preset }}
fi
- name: Build
run: |
cmake --build --preset ${{matrix.preset}}
env:
ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
- name: Test
env:
HEROES_3_DATA_PASSWORD: ${{ secrets.HEROES_3_DATA_PASSWORD }}
if: ${{ env.HEROES_3_DATA_PASSWORD != '' && matrix.test == 1 }}
run: |
ctest --preset ${{matrix.preset}}
- name: Kill XProtect to work around CPack issue on macOS
if: ${{ startsWith(matrix.platform, 'mac') }}
run: |
# Cf. https://github.com/actions/runner-images/issues/7522#issuecomment-1556766641
echo Killing...; sudo pkill -9 XProtect >/dev/null || true;
echo "Waiting..."; counter=0; while pgrep XProtect && ((counter < 20)); do sleep 3; ((counter++)); done
pgrep XProtect || true
- name: Pack
id: cpack
if: ${{ matrix.pack == 1 }}
run: |
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
CPACK_PATH=`which -a cpack | grep -m1 -v -i chocolatey`
counter=0; until "$CPACK_PATH" -C ${{matrix.pack_type}} ${{ matrix.cpack_args }} || ((counter > 20)); do sleep 3; ((counter++)); done
test -f '${{github.workspace}}/CI/${{matrix.platform}}/post_pack.sh' \
&& '${{github.workspace}}/CI/${{matrix.platform}}/post_pack.sh' '${{github.workspace}}' "$(ls '${{ env.VCMI_PACKAGE_FILE_NAME }}'.*)"
rm -rf _CPack_Packages
- name: Artifacts
if: ${{ matrix.pack == 1 }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
path: |
${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
- name: Find Android package
if: ${{ startsWith(matrix.platform, 'android') }}
run: |
builtApkPath="$(ls ${{ github.workspace }}/out/build/${{ matrix.preset }}/android-build/vcmi-app/build/outputs/apk/release/*.${{ matrix.extension }})"
builtAabPath="$(ls ${{ github.workspace }}/out/build/${{ matrix.preset }}/android-build/vcmi-app/build/outputs/bundle/release/*.aab)"
ANDROID_APK_PATH="${{ github.workspace }}/$VCMI_PACKAGE_FILE_NAME.${{ matrix.extension }}"
ANDROID_AAB_PATH="${{ github.workspace }}/$VCMI_PACKAGE_FILE_NAME.aab"
mv "$builtApkPath" "$ANDROID_APK_PATH"
mv "$builtAabPath" "$ANDROID_AAB_PATH"
echo "ANDROID_APK_PATH=$ANDROID_APK_PATH" >> $GITHUB_ENV
echo "ANDROID_AAB_PATH=$ANDROID_AAB_PATH" >> $GITHUB_ENV
- name: Android apk artifacts
if: ${{ startsWith(matrix.platform, 'android') }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
path: |
${{ env.ANDROID_APK_PATH }}
- name: Android aab artifacts
if: ${{ startsWith(matrix.platform, 'android') }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - aab
path: |
${{ env.ANDROID_AAB_PATH }}
- name: Symbols
if: ${{ matrix.platform == 'msvc' }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - symbols
path: |
${{github.workspace}}/**/*.pdb
- name: Upload build
if: ${{ (matrix.pack == 1 || startsWith(matrix.platform, 'android')) && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/features/')) && matrix.platform != 'msvc' && matrix.platform != 'mingw-32' }}
continue-on-error: true
run: |
if [ -z '${{ env.ANDROID_APK_PATH }}' ] ; then
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
fi
source '${{github.workspace}}/CI/upload_package.sh'
env:
DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
PACKAGE_EXTENSION: ${{ matrix.extension }}
deploy-src:
if: always() && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build Number
run: |
source '${{github.workspace}}/CI/get_package_name.sh'
echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
- name: Create source code archive (including submodules)
run: |
git archive HEAD -o "release.tar" --worktree-attributes -v
git submodule update --init --recursive
git submodule --quiet foreach 'cd "$toplevel"; tar -rvf "release.tar" "$sm_path"'
gzip release.tar
- name: Upload source code archive
uses: actions/upload-artifact@v4
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
path: |
./release.tar.gz
validate-code:
if: always()
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
if: "${{ matrix.conan_profile != '' }}"
with:
python-version: '3.10'
- name: Ensure LF line endings
run: |
find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -o -path ./test/googletest \
-o -path ./osx -prune -o -type f \
-not -name '*.png' -and -not -name '*.ttf' -and -not -name '*.wav' -and -not -name '*.webm' -and -not -name '*.ico' -and -not -name '*.bat' -and -not -name '*.pt' -print0 | \
{ ! xargs -0 grep -l -z -P '\r\n'; }
- name: Validate JSON
run: |
sudo apt install python3-jstyleson
python3 CI/linux-qt6/validate_json.py