github.yml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  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-14
  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-14
  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-14
  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. - name: Install Conan profile
  239. if: "${{ matrix.conan_profile != '' }}"
  240. run: |
  241. conan profile detect
  242. outFolder=conan-generated
  243. conan install . \
  244. --output-folder="$outFolder" \
  245. --build=never \
  246. --profile=dependencies/conan_profiles/${{ matrix.conan_profile }} \
  247. ${{ matrix.conan_options }}
  248. ${{ startsWith(matrix.platform, 'msvc') && 'echo CONANRUN_PWSH_SCRIPT="$outFolder/conanrun.ps1" >> $GITHUB_ENV' || '' }}
  249. # Can't be set in Gradle project
  250. - name: Configure enableUncompressedNativeLibs
  251. if: ${{ startsWith(matrix.platform, 'android') }}
  252. run: mkdir -p ~/.gradle && echo "android.bundle.enableUncompressedNativeLibs=true" > ~/.gradle/gradle.properties
  253. - name: Install Java
  254. uses: actions/setup-java@v5
  255. if: ${{ startsWith(matrix.platform, 'android') }}
  256. with:
  257. distribution: 'temurin'
  258. java-version: '17'
  259. # Frees 10+GB on linux runners by removing unused tools (.NET, Haskell compiler)
  260. - name: Free up disk space
  261. if: contains(matrix.os, 'ubuntu')
  262. run: |
  263. echo "Disk usage BEFORE cleanup:"
  264. df -h
  265. sudo rm -rf /opt/ghc /usr/local/.ghcup /usr/share/dotnet || :
  266. echo "Disk usage AFTER cleanup:"
  267. df -h
  268. # a hack to build ID for x64 build in order for Google Play to allow upload of both 32 and 64 bit builds
  269. - name: Bump Android x64 build ID
  270. if: ${{ matrix.platform == 'android-64' }}
  271. run: perl -i -pe 's/versionCode (\d+)/$x=$1+1; "versionCode $x"/e' android/vcmi-app/build.gradle
  272. - name: Bump Android x86_64 build ID
  273. if: ${{ matrix.platform == 'android-64-intel' }}
  274. run: perl -i -pe 's/versionCode (\d+)/$x=$1+2; "versionCode $x"/e' android/vcmi-app/build.gradle
  275. - name: Build Number
  276. run: |
  277. source '${{github.workspace}}/CI/get_package_name.sh'
  278. if [ '${{ matrix.artifact_platform }}' ]; then
  279. VCMI_PACKAGE_FILE_NAME+="-${{ matrix.artifact_platform }}"
  280. fi
  281. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  282. echo VCMI_PACKAGE_BUILD="$VCMI_PACKAGE_BUILD" >> $GITHUB_ENV
  283. echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
  284. echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
  285. env:
  286. PULL_REQUEST: ${{ github.event.pull_request.number }}
  287. - name: Configure (non-MSVC)
  288. if: ${{ !startsWith(matrix.platform, 'msvc') }}
  289. run: |
  290. if [[ ("${{ matrix.preset }}" == "android-conan-ninja-release") && ("${{ github.ref }}" != 'refs/heads/master') ]]; then
  291. # key1=value1;key2=value2;...
  292. gradleProperties=$(python3 CI/android/gradle_daily_props.py)
  293. androidOptions=("-DANDROID_GRADLE_PROPERTIES=$gradleProperties")
  294. androidOptions+=("-DCMAKE_C_COMPILER_LAUNCHER=ccache" "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache")
  295. fi
  296. cmake -DENABLE_CCACHE:BOOL=ON "${androidOptions[@]}" --preset ${{ matrix.preset }}
  297. - name: Configure (MSVC)
  298. if: ${{ startsWith(matrix.platform, 'msvc') }}
  299. run: |
  300. & $env:CONANRUN_PWSH_SCRIPT
  301. cmake --preset ${{ matrix.preset }}
  302. shell: pwsh
  303. - name: Build
  304. run: |
  305. ${{ startsWith(matrix.platform, 'msvc') && '& $env:CONANRUN_PWSH_SCRIPT' }}
  306. cmake --build --preset ${{matrix.preset}}
  307. shell: pwsh
  308. env:
  309. ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
  310. ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
  311. - name: Create AppImage
  312. if: ${{ matrix.platform == 'linux-appimage-x64' || matrix.platform == 'linux-appimage-arm64' }}
  313. env:
  314. BUILD_DIR: ${{ github.workspace }}/out/build/${{ matrix.preset }}
  315. ARCH: ${{ matrix.artifact_platform }}
  316. run: |
  317. chmod +x CI/create_appimage.sh
  318. CI/create_appimage.sh
  319. - name: Kill XProtect to work around CPack issue on macOS
  320. if: ${{ startsWith(matrix.platform, 'mac') }}
  321. run: |
  322. # Cf. https://github.com/actions/runner-images/issues/7522#issuecomment-1556766641
  323. echo Killing...; sudo pkill -9 XProtect >/dev/null || true;
  324. echo "Waiting..."; counter=0; while pgrep XProtect && ((counter < 20)); do sleep 3; ((counter++)); done
  325. pgrep XProtect || true
  326. - name: Pack
  327. id: cpack
  328. if: ${{ matrix.pack == 1 }}
  329. run: |
  330. ${{ startsWith(matrix.platform, 'msvc') && '& $env:CONANRUN_PWSH_SCRIPT' }}
  331. cd "${{github.workspace}}/out/build/${{matrix.preset}}"
  332. cpack -C ${{matrix.pack_type}}
  333. shell: pwsh
  334. - name: Notarize macOS dmg
  335. if: ${{ startsWith(matrix.platform, 'mac-') }}
  336. env:
  337. NOTARIZATION_APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
  338. NOTARIZATION_APPLE_ID_PASSWORD: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID_PASSWORD }}
  339. NOTARIZATION_TEAM_ID: ${{ secrets.MACOS_NOTARIZATION_TEAM_ID }}
  340. run: |
  341. if [[ -z "$NOTARIZATION_APPLE_ID" || -z "$NOTARIZATION_APPLE_ID_PASSWORD" || -z "$NOTARIZATION_TEAM_ID" ]]; then
  342. echo "skip notarization"
  343. exit 0
  344. fi
  345. dmg='${{ github.workspace }}/out/build/${{ matrix.preset }}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}'
  346. codesign --verbose=4 --force --sign "$MACOS_CODE_SIGN_IDENTITY" "$dmg"
  347. xcrun notarytool submit \
  348. --apple-id "$NOTARIZATION_APPLE_ID" \
  349. --password "$NOTARIZATION_APPLE_ID_PASSWORD" \
  350. --team-id "$NOTARIZATION_TEAM_ID" \
  351. --wait \
  352. "$dmg"
  353. xcrun stapler staple "$dmg"
  354. - name: Find Android package
  355. if: ${{ startsWith(matrix.platform, 'android') }}
  356. run: |
  357. OUTPUT_DIRECTORY="${{ github.workspace }}/out/build/${{ matrix.preset }}/android-build/vcmi-app/build/outputs"
  358. mv "$OUTPUT_DIRECTORY/apk/release/vcmi-release.apk" "${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.apk"
  359. mv "$OUTPUT_DIRECTORY/bundle/release/vcmi-release.aab" "${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.aab"
  360. - name: Upload Artifact
  361. id: upload_artifact
  362. uses: actions/upload-artifact@v7
  363. with:
  364. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}
  365. compression-level: 9
  366. path: |
  367. ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
  368. - name: Upload AAB Artifact
  369. id: upload_aab
  370. if: ${{ startsWith(matrix.platform, 'android') && github.ref == 'refs/heads/master' }}
  371. uses: actions/upload-artifact@v7
  372. with:
  373. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}-aab
  374. compression-level: 9
  375. path: |
  376. ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.aab
  377. - name: Upload MSVC debug symbols
  378. id: upload_symbols
  379. if: ${{ startsWith(matrix.platform, 'msvc') }}
  380. uses: actions/upload-artifact@v7
  381. with:
  382. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}-symbols
  383. compression-level: 9
  384. path: |
  385. ${{github.workspace}}/**/*.pdb
  386. - name: Create iOS AppStore debug symbols
  387. if: ${{ matrix.platform == 'ios' }}
  388. run: |
  389. IOS_APPSTORE_SYMBOLS_DIR='${{ github.workspace }}/Symbols'
  390. mkdir "$IOS_APPSTORE_SYMBOLS_DIR"
  391. dsyms=$(find '${{ github.workspace }}/out/build/${{ matrix.preset }}' -name '*.dSYM')
  392. xcrun symbols -arch all -symbolsPackageDir "$IOS_APPSTORE_SYMBOLS_DIR" $dsyms
  393. echo IOS_APPSTORE_SYMBOLS_DIR="$IOS_APPSTORE_SYMBOLS_DIR" >> $GITHUB_ENV
  394. - name: Upload iOS AppStore debug symbols
  395. if: ${{ matrix.platform == 'ios' }}
  396. uses: actions/upload-artifact@v7
  397. with:
  398. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}-symbols
  399. compression-level: 9
  400. path: |
  401. ${{ env.IOS_APPSTORE_SYMBOLS_DIR }}
  402. - name: Upload build to download.vcmi.eu
  403. if: ${{ matrix.upload == 1 && github.event.number == '' && env.DEPLOY_RSA != '' }}
  404. run: |
  405. if [ -z '${{ env.ANDROID_APK_PATH }}' ] ; then
  406. cd '${{github.workspace}}/out/build/${{matrix.preset}}'
  407. fi
  408. source '${{github.workspace}}/CI/upload_package.sh'
  409. env:
  410. DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
  411. PACKAGE_EXTENSION: ${{ matrix.extension }}
  412. - name: Prepare partial JSON with build informations
  413. id: make_partial_json
  414. env:
  415. PLATFORM: ${{ matrix.platform }}
  416. ARTIFACT_URL: ${{ steps.upload_artifact.outputs.artifact-url }}
  417. DEBUG_SYMBOLS_URL: ${{ steps.upload_symbols.outputs.artifact-url }}
  418. AAB_URL: ${{ steps.upload_aab.outputs.artifact-url }}
  419. run: |
  420. python3 CI/emit_partial.py
  421. - name: Upload partial JSON with build informations
  422. uses: actions/upload-artifact@v7
  423. with:
  424. name: partial-json-${{ matrix.platform }}
  425. path: .summary/${{ matrix.platform }}.json
  426. upload-source-package:
  427. name: Upload Source Code Package
  428. if: always() && github.event.number == ''
  429. runs-on: ubuntu-latest
  430. defaults:
  431. run:
  432. shell: bash
  433. steps:
  434. - uses: actions/checkout@v6
  435. with:
  436. submodules: recursive
  437. - name: Build Number
  438. run: |
  439. source '${{github.workspace}}/CI/get_package_name.sh'
  440. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  441. - name: Create source code archive (including submodules)
  442. run: |
  443. git archive HEAD -o "release.tar" --worktree-attributes -v
  444. git submodule update --init --recursive
  445. git submodule --quiet foreach 'cd "$toplevel"; tar -rvf "release.tar" "$sm_path"'
  446. gzip release.tar
  447. - name: Upload source code archive
  448. id: upload_source
  449. uses: actions/upload-artifact@v7
  450. with:
  451. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
  452. compression-level: 9
  453. path: |
  454. ./release.tar.gz
  455. - name: Prepare partial JSON with source informations
  456. shell: bash
  457. run: |
  458. mkdir -p .summary
  459. cat > .summary/source.json <<JSON
  460. {"source_url": "${{ steps.upload_source.outputs.artifact-url }}"}
  461. JSON
  462. - name: Upload partial JSON with source informations
  463. uses: actions/upload-artifact@v7
  464. with:
  465. name: partial-json-source
  466. path: .summary/source.json
  467. test:
  468. name: Test (${{ matrix.platform }})
  469. strategy:
  470. fail-fast: false
  471. matrix:
  472. include:
  473. - platform: gcc-latest-release
  474. os: ubuntu-24.04
  475. before_install: linux_qt6.sh
  476. compiler_cxx: g++-14
  477. compiler_cc: gcc-14
  478. preset: linux-gcc-test
  479. - platform: clang-latest-debug
  480. os: ubuntu-24.04
  481. before_install: linux_qt6.sh
  482. compiler_cxx: clang++-18
  483. compiler_cc: clang-18
  484. preset: linux-clang-debug
  485. - platform: gcc-oldest-debug
  486. os: ubuntu-22.04
  487. before_install: linux_qt5.sh
  488. compiler_cxx: g++-10
  489. compiler_cc: gcc-10
  490. preset: linux-gcc-debug
  491. - platform: clang-oldest-release
  492. os: ubuntu-22.04
  493. before_install: linux_qt5.sh
  494. compiler_cxx: clang++-13
  495. compiler_cc: clang-13
  496. preset: linux-clang-test
  497. runs-on: ${{ matrix.os }}
  498. defaults:
  499. run:
  500. shell: bash
  501. steps:
  502. - name: Checkout repository
  503. uses: actions/checkout@v6
  504. with:
  505. submodules: recursive
  506. - name: Prepare APT staging dir
  507. if: contains(matrix.os, 'ubuntu')
  508. run: mkdir -p "$RUNNER_TEMP/apt-cache"
  509. - name: APT cache restore
  510. if: contains(matrix.os, 'ubuntu')
  511. id: aptcache
  512. uses: actions/cache/restore@v5
  513. with:
  514. path: ${{ runner.temp }}/apt-cache
  515. key: ${{ matrix.platform }}-apt-${{ matrix.os }}
  516. restore-keys: |
  517. ${{ matrix.platform }}-apt-${{ matrix.os }}
  518. - name: Prepare CI
  519. run: source '${{ github.workspace }}/CI/before_install/${{ matrix.before_install }}'
  520. - name: APT cache save
  521. if: contains(matrix.os, 'ubuntu') && steps.aptcache.outputs.cache-hit != 'true'
  522. uses: actions/cache/save@v5
  523. with:
  524. path: ${{ runner.temp }}/apt-cache
  525. key: ${{ steps.aptcache.outputs.cache-primary-key }}
  526. - name: Setup compiler cache for PRs
  527. uses: hendrikmuhs/[email protected]
  528. if: ${{ github.event.number != '' }}
  529. with:
  530. key: ${{ matrix.platform }}-PR-${{ github.event.number }}
  531. restore-keys: |
  532. ${{ matrix.platform }}-PR-${{ github.event.number }}
  533. ${{ matrix.platform }}-branch-${{ github.base_ref }}
  534. ${{ matrix.platform }}-
  535. max-size: '5G'
  536. verbose: 2
  537. - name: Setup compiler cache for branch builds
  538. uses: hendrikmuhs/[email protected]
  539. if: ${{ github.event.number == '' }}
  540. with:
  541. key: ${{ matrix.platform }}-branch-${{ github.ref_name }}
  542. restore-keys: |
  543. ${{ matrix.platform }}-branch-${{ github.ref_name }}
  544. ${{ matrix.platform }}-
  545. max-size: '5G'
  546. verbose: 2
  547. - name: Prepare Heroes 3 data
  548. run: |
  549. data_url="https://github.com/vcmi-mods/vcmi-test-data/releases/download/v2.0/heroes3.7z"
  550. wget --progress=dot:giga "$data_url" -O heroes3.7z
  551. mkdir -p ~/.local/share/vcmi/
  552. 7za x -o"$HOME/.local/share/vcmi/" heroes3.7z
  553. - name: Configure
  554. run: |
  555. cmake -DENABLE_CCACHE:BOOL=ON -DCMAKE_C_COMPILER=${{ matrix.compiler_cc }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler_cxx }} --preset ${{ matrix.preset }}
  556. - name: Build
  557. run: |
  558. cmake --build --preset ${{matrix.preset}}
  559. - name: Test
  560. run: |
  561. ctest --preset ${{matrix.preset}}
  562. - name: Validate library startup
  563. run: |
  564. cd "${{github.workspace}}/out/build/${{matrix.preset}}/bin"
  565. ./vcmiserver --dummy-run 2> >(tee error.log)
  566. if [ ! -s error.log ]; then
  567. echo "Validation OK!"
  568. exit 0
  569. else
  570. echo "Validation failed!"
  571. exit 1
  572. fi
  573. windows-installer:
  574. needs: build
  575. if: ${{ needs.build.result == 'success' }}
  576. name: Create Windows Installer (${{ matrix.arch }})
  577. strategy:
  578. matrix:
  579. include:
  580. - platform: msvc-x64
  581. arch: x64
  582. os: windows-2025
  583. - platform: msvc-x86
  584. arch: x86
  585. os: windows-2025
  586. - platform: msvc-arm64
  587. arch: arm64
  588. os: windows-11-arm
  589. runs-on: ${{ matrix.os }}
  590. defaults:
  591. run:
  592. shell: bash
  593. steps:
  594. - name: Checkout repository
  595. uses: actions/checkout@v6
  596. with:
  597. submodules: recursive
  598. - name: Extract version info
  599. id: extract-version
  600. run: |
  601. filePath="${GITHUB_WORKSPACE}/cmake_modules/VersionDefinition.cmake"
  602. major=$(grep -m 1 "VCMI_VERSION_MAJOR" "$filePath" | tr -d -c 0-9)
  603. minor=$(grep -m 1 "VCMI_VERSION_MINOR" "$filePath" | tr -d -c 0-9)
  604. patch=$(grep -m 1 "VCMI_VERSION_PATCH" "$filePath" | tr -d -c 0-9)
  605. short_version="${major}.${minor}.${patch}"
  606. version_timestamp=$(date +"%Y%m%d%H%M%S")
  607. echo "short_version=${short_version}" >> "$GITHUB_OUTPUT"
  608. echo "version_timestamp=${version_timestamp}" >> "$GITHUB_OUTPUT"
  609. - name: Download UCRT
  610. run: source '${{github.workspace}}/CI/wininstaller/download_ucrt.sh' '${{matrix.platform}}'
  611. - name: Build Number
  612. run: |
  613. source '${{github.workspace}}/CI/get_package_name.sh'
  614. VCMI_PACKAGE_FILE_NAME+="-${{ matrix.arch }}"
  615. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  616. echo VCMI_PACKAGE_BUILD="$VCMI_PACKAGE_BUILD" >> $GITHUB_ENV
  617. echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
  618. echo VCMI_PACKAGE_GOLDMASTER="$VCMI_PACKAGE_GOLDMASTER" >> $GITHUB_ENV
  619. env:
  620. PULL_REQUEST: ${{ github.event.pull_request.number }}
  621. - name: Download Artifact
  622. uses: actions/download-artifact@v8
  623. with:
  624. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}
  625. path: ${{github.workspace}}/artifact
  626. - name: Extract Artifact
  627. run: |
  628. mkdir artifact/extracted
  629. unzip "artifact/${{ env.VCMI_PACKAGE_FILE_NAME }}.zip" -d artifact/extracted
  630. - name: Ensure Inno Setup is installed
  631. run: |
  632. if [ ! -f "/c/Program Files (x86)/Inno Setup 6/ISCC.exe" ] && [ ! -f "/c/ProgramData/Chocolatey/bin/ISCC.exe" ]; then
  633. choco install innosetup --no-progress -y
  634. fi
  635. - name: Build VCMI Installer
  636. run: >
  637. CI\wininstaller\build_installer.cmd
  638. "${{ steps.extract-version.outputs.short_version }}"
  639. "${{ env.VCMI_PACKAGE_BUILD }}"
  640. "${{ matrix.arch }}"
  641. "VCMI ${{ env.VCMI_PACKAGE_NAME_SUFFIX }}"
  642. "${{ env.VCMI_PACKAGE_FILE_NAME }}"
  643. "${{ github.workspace }}\artifact\extracted"
  644. "${{ github.workspace }}\ucrt"
  645. shell: cmd
  646. - name: Upload VCMI Installer Artifacts
  647. id: upload_installer
  648. uses: actions/upload-artifact@v7
  649. with:
  650. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}-${{ matrix.platform }}-installer
  651. compression-level: 9
  652. path: |
  653. ${{ github.workspace }}/CI/wininstaller/Output/*.exe
  654. - name: Upload Installer
  655. if: ${{ github.event.number == '' && env.DEPLOY_RSA != '' }}
  656. run: |
  657. cd '${{github.workspace}}/CI/wininstaller/Output'
  658. source '${{github.workspace}}/CI/upload_package.sh'
  659. env:
  660. DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
  661. PACKAGE_EXTENSION: exe
  662. - name: Prepare partial JSON with installer informations
  663. shell: bash
  664. run: |
  665. mkdir -p .summary
  666. cat > .summary/installer-${{ matrix.platform }}.json <<JSON
  667. {
  668. "platform": "${{ matrix.platform }}",
  669. "installer_url": "${{ steps.upload_installer.outputs.artifact-url }}"
  670. }
  671. JSON
  672. - name: Upload partial JSON with installer informations
  673. uses: actions/upload-artifact@v7
  674. with:
  675. name: partial-json-${{ matrix.platform }}-installer
  676. path: .summary/installer-${{ matrix.platform }}.json
  677. validate-code:
  678. name: Validate Code
  679. if: always()
  680. runs-on: ubuntu-latest
  681. defaults:
  682. run:
  683. shell: bash
  684. steps:
  685. - uses: actions/checkout@v6
  686. - name: Ensure LF line endings
  687. run: |
  688. find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -o -path ./test/googletest \
  689. -o -path ./osx -prune -o -type f \
  690. -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 | \
  691. { ! xargs -0 grep -l -z -P '\r\n'; }
  692. - name: Validate JSON
  693. run: |
  694. sudo apt install python3-jstyleson
  695. python3 CI/validate_json.py
  696. - name: Validate Markdown
  697. uses: DavidAnson/markdownlint-cli2-action@v22
  698. with:
  699. config: 'CI/example.markdownlint-cli2.jsonc'
  700. globs: '**/*.md'
  701. final-summary:
  702. name: Build report
  703. if: always()
  704. needs: [build, windows-installer, validate-code, test, upload-source-package]
  705. runs-on: ubuntu-latest
  706. permissions:
  707. contents: read
  708. actions: write # Partial JSON artifacts can't be deleted in PRs
  709. steps:
  710. - name: Checkout (for script path)
  711. uses: actions/checkout@v6
  712. - name: Download all partial JSON artifacts
  713. continue-on-error: true
  714. uses: actions/download-artifact@v8
  715. with:
  716. pattern: partial-json-*
  717. merge-multiple: true
  718. path: partials
  719. - name: Run final summary
  720. env:
  721. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  722. run: |
  723. python3 CI/final_summary.py