github.yml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. name: VCMI
  2. on:
  3. push:
  4. branches:
  5. - beta
  6. - master
  7. - develop
  8. pull_request:
  9. workflow_dispatch:
  10. jobs:
  11. build:
  12. name: Build (${{ matrix.platform }})
  13. strategy:
  14. fail-fast: false # Do not cancel whole matrix when one build fails
  15. matrix:
  16. include:
  17. - platform: mac-intel
  18. os: macos-14
  19. pack: 1
  20. upload: 1
  21. pack_type: Release
  22. extension: dmg
  23. before_install: macos.sh
  24. preset: macos-conan-ninja-release
  25. conan_profile: macos-intel
  26. conan_prebuilts: dependencies-mac-intel
  27. conan_options: --profile=dependencies/conan_profiles/base/apple-system
  28. artifact_platform: intel
  29. - platform: mac-arm
  30. os: macos-14
  31. pack: 1
  32. upload: 1
  33. pack_type: Release
  34. extension: dmg
  35. before_install: macos.sh
  36. preset: macos-arm-conan-ninja-release
  37. conan_profile: macos-arm
  38. conan_prebuilts: dependencies-mac-arm
  39. conan_options: --profile=dependencies/conan_profiles/base/apple-system
  40. artifact_platform: arm
  41. - platform: ios
  42. os: macos-14
  43. pack: 1
  44. upload: 1
  45. pack_type: Release
  46. extension: ipa
  47. before_install: macos.sh
  48. preset: ios-release-conan-ccache
  49. conan_profile: ios-arm64
  50. conan_prebuilts: dependencies-ios
  51. conan_options: --profile=dependencies/conan_profiles/base/apple-system
  52. - platform: msvc-x64
  53. arch: x64
  54. toolset: '14.29'
  55. os: windows-2025
  56. pack: 1
  57. upload: 0
  58. pack_type: RelWithDebInfo
  59. extension: zip
  60. preset: windows-msvc-ninja-release
  61. conan_profile: msvc-x64
  62. conan_prebuilts: dependencies-windows-x64
  63. conan_options: -s "&:build_type=RelWithDebInfo" -c tools.env.virtualenv:powershell=pwsh -o "&:target_pre_windows10=True"
  64. artifact_platform: x64
  65. cl: Hostx64/x64/cl.exe
  66. - platform: msvc-x86
  67. arch: x86
  68. toolset: '14.29'
  69. os: windows-2025
  70. pack: 1
  71. upload: 0
  72. pack_type: RelWithDebInfo
  73. extension: zip
  74. preset: windows-msvc-ninja-release-x86
  75. conan_profile: msvc-x86
  76. conan_prebuilts: dependencies-windows-x86
  77. conan_options: -s "&:build_type=RelWithDebInfo" -c tools.env.virtualenv:powershell=pwsh -o "&:target_pre_windows10=True"
  78. artifact_platform: x86
  79. cl: Hostx64/x86/cl.exe
  80. - platform: msvc-arm64
  81. arch: arm64
  82. os: windows-11-arm
  83. pack: 1
  84. upload: 0
  85. pack_type: RelWithDebInfo
  86. extension: zip
  87. preset: windows-msvc-ninja-release-arm64
  88. conan_profile: msvc-arm64
  89. conan_prebuilts: dependencies-windows-arm64
  90. conan_options: -s "&:build_type=RelWithDebInfo" -c tools.env.virtualenv:powershell=pwsh -o "&:lua_lib=lua"
  91. artifact_platform: arm64
  92. cl: HostARM64/ARM64/cl.exe
  93. - platform: android-32
  94. os: ubuntu-latest
  95. upload: 1
  96. extension: apk
  97. preset: android-conan-ninja-release
  98. conan_profile: android-32-ndk
  99. conan_prebuilts: dependencies-android-armeabi-v7a
  100. conan_options: --profile=dependencies/conan_profiles/base/android-system
  101. artifact_platform: armeabi-v7a
  102. - platform: android-64
  103. os: ubuntu-latest
  104. upload: 1
  105. extension: apk
  106. preset: android-conan-ninja-release
  107. conan_profile: android-64-ndk
  108. conan_prebuilts: dependencies-android-arm64-v8a
  109. conan_options: --profile=dependencies/conan_profiles/base/android-system
  110. artifact_platform: arm64-v8a
  111. - platform: android-64-intel
  112. os: ubuntu-latest
  113. upload: 1
  114. extension: apk
  115. preset: android-conan-ninja-release
  116. conan_profile: android-x64-ndk
  117. conan_prebuilts: dependencies-android-x64
  118. conan_options: --profile=dependencies/conan_profiles/base/android-system
  119. artifact_platform: x64
  120. runs-on: ${{ matrix.os }}
  121. # Allow non-MSVC builds to fail without failing whole job
  122. # This keeps pipeline moving so Windows Installer job can still run
  123. # MSVC builds must success to continue to Windows Installer job
  124. continue-on-error: ${{ !startsWith(matrix.platform, 'msvc') }}
  125. defaults:
  126. run:
  127. shell: bash
  128. steps:
  129. - name: Checkout repository
  130. uses: actions/checkout@v5
  131. with:
  132. submodules: recursive
  133. - name: Prepare APT staging dir
  134. if: contains(matrix.os, 'ubuntu')
  135. run: mkdir -p "$RUNNER_TEMP/apt-cache"
  136. - name: APT cache restore
  137. if: contains(matrix.os, 'ubuntu')
  138. id: aptcache
  139. uses: actions/cache/restore@v4
  140. with:
  141. path: ${{ runner.temp }}/apt-cache
  142. key: ${{ matrix.platform }}-apt-${{ matrix.os }}
  143. restore-keys: |
  144. ${{ matrix.platform }}-apt-${{ matrix.os }}
  145. - name: Prepare CI
  146. if: "${{ matrix.before_install != '' }}"
  147. run: source '${{github.workspace}}/CI/before_install/${{matrix.before_install}}' '${{matrix.arch}}'
  148. # Save only on cache miss, GitHub caches are immutable per key
  149. - name: APT cache save
  150. if: contains(matrix.os, 'ubuntu') && steps.aptcache.outputs.cache-hit != 'true'
  151. uses: actions/cache/save@v4
  152. with:
  153. path: ${{ runner.temp }}/apt-cache
  154. key: ${{ steps.aptcache.outputs.cache-primary-key }}
  155. - name: Install Conan Dependencies
  156. if: "${{ matrix.conan_prebuilts != '' }}"
  157. run: |
  158. pipx install conan
  159. source '${{github.workspace}}/CI/install_conan_dependencies.sh' '${{matrix.conan_prebuilts}}'
  160. - name: Setup MSVC Developer Command Prompt
  161. if: ${{ startsWith(matrix.platform, 'msvc') }}
  162. uses: ilammy/msvc-dev-cmd@v1
  163. with:
  164. arch: ${{ matrix.arch }}
  165. toolset: ${{ matrix.toolset }}
  166. # ensure the cache for each PR is separate so they don't interfere with each other
  167. # fall back to cache of the vcmi/vcmi repo if no PR-specific cache is found
  168. - name: Setup compiler cache for PRs
  169. uses: hendrikmuhs/[email protected]
  170. if: ${{ github.event.number != '' }}
  171. with:
  172. variant: ${{ startsWith(matrix.platform, 'msvc') && 'sccache' || 'ccache' }}
  173. key: ${{ matrix.platform }}-PR-${{ github.event.number }}
  174. restore-keys: |
  175. ${{ matrix.platform }}-PR-${{ github.event.number }}
  176. ${{ matrix.platform }}-branch-${{ github.base_ref }}
  177. ${{ matrix.platform }}-
  178. create-symlink: ${{ !startsWith(matrix.platform, 'msvc') }}
  179. max-size: '5G'
  180. verbose: 2
  181. job-summary: "" # <-- disable built-in summary to avoid duplicate block
  182. - name: Setup compiler cache for branch builds
  183. uses: hendrikmuhs/[email protected]
  184. if: ${{ github.event.number == '' }}
  185. with:
  186. variant: ${{ startsWith(matrix.platform, 'msvc') && 'sccache' || 'ccache' }}
  187. key: ${{ matrix.platform }}-branch-${{ github.ref_name }}
  188. restore-keys: |
  189. ${{ matrix.platform }}-branch-${{ github.ref_name }}
  190. ${{ matrix.platform }}-
  191. create-symlink: ${{ !startsWith(matrix.platform, 'msvc') }}
  192. max-size: '5G'
  193. verbose: 2
  194. job-summary: "" # <-- disable built-in summary to avoid duplicate block
  195. - name: CCache tuning (Android)
  196. if: ${{ startsWith(matrix.platform, 'android') }}
  197. run: |
  198. echo "/usr/lib/ccache" >> $GITHUB_PATH
  199. ccache --set-config=compiler_check=content
  200. ccache --set-config=base_dir="${GITHUB_WORKSPACE}"
  201. ccache --set-config=hash_dir=true
  202. ccache --set-config=sloppiness=time_macros
  203. - name: Install Conan profile
  204. if: "${{ matrix.conan_profile != '' }}"
  205. run: |
  206. conan profile detect
  207. conan install . \
  208. --output-folder=conan-generated \
  209. --build=never \
  210. --profile=dependencies/conan_profiles/${{ matrix.conan_profile }} \
  211. ${{ matrix.conan_options }}
  212. # Can't be set in Gradle project
  213. - name: Configure enableUncompressedNativeLibs
  214. if: ${{ startsWith(matrix.platform, 'android') }}
  215. run: mkdir -p ~/.gradle && echo "android.bundle.enableUncompressedNativeLibs=true" > ~/.gradle/gradle.properties
  216. # Workaround for gradle not discovering SDK that was installed via Сonan
  217. - name: Link Android NDK from Conan cache to Android SDK path
  218. if: ${{ startsWith(matrix.platform, 'android') }}
  219. run: |
  220. ndkPackage='android-ndk'
  221. hexRegex='[[:xdigit:]]+'
  222. ndkPackageRevision=$(conan list "$ndkPackage/*:*" --format=compact \
  223. | egrep --only-matching "$ndkPackage/\\w+#$hexRegex:$hexRegex")
  224. ndkPackagePath=$(conan cache path "$ndkPackageRevision")
  225. # format: Pkg.Revision = 25.2.9519653
  226. ndkPath="$ndkPackagePath/bin"
  227. ndkVersion=$(fgrep 'Pkg.Revision' "$ndkPath/source.properties" | cut -d ' ' -f 3)
  228. ln -s -T "$ndkPath" "$ANDROID_HOME/ndk/$ndkVersion"
  229. - name: Install Java
  230. uses: actions/setup-java@v5
  231. if: ${{ startsWith(matrix.platform, 'android') }}
  232. with:
  233. distribution: 'temurin'
  234. java-version: '17'
  235. # a hack to build ID for x64 build in order for Google Play to allow upload of both 32 and 64 bit builds
  236. # TODO: x86_64
  237. - name: Bump Android x64 build ID
  238. if: ${{ matrix.platform == 'android-64' }}
  239. run: perl -i -pe 's/versionCode (\d+)/$x=$1+1; "versionCode $x"/e' android/vcmi-app/build.gradle
  240. - name: Build Number
  241. run: |
  242. source '${{github.workspace}}/CI/get_package_name.sh'
  243. if [ '${{ matrix.artifact_platform }}' ]; then
  244. VCMI_PACKAGE_FILE_NAME+="-${{ matrix.artifact_platform }}"
  245. fi
  246. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  247. echo VCMI_PACKAGE_BUILD="$VCMI_PACKAGE_BUILD" >> $GITHUB_ENV
  248. echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
  249. echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
  250. env:
  251. PULL_REQUEST: ${{ github.event.pull_request.number }}
  252. - name: Configure (non-MSVC)
  253. if: ${{ !startsWith(matrix.platform, 'msvc') }}
  254. run: |
  255. if [[ ("${{ matrix.preset }}" == "android-conan-ninja-release") && ("${{ github.ref }}" != 'refs/heads/master') ]]; then
  256. # key1=value1;key2=value2;...
  257. gradleProperties=$(python3 CI/android/gradle_daily_props.py)
  258. androidOptions=("-DANDROID_GRADLE_PROPERTIES=$gradleProperties")
  259. androidOptions+=("-DCMAKE_C_COMPILER_LAUNCHER=ccache" "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache")
  260. fi
  261. cmake -DENABLE_CCACHE:BOOL=ON "${androidOptions[@]}" --preset ${{ matrix.preset }}
  262. - name: Configure (MSVC)
  263. if: ${{ startsWith(matrix.platform, 'msvc') }}
  264. run: |
  265. & conan-generated\conanrun.ps1
  266. $CL = "$($env:VCToolsInstallDir)/bin/${{ matrix.cl }}"
  267. cmake `
  268. -D "CMAKE_C_COMPILER:FILEPATH=$CL" `
  269. -D "CMAKE_CXX_COMPILER:FILEPATH=$CL" `
  270. --preset ${{ matrix.preset }}
  271. shell: pwsh
  272. - name: Build
  273. run: |
  274. ${{ startsWith(matrix.platform, 'msvc') && '& conan-generated\conanrun.ps1' }}
  275. cmake --build --preset ${{matrix.preset}}
  276. shell: pwsh
  277. env:
  278. ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
  279. ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
  280. - name: Kill XProtect to work around CPack issue on macOS
  281. if: ${{ startsWith(matrix.platform, 'mac') }}
  282. run: |
  283. # Cf. https://github.com/actions/runner-images/issues/7522#issuecomment-1556766641
  284. echo Killing...; sudo pkill -9 XProtect >/dev/null || true;
  285. echo "Waiting..."; counter=0; while pgrep XProtect && ((counter < 20)); do sleep 3; ((counter++)); done
  286. pgrep XProtect || true
  287. - name: Pack
  288. id: cpack
  289. if: ${{ matrix.pack == 1 }}
  290. run: |
  291. ${{ startsWith(matrix.platform, 'msvc') && '& conan-generated\conanrun.ps1' }}
  292. cd "${{github.workspace}}/out/build/${{matrix.preset}}"
  293. cpack -C ${{matrix.pack_type}}
  294. shell: pwsh
  295. - name: Find Android package
  296. if: ${{ startsWith(matrix.platform, 'android') }}
  297. run: |
  298. OUTPUT_DIRECTORY="${{ github.workspace }}/out/build/${{ matrix.preset }}/android-build/vcmi-app/build/outputs"
  299. mv "$OUTPUT_DIRECTORY/apk/release/vcmi-release.apk" "${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.apk"
  300. mv "$OUTPUT_DIRECTORY/bundle/release/vcmi-release.aab" "${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.aab"
  301. - name: Upload Artifact
  302. id: upload_artifact
  303. uses: actions/upload-artifact@v4
  304. with:
  305. name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
  306. compression-level: 9
  307. path: |
  308. ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
  309. - name: Upload AAB Artifact
  310. id: upload_aab
  311. if: ${{ startsWith(matrix.platform, 'android') && github.ref == 'refs/heads/master' }}
  312. uses: actions/upload-artifact@v4
  313. with:
  314. name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - aab
  315. compression-level: 9
  316. path: |
  317. ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.aab
  318. - name: Upload debug symbols
  319. id: upload_symbols
  320. if: ${{ startsWith(matrix.platform, 'msvc') }}
  321. uses: actions/upload-artifact@v4
  322. with:
  323. name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - symbols
  324. compression-level: 9
  325. path: |
  326. ${{github.workspace}}/**/*.pdb
  327. - name: Upload build to download.vcmi.eu
  328. if: ${{ matrix.upload == 1 && github.event.number == '' && env.DEPLOY_RSA != '' }}
  329. run: |
  330. if [ -z '${{ env.ANDROID_APK_PATH }}' ] ; then
  331. cd '${{github.workspace}}/out/build/${{matrix.preset}}'
  332. fi
  333. source '${{github.workspace}}/CI/upload_package.sh'
  334. env:
  335. DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
  336. PACKAGE_EXTENSION: ${{ matrix.extension }}
  337. - name: Prepare partial JSON with build informations
  338. id: make_partial_json
  339. env:
  340. PLATFORM: ${{ matrix.platform }}
  341. ARCH: ${{ matrix.arch }}
  342. ARTIFACT_URL: ${{ steps.upload_artifact.outputs.artifact-url }}
  343. DEBUG_SYMBOLS_URL: ${{ steps.upload_symbols.outputs.artifact-url }}
  344. AAB_URL: ${{ steps.upload_aab.outputs.artifact-url }}
  345. run: |
  346. python3 CI/emit_partial.py
  347. - name: Upload partial JSON with build informations
  348. uses: actions/upload-artifact@v4
  349. with:
  350. name: partial-json-${{ matrix.platform }}
  351. path: .summary/${{ matrix.platform }}.json
  352. upload-source-package:
  353. name: Upload Source Code Package
  354. if: always() && github.event.number == ''
  355. runs-on: ubuntu-latest
  356. defaults:
  357. run:
  358. shell: bash
  359. steps:
  360. - uses: actions/checkout@v5
  361. with:
  362. submodules: recursive
  363. - name: Build Number
  364. run: |
  365. source '${{github.workspace}}/CI/get_package_name.sh'
  366. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  367. - name: Create source code archive (including submodules)
  368. run: |
  369. git archive HEAD -o "release.tar" --worktree-attributes -v
  370. git submodule update --init --recursive
  371. git submodule --quiet foreach 'cd "$toplevel"; tar -rvf "release.tar" "$sm_path"'
  372. gzip release.tar
  373. - name: Upload source code archive
  374. id: upload_source
  375. uses: actions/upload-artifact@v4
  376. with:
  377. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
  378. compression-level: 9
  379. path: |
  380. ./release.tar.gz
  381. - name: Prepare partial JSON with source informations
  382. shell: bash
  383. run: |
  384. mkdir -p .summary
  385. cat > .summary/source.json <<JSON
  386. {"source_url": "${{ steps.upload_source.outputs.artifact-url }}"}
  387. JSON
  388. - name: Upload partial JSON with source informations
  389. uses: actions/upload-artifact@v4
  390. with:
  391. name: partial-json-source
  392. path: .summary/source.json
  393. test:
  394. continue-on-error: true
  395. name: Test (${{ matrix.platform }})
  396. env:
  397. HEROES_3_DATA_PASSWORD: ${{ secrets.HEROES_3_DATA_PASSWORD }}
  398. strategy:
  399. fail-fast: false
  400. matrix:
  401. include:
  402. - platform: gcc-latest-release
  403. os: ubuntu-24.04
  404. before_install: linux_qt6.sh
  405. compiler_cxx: g++-14
  406. compiler_cc: gcc-14
  407. preset: linux-gcc-test
  408. - platform: clang-latest-debug
  409. os: ubuntu-24.04
  410. before_install: linux_qt6.sh
  411. compiler_cxx: clang++-18
  412. compiler_cc: clang-18
  413. preset: linux-clang-debug
  414. - platform: gcc-oldest-debug
  415. os: ubuntu-22.04
  416. before_install: linux_qt5.sh
  417. compiler_cxx: g++-10
  418. compiler_cc: gcc-10
  419. preset: linux-gcc-debug
  420. - platform: clang-oldest-release
  421. os: ubuntu-22.04
  422. before_install: linux_qt5.sh
  423. compiler_cxx: clang++-13
  424. compiler_cc: clang-13
  425. preset: linux-clang-test
  426. runs-on: ${{ matrix.os }}
  427. defaults:
  428. run:
  429. shell: bash
  430. steps:
  431. - name: Checkout repository
  432. uses: actions/checkout@v5
  433. with:
  434. submodules: recursive
  435. - name: Prepare APT staging dir
  436. if: contains(matrix.os, 'ubuntu')
  437. run: mkdir -p "$RUNNER_TEMP/apt-cache"
  438. - name: APT cache restore
  439. if: contains(matrix.os, 'ubuntu')
  440. id: aptcache
  441. uses: actions/cache/restore@v4
  442. with:
  443. path: ${{ runner.temp }}/apt-cache
  444. key: ${{ matrix.platform }}-apt-${{ matrix.os }}
  445. restore-keys: |
  446. ${{ matrix.platform }}-apt-${{ matrix.os }}
  447. - name: Prepare CI
  448. run: source '${{github.workspace}}/CI/before_install/${{matrix.before_install}}' '${{matrix.arch}}'
  449. - name: APT cache save
  450. if: contains(matrix.os, 'ubuntu') && steps.aptcache.outputs.cache-hit != 'true'
  451. uses: actions/cache/save@v4
  452. with:
  453. path: ${{ runner.temp }}/apt-cache
  454. key: ${{ steps.aptcache.outputs.cache-primary-key }}
  455. - name: Setup compiler cache for PRs
  456. uses: hendrikmuhs/[email protected]
  457. if: ${{ github.event.number != '' }}
  458. with:
  459. key: ${{ matrix.platform }}-PR-${{ github.event.number }}
  460. restore-keys: |
  461. ${{ matrix.platform }}-PR-${{ github.event.number }}
  462. ${{ matrix.platform }}-branch-${{ github.base_ref }}
  463. ${{ matrix.platform }}-
  464. max-size: '5G'
  465. verbose: 2
  466. - name: Setup compiler cache for branch builds
  467. uses: hendrikmuhs/[email protected]
  468. if: ${{ github.event.number == '' }}
  469. with:
  470. key: ${{ matrix.platform }}-branch-${{ github.ref_name }}
  471. restore-keys: |
  472. ${{ matrix.platform }}-branch-${{ github.ref_name }}
  473. ${{ matrix.platform }}-
  474. max-size: '5G'
  475. verbose: 2
  476. - name: Prepare Heroes 3 data
  477. if: ${{ env.HEROES_3_DATA_PASSWORD != '' }}
  478. run: |
  479. if [[ ${{github.repository_owner}} == vcmi ]]
  480. then
  481. data_url="https://github.com/vcmi-mods/vcmi-test-data/releases/download/v1.0/h3_assets.zip"
  482. else
  483. data_url="https://github.com/${{github.repository_owner}}/vcmi-test-data/releases/download/v1.0/h3_assets.zip"
  484. fi
  485. wget --progress=dot:giga "$data_url" -O h3_assets.zip
  486. 7za x h3_assets.zip -p$HEROES_3_DATA_PASSWORD
  487. mkdir -p ~/.local/share/vcmi/
  488. mv h3_assets/* ~/.local/share/vcmi/
  489. - name: Configure
  490. run: |
  491. cmake -DENABLE_CCACHE:BOOL=ON -DCMAKE_C_COMPILER=${{ matrix.compiler_cc }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler_cxx }} --preset ${{ matrix.preset }}
  492. - name: Build
  493. run: |
  494. cmake --build --preset ${{matrix.preset}}
  495. - name: Test
  496. if: ${{ env.HEROES_3_DATA_PASSWORD != '' }}
  497. run: |
  498. ctest --preset ${{matrix.preset}}
  499. windows-installer:
  500. needs: build
  501. if: ${{ needs.build.result == 'success' }}
  502. name: Create Windows Installer (${{ matrix.arch }})
  503. strategy:
  504. matrix:
  505. include:
  506. - platform: msvc-x64
  507. arch: x64
  508. os: windows-2025
  509. - platform: msvc-x86
  510. arch: x86
  511. os: windows-2025
  512. - platform: msvc-arm64
  513. arch: arm64
  514. os: windows-11-arm
  515. runs-on: ${{ matrix.os }}
  516. defaults:
  517. run:
  518. shell: bash
  519. steps:
  520. - name: Checkout repository
  521. uses: actions/checkout@v5
  522. with:
  523. submodules: recursive
  524. - name: Extract version info
  525. id: extract-version
  526. run: |
  527. filePath="${GITHUB_WORKSPACE}/cmake_modules/VersionDefinition.cmake"
  528. major=$(grep -m 1 "VCMI_VERSION_MAJOR" "$filePath" | tr -d -c 0-9)
  529. minor=$(grep -m 1 "VCMI_VERSION_MINOR" "$filePath" | tr -d -c 0-9)
  530. patch=$(grep -m 1 "VCMI_VERSION_PATCH" "$filePath" | tr -d -c 0-9)
  531. short_version="${major}.${minor}.${patch}"
  532. version_timestamp=$(date +"%Y%m%d%H%M%S")
  533. echo "short_version=${short_version}" >> "$GITHUB_OUTPUT"
  534. echo "version_timestamp=${version_timestamp}" >> "$GITHUB_OUTPUT"
  535. - name: Download UCRT
  536. run: source '${{github.workspace}}/CI/wininstaller/download_ucrt.sh' '${{matrix.platform}}'
  537. - name: Build Number
  538. run: |
  539. source '${{github.workspace}}/CI/get_package_name.sh'
  540. VCMI_PACKAGE_FILE_NAME+="-${{ matrix.arch }}"
  541. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  542. echo VCMI_PACKAGE_BUILD="$VCMI_PACKAGE_BUILD" >> $GITHUB_ENV
  543. echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
  544. echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
  545. env:
  546. PULL_REQUEST: ${{ github.event.pull_request.number }}
  547. - name: Download Artifact
  548. uses: actions/download-artifact@v5
  549. with:
  550. name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
  551. path: ${{github.workspace}}/artifact
  552. - name: Extract Artifact
  553. run: |
  554. mkdir artifact/extracted
  555. unzip "artifact/${{ env.VCMI_PACKAGE_FILE_NAME }}.zip" -d artifact/extracted
  556. - name: Ensure Inno Setup is installed
  557. run: |
  558. if [ ! -f "/c/Program Files (x86)/Inno Setup 6/ISCC.exe" ] && [ ! -f "/c/ProgramData/Chocolatey/bin/ISCC.exe" ]; then
  559. choco install innosetup --no-progress -y
  560. fi
  561. - name: Build VCMI Installer
  562. run: >
  563. CI\wininstaller\build_installer.cmd
  564. "${{ steps.extract-version.outputs.short_version }}"
  565. "${{ env.VCMI_PACKAGE_BUILD }}"
  566. "${{ matrix.arch }}"
  567. "VCMI ${{ env.VCMI_PACKAGE_NAME_SUFFIX }}"
  568. "${{ env.VCMI_PACKAGE_FILE_NAME }}"
  569. "${{ github.workspace }}\artifact\extracted"
  570. "${{ github.workspace }}\ucrt"
  571. shell: cmd
  572. - name: Upload VCMI Installer Artifacts
  573. id: upload_installer
  574. uses: actions/upload-artifact@v4
  575. with:
  576. name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - installer
  577. compression-level: 9
  578. path: |
  579. ${{ github.workspace }}/CI/wininstaller/Output/*.exe
  580. - name: Upload Installer
  581. if: ${{ github.event.number == '' && env.DEPLOY_RSA != '' }}
  582. run: |
  583. cd '${{github.workspace}}/CI/wininstaller/Output'
  584. source '${{github.workspace}}/CI/upload_package.sh'
  585. env:
  586. DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
  587. PACKAGE_EXTENSION: exe
  588. - name: Prepare partial JSON with installer informations
  589. shell: bash
  590. run: |
  591. mkdir -p .summary
  592. cat > .summary/installer-${{ matrix.platform }}.json <<JSON
  593. {
  594. "platform": "${{ matrix.platform }}",
  595. "installer_url": "${{ steps.upload_installer.outputs.artifact-url }}"
  596. }
  597. JSON
  598. - name: Upload partial JSON with installer informations
  599. uses: actions/upload-artifact@v4
  600. with:
  601. name: partial-json-${{ matrix.platform }}-installer
  602. path: .summary/installer-${{ matrix.platform }}.json
  603. validate-code:
  604. name: Validate Code
  605. if: always()
  606. runs-on: ubuntu-latest
  607. defaults:
  608. run:
  609. shell: bash
  610. steps:
  611. - uses: actions/checkout@v5
  612. - name: Ensure LF line endings
  613. run: |
  614. find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -o -path ./test/googletest \
  615. -o -path ./osx -prune -o -type f \
  616. -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 '*.cmd' -and -not -name '*.iss' -and -not -name '*.isl' -print0 | \
  617. { ! xargs -0 grep -l -z -P '\r\n'; }
  618. - name: Validate JSON
  619. run: |
  620. sudo apt install python3-jstyleson
  621. python3 CI/validate_json.py
  622. - name: Validate Markdown
  623. uses: DavidAnson/markdownlint-cli2-action@v20
  624. with:
  625. config: 'CI/example.markdownlint-cli2.jsonc'
  626. globs: '**/*.md'
  627. final-summary:
  628. name: Build report
  629. if: always()
  630. needs: [build, windows-installer, validate-code, test, upload-source-package]
  631. runs-on: ubuntu-latest
  632. permissions:
  633. contents: read
  634. actions: write # Partial JSON artifacts can't be deleted in PRs
  635. steps:
  636. - name: Checkout (for script path)
  637. uses: actions/checkout@v5
  638. - name: Download all partial JSON artifacts
  639. continue-on-error: true
  640. uses: actions/download-artifact@v5
  641. with:
  642. pattern: partial-json-*
  643. merge-multiple: true
  644. path: partials
  645. - name: Run final summary
  646. env:
  647. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  648. run: |
  649. python3 CI/final_summary.py