github.yml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. name: VCMI
  2. on:
  3. push:
  4. branches:
  5. - beta
  6. - master
  7. - develop
  8. pull_request:
  9. workflow_dispatch:
  10. concurrency:
  11. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
  12. cancel-in-progress: true
  13. jobs:
  14. build:
  15. name: Build (${{ matrix.platform }})
  16. strategy:
  17. matrix:
  18. include:
  19. - platform: mac-intel
  20. os: macos-15
  21. pack: 1
  22. upload: 1
  23. pack_type: Release
  24. extension: dmg
  25. before_install: macos.sh
  26. preset: macos-conan-ninja-release
  27. conan_profile: macos-intel
  28. conan_prebuilts: dependencies-mac-intel
  29. conan_options: --profile=dependencies/conan_profiles/base/apple-system
  30. artifact_platform: intel
  31. - platform: mac-arm
  32. os: macos-15
  33. pack: 1
  34. upload: 1
  35. pack_type: Release
  36. extension: dmg
  37. before_install: macos.sh
  38. preset: macos-arm-conan-ninja-release
  39. conan_profile: macos-arm
  40. conan_prebuilts: dependencies-mac-arm
  41. conan_options: --profile=dependencies/conan_profiles/base/apple-system
  42. artifact_platform: arm
  43. - platform: ios
  44. os: macos-15
  45. pack: 1
  46. upload: 1
  47. pack_type: RelWithDebInfo
  48. extension: ipa
  49. before_install: macos.sh
  50. preset: ios-release-conan-ccache
  51. conan_profile: ios-arm64
  52. conan_prebuilts: dependencies-ios
  53. conan_options: --profile=dependencies/conan_profiles/base/apple-system
  54. - platform: msvc-x64
  55. arch: x64
  56. toolset: '14.29'
  57. os: windows-2025
  58. pack: 1
  59. upload: 0
  60. pack_type: RelWithDebInfo
  61. extension: zip
  62. preset: windows-msvc-ninja-release
  63. conan_profile: msvc-x64
  64. conan_prebuilts: dependencies-windows-x64
  65. conan_options: -s "&:build_type=RelWithDebInfo" -c tools.env.virtualenv:powershell=pwsh -o "&:target_pre_windows10=True"
  66. artifact_platform: x64
  67. - platform: msvc-x86
  68. arch: amd64_x86
  69. toolset: '14.29'
  70. os: windows-2025
  71. pack: 1
  72. upload: 0
  73. pack_type: RelWithDebInfo
  74. extension: zip
  75. preset: windows-msvc-ninja-release-x86
  76. conan_profile: msvc-x86
  77. conan_prebuilts: dependencies-windows-x86
  78. conan_options: -s "&:build_type=RelWithDebInfo" -c tools.env.virtualenv:powershell=pwsh -o "&:target_pre_windows10=True"
  79. artifact_platform: x86
  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. - platform: android-32
  93. os: ubuntu-latest
  94. upload: 1
  95. extension: apk
  96. preset: android-conan-ninja-release
  97. conan_profile: android-32-ndk
  98. conan_prebuilts: dependencies-android-armeabi-v7a
  99. conan_options: --profile=dependencies/conan_profiles/base/android-system
  100. artifact_platform: armeabi-v7a
  101. - platform: android-64
  102. os: ubuntu-latest
  103. upload: 1
  104. extension: apk
  105. preset: android-conan-ninja-release
  106. conan_profile: android-64-ndk
  107. conan_prebuilts: dependencies-android-arm64-v8a
  108. conan_options: --profile=dependencies/conan_profiles/base/android-system
  109. artifact_platform: arm64-v8a
  110. - platform: android-64-intel
  111. os: ubuntu-latest
  112. upload: 1
  113. extension: apk
  114. preset: android-conan-ninja-release
  115. conan_profile: android-x64-ndk
  116. conan_prebuilts: dependencies-android-x64
  117. conan_options: --profile=dependencies/conan_profiles/base/android-system
  118. artifact_platform: x64
  119. - platform: linux-appimage-x64
  120. os: ubuntu-24.04
  121. upload: 1
  122. preset: linux-gcc-release-appimage
  123. extension: AppImage
  124. before_install: linux_qt6.sh
  125. artifact_platform: x86_64
  126. - platform: linux-appimage-arm64
  127. os: ubuntu-24.04-arm
  128. upload: 1
  129. preset: linux-gcc-release-arm64-appimage
  130. extension: AppImage
  131. before_install: linux_qt6.sh
  132. artifact_platform: arm64
  133. runs-on: ${{ matrix.os }}
  134. defaults:
  135. run:
  136. shell: bash
  137. steps:
  138. - name: Checkout repository
  139. uses: actions/checkout@v6
  140. with:
  141. submodules: recursive
  142. - name: Prepare APT staging dir
  143. if: contains(matrix.os, 'ubuntu')
  144. run: mkdir -p "$RUNNER_TEMP/apt-cache"
  145. - name: APT cache restore
  146. if: contains(matrix.os, 'ubuntu')
  147. id: aptcache
  148. uses: actions/cache/restore@v5
  149. with:
  150. path: ${{ runner.temp }}/apt-cache
  151. key: ${{ matrix.platform }}-apt-${{ matrix.os }}
  152. restore-keys: |
  153. ${{ matrix.platform }}-apt-${{ matrix.os }}
  154. - name: Prepare CI
  155. if: "${{ matrix.before_install != '' }}"
  156. run: source '${{ github.workspace }}/CI/before_install/${{ matrix.before_install }}'
  157. - name: Configure codesigning for macOS
  158. if: ${{ startsWith(matrix.platform, 'mac-') }}
  159. env:
  160. KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  161. SIGNING_CERTIFICATE_BASE64: ${{ secrets.MACOS_SIGNING_CERTIFICATE_BASE64 }}
  162. SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_SIGNING_CERTIFICATE_PASSWORD }}
  163. run: |
  164. if [[ -z "$KEYCHAIN_PASSWORD" || -z "$SIGNING_CERTIFICATE_BASE64" || -z "$SIGNING_CERTIFICATE_PASSWORD" ]]; then
  165. echo "skip codesigning"
  166. exit 0
  167. fi
  168. keychainName=build.keychain
  169. security create-keychain -p "$KEYCHAIN_PASSWORD" "$keychainName"
  170. security default-keychain -s "$keychainName"
  171. security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$keychainName"
  172. security set-keychain-settings -u -t 7200 "$keychainName"
  173. certPath="$RUNNER_TEMP/cert.p12"
  174. printf "$SIGNING_CERTIFICATE_BASE64" | base64 -D -o "$certPath"
  175. security import "$certPath" -f pkcs12 -P "$SIGNING_CERTIFICATE_PASSWORD" -T "$(which codesign)" -k "$keychainName"
  176. security set-key-partition-list -S apple-tool:,apple: -s -k "$KEYCHAIN_PASSWORD" "$keychainName" >/dev/null
  177. # fetch SHA-1 of the p12 cert. Sample output for awk processing:
  178. # SHA1 Fingerprint=00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33
  179. signingIdentitySHA=$(openssl pkcs12 -in "$certPath" -nodes -passin "pass:$SIGNING_CERTIFICATE_PASSWORD" 2>/dev/null \
  180. | openssl x509 -noout -fingerprint -sha1 \
  181. | awk -F = '{ gsub(/:/, "", $2); print $2 }')
  182. echo MACOS_CODE_SIGN_IDENTITY=$signingIdentitySHA >> $GITHUB_ENV
  183. # Save only on cache miss, GitHub caches are immutable per key
  184. - name: APT cache save
  185. if: contains(matrix.os, 'ubuntu') && steps.aptcache.outputs.cache-hit != 'true'
  186. uses: actions/cache/save@v5
  187. with:
  188. path: ${{ runner.temp }}/apt-cache
  189. key: ${{ steps.aptcache.outputs.cache-primary-key }}
  190. - name: Install Conan Dependencies
  191. if: "${{ matrix.conan_prebuilts != '' }}"
  192. run: |
  193. pipx install conan
  194. source '${{github.workspace}}/CI/install_conan_dependencies.sh' '${{matrix.conan_prebuilts}}'
  195. - name: Setup MSVC Developer Command Prompt
  196. if: ${{ startsWith(matrix.platform, 'msvc') }}
  197. uses: ilammy/msvc-dev-cmd@v1
  198. with:
  199. arch: ${{ matrix.arch }}
  200. toolset: ${{ matrix.toolset }}
  201. # ensure the cache for each PR is separate so they don't interfere with each other
  202. # fall back to cache of the vcmi/vcmi repo if no PR-specific cache is found
  203. - name: Setup compiler cache for PRs
  204. uses: hendrikmuhs/[email protected]
  205. if: ${{ github.event.number != '' }}
  206. with:
  207. variant: ${{ startsWith(matrix.platform, 'msvc') && 'sccache' || 'ccache' }}
  208. key: ${{ matrix.platform }}-PR-${{ github.event.number }}
  209. restore-keys: |
  210. ${{ matrix.platform }}-PR-${{ github.event.number }}
  211. ${{ matrix.platform }}-branch-${{ github.base_ref }}
  212. ${{ matrix.platform }}-
  213. create-symlink: ${{ !startsWith(matrix.platform, 'msvc') }}
  214. max-size: '5G'
  215. verbose: 2
  216. job-summary: "" # <-- disable built-in summary to avoid duplicate block
  217. - name: Setup compiler cache for branch builds
  218. uses: hendrikmuhs/[email protected]
  219. if: ${{ github.event.number == '' }}
  220. with:
  221. variant: ${{ startsWith(matrix.platform, 'msvc') && 'sccache' || 'ccache' }}
  222. key: ${{ matrix.platform }}-branch-${{ github.ref_name }}
  223. restore-keys: |
  224. ${{ matrix.platform }}-branch-${{ github.ref_name }}
  225. ${{ matrix.platform }}-
  226. create-symlink: ${{ !startsWith(matrix.platform, 'msvc') }}
  227. max-size: '5G'
  228. verbose: 2
  229. job-summary: "" # <-- disable built-in summary to avoid duplicate block
  230. - name: CCache tuning (Android)
  231. if: ${{ startsWith(matrix.platform, 'android') }}
  232. run: |
  233. echo "/usr/lib/ccache" >> $GITHUB_PATH
  234. ccache --set-config=compiler_check=content
  235. ccache --set-config=base_dir="${GITHUB_WORKSPACE}"
  236. ccache --set-config=hash_dir=true
  237. ccache --set-config=sloppiness=time_macros
  238. # TODO: remove once v4.13 is available in Homebrew
  239. - name: Install ccache v4.13
  240. if: ${{ matrix.platform == 'ios' }}
  241. run: |
  242. curl -L https://github.com/ccache/ccache/releases/download/v4.13/ccache-4.13-darwin.tar.gz \
  243. | tar -xf -
  244. echo "$(pwd)/ccache-4.13-darwin" >> $GITHUB_PATH
  245. - name: Install Conan profile
  246. if: "${{ matrix.conan_profile != '' }}"
  247. run: |
  248. conan profile detect
  249. outFolder=conan-generated
  250. conan install . \
  251. --output-folder="$outFolder" \
  252. --build=never \
  253. --profile=dependencies/conan_profiles/${{ matrix.conan_profile }} \
  254. --conf="tools.cmake.cmaketoolchain:generator=Ninja" \
  255. ${{ matrix.conan_options }}
  256. ${{ startsWith(matrix.platform, 'msvc') && 'echo CONANRUN_PWSH_SCRIPT="$outFolder/conanrun.ps1" >> $GITHUB_ENV' || '' }}
  257. # Can't be set in Gradle project
  258. - name: Configure enableUncompressedNativeLibs
  259. if: ${{ startsWith(matrix.platform, 'android') }}
  260. run: mkdir -p ~/.gradle && echo "android.bundle.enableUncompressedNativeLibs=true" > ~/.gradle/gradle.properties
  261. - name: Install Java
  262. uses: actions/setup-java@v5
  263. if: ${{ startsWith(matrix.platform, 'android') }}
  264. with:
  265. distribution: 'temurin'
  266. java-version: '17'
  267. # Frees 10+GB on linux runners by removing unused tools (.NET, Haskell compiler)
  268. - name: Free up disk space
  269. if: contains(matrix.os, 'ubuntu')
  270. run: |
  271. echo "Disk usage BEFORE cleanup:"
  272. df -h
  273. sudo rm -rf /opt/ghc /usr/local/.ghcup /usr/share/dotnet || :
  274. echo "Disk usage AFTER cleanup:"
  275. df -h
  276. # a hack to build ID for x64 build in order for Google Play to allow upload of both 32 and 64 bit builds
  277. - name: Bump Android x64 build ID
  278. if: ${{ matrix.platform == 'android-64' }}
  279. run: perl -i -pe 's/versionCode (\d+)/$x=$1+1; "versionCode $x"/e' android/vcmi-app/build.gradle
  280. - name: Bump Android x86_64 build ID
  281. if: ${{ matrix.platform == 'android-64-intel' }}
  282. run: perl -i -pe 's/versionCode (\d+)/$x=$1+2; "versionCode $x"/e' android/vcmi-app/build.gradle
  283. - name: Build Number
  284. run: |
  285. source '${{github.workspace}}/CI/get_package_name.sh'
  286. if [ '${{ matrix.artifact_platform }}' ]; then
  287. VCMI_PACKAGE_FILE_NAME+="-${{ matrix.artifact_platform }}"
  288. fi
  289. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  290. echo VCMI_PACKAGE_BUILD="$VCMI_PACKAGE_BUILD" >> $GITHUB_ENV
  291. echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
  292. echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
  293. env:
  294. PULL_REQUEST: ${{ github.event.pull_request.number }}
  295. - name: Configure (non-MSVC)
  296. if: ${{ !startsWith(matrix.platform, 'msvc') }}
  297. run: |
  298. if [[ ("${{ matrix.preset }}" == "android-conan-ninja-release") && ("${{ github.ref }}" != 'refs/heads/master') ]]; then
  299. # key1=value1;key2=value2;...
  300. gradleProperties=$(python3 CI/android/gradle_daily_props.py)
  301. androidOptions=("-DANDROID_GRADLE_PROPERTIES=$gradleProperties")
  302. androidOptions+=("-DCMAKE_C_COMPILER_LAUNCHER=ccache" "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache")
  303. fi
  304. cmake -DENABLE_CCACHE:BOOL=ON "${androidOptions[@]}" --preset ${{ matrix.preset }}
  305. - name: Configure (MSVC)
  306. if: ${{ startsWith(matrix.platform, 'msvc') }}
  307. run: |
  308. & $env:CONANRUN_PWSH_SCRIPT
  309. cmake --preset ${{ matrix.preset }}
  310. shell: pwsh
  311. - name: Build
  312. run: |
  313. ${{ startsWith(matrix.platform, 'msvc') && '& $env:CONANRUN_PWSH_SCRIPT' || '' }}
  314. cmake --build --preset ${{matrix.preset}}
  315. shell: pwsh
  316. env:
  317. ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
  318. ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
  319. - name: Create AppImage
  320. if: ${{ matrix.platform == 'linux-appimage-x64' || matrix.platform == 'linux-appimage-arm64' }}
  321. env:
  322. BUILD_DIR: ${{ github.workspace }}/out/build/${{ matrix.preset }}
  323. ARCH: ${{ matrix.artifact_platform }}
  324. run: |
  325. chmod +x CI/create_appimage.sh
  326. CI/create_appimage.sh
  327. - name: Kill XProtect to work around CPack issue on macOS
  328. if: ${{ startsWith(matrix.platform, 'mac') }}
  329. run: |
  330. # Cf. https://github.com/actions/runner-images/issues/7522#issuecomment-1556766641
  331. echo Killing...; sudo pkill -9 XProtect >/dev/null || true;
  332. echo "Waiting..."; counter=0; while pgrep XProtect && ((counter < 20)); do sleep 3; ((counter++)); done
  333. pgrep XProtect || true
  334. - name: Pack
  335. id: cpack
  336. if: ${{ matrix.pack == 1 }}
  337. run: |
  338. ${{ startsWith(matrix.platform, 'msvc') && '& $env:CONANRUN_PWSH_SCRIPT' }}
  339. cd "${{github.workspace}}/out/build/${{matrix.preset}}"
  340. cpack -C ${{matrix.pack_type}}
  341. shell: pwsh
  342. - name: Notarize macOS dmg
  343. if: ${{ startsWith(matrix.platform, 'mac-') }}
  344. env:
  345. NOTARIZATION_APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
  346. NOTARIZATION_APPLE_ID_PASSWORD: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID_PASSWORD }}
  347. NOTARIZATION_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
  348. run: |
  349. if [[ -z "$NOTARIZATION_APPLE_ID" || -z "$NOTARIZATION_APPLE_ID_PASSWORD" || -z "$NOTARIZATION_TEAM_ID" ]]; then
  350. echo "skip notarization"
  351. exit 0
  352. fi
  353. dmg='${{ github.workspace }}/out/build/${{ matrix.preset }}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}'
  354. codesign --verbose=4 --force --sign "$MACOS_CODE_SIGN_IDENTITY" "$dmg"
  355. xcrun notarytool submit \
  356. --apple-id "$NOTARIZATION_APPLE_ID" \
  357. --password "$NOTARIZATION_APPLE_ID_PASSWORD" \
  358. --team-id "$NOTARIZATION_TEAM_ID" \
  359. --wait \
  360. "$dmg"
  361. xcrun stapler staple "$dmg"
  362. - name: Find Android package
  363. if: ${{ startsWith(matrix.platform, 'android') }}
  364. run: |
  365. OUTPUT_DIRECTORY="${{ github.workspace }}/out/build/${{ matrix.preset }}/android-build/vcmi-app/build/outputs"
  366. mv "$OUTPUT_DIRECTORY/apk/release/vcmi-release.apk" "${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.apk"
  367. mv "$OUTPUT_DIRECTORY/bundle/release/vcmi-release.aab" "${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.aab"
  368. - name: Upload Artifact
  369. id: upload_artifact
  370. uses: actions/upload-artifact@v6
  371. with:
  372. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}
  373. compression-level: 9
  374. path: |
  375. ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
  376. - name: Upload AAB Artifact
  377. id: upload_aab
  378. if: ${{ startsWith(matrix.platform, 'android') && github.ref == 'refs/heads/master' }}
  379. uses: actions/upload-artifact@v6
  380. with:
  381. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}-aab
  382. compression-level: 9
  383. path: |
  384. ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.aab
  385. - name: Upload MSVC debug symbols
  386. id: upload_symbols
  387. if: ${{ startsWith(matrix.platform, 'msvc') }}
  388. uses: actions/upload-artifact@v6
  389. with:
  390. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}-symbols
  391. compression-level: 9
  392. path: |
  393. ${{github.workspace}}/**/*.pdb
  394. - name: Create iOS AppStore debug symbols
  395. if: ${{ matrix.platform == 'ios' }}
  396. run: |
  397. IOS_APPSTORE_SYMBOLS_DIR='${{ github.workspace }}/Symbols'
  398. mkdir "$IOS_APPSTORE_SYMBOLS_DIR"
  399. dsyms=$(find '${{ github.workspace }}/out/build/${{ matrix.preset }}' -name '*.dSYM')
  400. xcrun symbols -arch all -symbolsPackageDir "$IOS_APPSTORE_SYMBOLS_DIR" $dsyms
  401. echo IOS_APPSTORE_SYMBOLS_DIR="$IOS_APPSTORE_SYMBOLS_DIR" >> $GITHUB_ENV
  402. - name: Upload iOS AppStore debug symbols
  403. if: ${{ matrix.platform == 'ios' }}
  404. uses: actions/upload-artifact@v6
  405. with:
  406. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}-symbols
  407. compression-level: 9
  408. path: |
  409. ${{ env.IOS_APPSTORE_SYMBOLS_DIR }}
  410. - name: Upload build to download.vcmi.eu
  411. if: ${{ matrix.upload == 1 && github.event.number == '' && env.DEPLOY_RSA != '' }}
  412. run: |
  413. if [ -z '${{ env.ANDROID_APK_PATH }}' ] ; then
  414. cd '${{github.workspace}}/out/build/${{matrix.preset}}'
  415. fi
  416. source '${{github.workspace}}/CI/upload_package.sh'
  417. env:
  418. DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
  419. PACKAGE_EXTENSION: ${{ matrix.extension }}
  420. - name: Prepare partial JSON with build informations
  421. id: make_partial_json
  422. env:
  423. PLATFORM: ${{ matrix.platform }}
  424. ARTIFACT_URL: ${{ steps.upload_artifact.outputs.artifact-url }}
  425. DEBUG_SYMBOLS_URL: ${{ steps.upload_symbols.outputs.artifact-url }}
  426. AAB_URL: ${{ steps.upload_aab.outputs.artifact-url }}
  427. run: |
  428. python3 CI/emit_partial.py
  429. - name: Upload partial JSON with build informations
  430. uses: actions/upload-artifact@v6
  431. with:
  432. name: partial-json-${{ matrix.platform }}
  433. path: .summary/${{ matrix.platform }}.json
  434. upload-source-package:
  435. name: Upload Source Code Package
  436. if: always() && github.event.number == ''
  437. runs-on: ubuntu-latest
  438. defaults:
  439. run:
  440. shell: bash
  441. steps:
  442. - uses: actions/checkout@v6
  443. with:
  444. submodules: recursive
  445. - name: Build Number
  446. run: |
  447. source '${{github.workspace}}/CI/get_package_name.sh'
  448. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  449. - name: Create source code archive (including submodules)
  450. run: |
  451. git archive HEAD -o "release.tar" --worktree-attributes -v
  452. git submodule update --init --recursive
  453. git submodule --quiet foreach 'cd "$toplevel"; tar -rvf "release.tar" "$sm_path"'
  454. gzip release.tar
  455. - name: Upload source code archive
  456. id: upload_source
  457. uses: actions/upload-artifact@v6
  458. with:
  459. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
  460. compression-level: 9
  461. path: |
  462. ./release.tar.gz
  463. - name: Prepare partial JSON with source informations
  464. shell: bash
  465. run: |
  466. mkdir -p .summary
  467. cat > .summary/source.json <<JSON
  468. {"source_url": "${{ steps.upload_source.outputs.artifact-url }}"}
  469. JSON
  470. - name: Upload partial JSON with source informations
  471. uses: actions/upload-artifact@v6
  472. with:
  473. name: partial-json-source
  474. path: .summary/source.json
  475. test:
  476. name: Test (${{ matrix.platform }})
  477. strategy:
  478. fail-fast: false
  479. matrix:
  480. include:
  481. - platform: gcc-latest-release
  482. os: ubuntu-24.04
  483. before_install: linux_qt6.sh
  484. compiler_cxx: g++-14
  485. compiler_cc: gcc-14
  486. preset: linux-gcc-test
  487. - platform: clang-latest-debug
  488. os: ubuntu-24.04
  489. before_install: linux_qt6.sh
  490. compiler_cxx: clang++-18
  491. compiler_cc: clang-18
  492. preset: linux-clang-debug
  493. - platform: gcc-oldest-debug
  494. os: ubuntu-22.04
  495. before_install: linux_qt5.sh
  496. compiler_cxx: g++-10
  497. compiler_cc: gcc-10
  498. preset: linux-gcc-debug
  499. - platform: clang-oldest-release
  500. os: ubuntu-22.04
  501. before_install: linux_qt5.sh
  502. compiler_cxx: clang++-13
  503. compiler_cc: clang-13
  504. preset: linux-clang-test
  505. runs-on: ${{ matrix.os }}
  506. defaults:
  507. run:
  508. shell: bash
  509. steps:
  510. - name: Checkout repository
  511. uses: actions/checkout@v6
  512. with:
  513. submodules: recursive
  514. - name: Prepare APT staging dir
  515. if: contains(matrix.os, 'ubuntu')
  516. run: mkdir -p "$RUNNER_TEMP/apt-cache"
  517. - name: APT cache restore
  518. if: contains(matrix.os, 'ubuntu')
  519. id: aptcache
  520. uses: actions/cache/restore@v5
  521. with:
  522. path: ${{ runner.temp }}/apt-cache
  523. key: ${{ matrix.platform }}-apt-${{ matrix.os }}
  524. restore-keys: |
  525. ${{ matrix.platform }}-apt-${{ matrix.os }}
  526. - name: Prepare CI
  527. run: source '${{ github.workspace }}/CI/before_install/${{ matrix.before_install }}'
  528. - name: APT cache save
  529. if: contains(matrix.os, 'ubuntu') && steps.aptcache.outputs.cache-hit != 'true'
  530. uses: actions/cache/save@v5
  531. with:
  532. path: ${{ runner.temp }}/apt-cache
  533. key: ${{ steps.aptcache.outputs.cache-primary-key }}
  534. - name: Setup compiler cache for PRs
  535. uses: hendrikmuhs/[email protected]
  536. if: ${{ github.event.number != '' }}
  537. with:
  538. key: ${{ matrix.platform }}-PR-${{ github.event.number }}
  539. restore-keys: |
  540. ${{ matrix.platform }}-PR-${{ github.event.number }}
  541. ${{ matrix.platform }}-branch-${{ github.base_ref }}
  542. ${{ matrix.platform }}-
  543. max-size: '5G'
  544. verbose: 2
  545. - name: Setup compiler cache for branch builds
  546. uses: hendrikmuhs/[email protected]
  547. if: ${{ github.event.number == '' }}
  548. with:
  549. key: ${{ matrix.platform }}-branch-${{ github.ref_name }}
  550. restore-keys: |
  551. ${{ matrix.platform }}-branch-${{ github.ref_name }}
  552. ${{ matrix.platform }}-
  553. max-size: '5G'
  554. verbose: 2
  555. - name: Prepare Heroes 3 data
  556. run: |
  557. data_url="https://github.com/vcmi-mods/vcmi-test-data/releases/download/v2.0/heroes3.7z"
  558. wget --progress=dot:giga "$data_url" -O heroes3.7z
  559. mkdir -p ~/.local/share/vcmi/
  560. 7za x -o"$HOME/.local/share/vcmi/" heroes3.7z
  561. - name: Configure
  562. run: |
  563. cmake -DENABLE_CCACHE:BOOL=ON -DCMAKE_C_COMPILER=${{ matrix.compiler_cc }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler_cxx }} --preset ${{ matrix.preset }}
  564. - name: Build
  565. run: |
  566. cmake --build --preset ${{matrix.preset}}
  567. - name: Test
  568. run: |
  569. ctest --preset ${{matrix.preset}}
  570. - name: Validate library startup
  571. run: |
  572. cd "${{github.workspace}}/out/build/${{matrix.preset}}/bin"
  573. ./vcmiserver --dummy-run 2> >(tee error.log)
  574. if [ ! -s error.log ]; then
  575. echo "Validation OK!"
  576. exit 0
  577. else
  578. echo "Validation failed!"
  579. exit 1
  580. fi
  581. windows-installer:
  582. needs: build
  583. if: ${{ needs.build.result == 'success' }}
  584. name: Create Windows Installer (${{ matrix.arch }})
  585. strategy:
  586. matrix:
  587. include:
  588. - platform: msvc-x64
  589. arch: x64
  590. os: windows-2025
  591. - platform: msvc-x86
  592. arch: x86
  593. os: windows-2025
  594. - platform: msvc-arm64
  595. arch: arm64
  596. os: windows-11-arm
  597. runs-on: ${{ matrix.os }}
  598. defaults:
  599. run:
  600. shell: bash
  601. steps:
  602. - name: Checkout repository
  603. uses: actions/checkout@v6
  604. with:
  605. submodules: recursive
  606. - name: Extract version info
  607. id: extract-version
  608. run: |
  609. filePath="${GITHUB_WORKSPACE}/cmake_modules/VersionDefinition.cmake"
  610. major=$(grep -m 1 "VCMI_VERSION_MAJOR" "$filePath" | tr -d -c 0-9)
  611. minor=$(grep -m 1 "VCMI_VERSION_MINOR" "$filePath" | tr -d -c 0-9)
  612. patch=$(grep -m 1 "VCMI_VERSION_PATCH" "$filePath" | tr -d -c 0-9)
  613. short_version="${major}.${minor}.${patch}"
  614. version_timestamp=$(date +"%Y%m%d%H%M%S")
  615. echo "short_version=${short_version}" >> "$GITHUB_OUTPUT"
  616. echo "version_timestamp=${version_timestamp}" >> "$GITHUB_OUTPUT"
  617. - name: Download UCRT
  618. run: source '${{github.workspace}}/CI/wininstaller/download_ucrt.sh' '${{matrix.platform}}'
  619. - name: Build Number
  620. run: |
  621. source '${{github.workspace}}/CI/get_package_name.sh'
  622. VCMI_PACKAGE_FILE_NAME+="-${{ matrix.arch }}"
  623. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  624. echo VCMI_PACKAGE_BUILD="$VCMI_PACKAGE_BUILD" >> $GITHUB_ENV
  625. echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
  626. echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
  627. env:
  628. PULL_REQUEST: ${{ github.event.pull_request.number }}
  629. - name: Download Artifact
  630. uses: actions/download-artifact@v7
  631. with:
  632. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}
  633. path: ${{github.workspace}}/artifact
  634. - name: Extract Artifact
  635. run: |
  636. mkdir artifact/extracted
  637. unzip "artifact/${{ env.VCMI_PACKAGE_FILE_NAME }}.zip" -d artifact/extracted
  638. - name: Ensure Inno Setup is installed
  639. run: |
  640. if [ ! -f "/c/Program Files (x86)/Inno Setup 6/ISCC.exe" ] && [ ! -f "/c/ProgramData/Chocolatey/bin/ISCC.exe" ]; then
  641. choco install innosetup --no-progress -y
  642. fi
  643. - name: Build VCMI Installer
  644. run: >
  645. CI\wininstaller\build_installer.cmd
  646. "${{ steps.extract-version.outputs.short_version }}"
  647. "${{ env.VCMI_PACKAGE_BUILD }}"
  648. "${{ matrix.arch }}"
  649. "VCMI ${{ env.VCMI_PACKAGE_NAME_SUFFIX }}"
  650. "${{ env.VCMI_PACKAGE_FILE_NAME }}"
  651. "${{ github.workspace }}\artifact\extracted"
  652. "${{ github.workspace }}\ucrt"
  653. shell: cmd
  654. - name: Upload VCMI Installer Artifacts
  655. id: upload_installer
  656. uses: actions/upload-artifact@v6
  657. with:
  658. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}-installer
  659. compression-level: 9
  660. path: |
  661. ${{ github.workspace }}/CI/wininstaller/Output/*.exe
  662. - name: Upload Installer
  663. if: ${{ github.event.number == '' && env.DEPLOY_RSA != '' }}
  664. run: |
  665. cd '${{github.workspace}}/CI/wininstaller/Output'
  666. source '${{github.workspace}}/CI/upload_package.sh'
  667. env:
  668. DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
  669. PACKAGE_EXTENSION: exe
  670. - name: Prepare partial JSON with installer informations
  671. shell: bash
  672. run: |
  673. mkdir -p .summary
  674. cat > .summary/installer-${{ matrix.platform }}.json <<JSON
  675. {
  676. "platform": "${{ matrix.platform }}",
  677. "installer_url": "${{ steps.upload_installer.outputs.artifact-url }}"
  678. }
  679. JSON
  680. - name: Upload partial JSON with installer informations
  681. uses: actions/upload-artifact@v6
  682. with:
  683. name: partial-json-${{ matrix.platform }}-installer
  684. path: .summary/installer-${{ matrix.platform }}.json
  685. validate-code:
  686. name: Validate Code
  687. if: always()
  688. runs-on: ubuntu-latest
  689. defaults:
  690. run:
  691. shell: bash
  692. steps:
  693. - uses: actions/checkout@v6
  694. - name: Ensure LF line endings
  695. run: |
  696. find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -o -path ./test/googletest \
  697. -o -path ./osx -prune -o -type f \
  698. -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 | \
  699. { ! xargs -0 grep -l -z -P '\r\n'; }
  700. - name: Validate JSON
  701. run: |
  702. sudo apt install python3-jstyleson
  703. python3 CI/validate_json.py
  704. - name: Validate Markdown
  705. uses: DavidAnson/markdownlint-cli2-action@v22
  706. with:
  707. config: 'CI/example.markdownlint-cli2.jsonc'
  708. globs: '**/*.md'
  709. final-summary:
  710. name: Build report
  711. if: always()
  712. needs: [build, windows-installer, validate-code, test, upload-source-package]
  713. runs-on: ubuntu-latest
  714. permissions:
  715. contents: read
  716. actions: write # Partial JSON artifacts can't be deleted in PRs
  717. steps:
  718. - name: Checkout (for script path)
  719. uses: actions/checkout@v6
  720. - name: Download all partial JSON artifacts
  721. continue-on-error: true
  722. uses: actions/download-artifact@v7
  723. with:
  724. pattern: partial-json-*
  725. merge-multiple: true
  726. path: partials
  727. - name: Run final summary
  728. env:
  729. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  730. run: |
  731. python3 CI/final_summary.py