github.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. name: VCMI
  2. on:
  3. push:
  4. branches:
  5. - features/*
  6. - beta
  7. - master
  8. - develop
  9. pull_request:
  10. workflow_dispatch:
  11. env:
  12. # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  13. BUILD_TYPE: Release
  14. jobs:
  15. build:
  16. strategy:
  17. matrix:
  18. include:
  19. - platform: linux-qt6
  20. os: ubuntu-22.04
  21. test: 0
  22. preset: linux-clang-test
  23. - platform: linux
  24. os: ubuntu-22.04
  25. test: 1
  26. preset: linux-gcc-test
  27. - platform: linux
  28. os: ubuntu-20.04
  29. test: 0
  30. preset: linux-gcc-debug
  31. - platform: mac-intel
  32. os: macos-12
  33. test: 0
  34. pack: 1
  35. pack_type: Release
  36. extension: dmg
  37. preset: macos-conan-ninja-release
  38. conan_profile: macos-intel
  39. conan_options: --options with_apple_system_libs=True
  40. artifact_platform: intel
  41. - platform: mac-arm
  42. os: macos-12
  43. test: 0
  44. pack: 1
  45. pack_type: Release
  46. extension: dmg
  47. preset: macos-arm-conan-ninja-release
  48. conan_profile: macos-arm
  49. conan_options: --options with_apple_system_libs=True
  50. artifact_platform: arm
  51. - platform: ios
  52. os: macos-12
  53. test: 0
  54. pack: 1
  55. pack_type: Release
  56. extension: ipa
  57. preset: ios-release-conan-ccache
  58. conan_profile: ios-arm64
  59. conan_options: --options with_apple_system_libs=True
  60. - platform: msvc
  61. os: windows-latest
  62. test: 0
  63. pack: 1
  64. pack_type: RelWithDebInfo
  65. extension: exe
  66. preset: windows-msvc-release-ccache
  67. - platform: mingw
  68. os: ubuntu-22.04
  69. test: 0
  70. pack: 1
  71. pack_type: Release
  72. extension: exe
  73. cpack_args: -D CPACK_NSIS_EXECUTABLE=`which makensis`
  74. cmake_args: -G Ninja
  75. preset: windows-mingw-conan-linux
  76. conan_profile: mingw64-linux.jinja
  77. - platform: mingw-32
  78. os: ubuntu-22.04
  79. test: 0
  80. pack: 1
  81. pack_type: Release
  82. extension: exe
  83. cpack_args: -D CPACK_NSIS_EXECUTABLE=`which makensis`
  84. cmake_args: -G Ninja
  85. preset: windows-mingw-conan-linux
  86. conan_profile: mingw32-linux.jinja
  87. - platform: android-32
  88. os: ubuntu-22.04
  89. extension: apk
  90. preset: android-conan-ninja-release
  91. conan_profile: android-32
  92. conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
  93. artifact_platform: armeabi-v7a
  94. - platform: android-64
  95. os: ubuntu-22.04
  96. extension: apk
  97. preset: android-conan-ninja-release
  98. conan_profile: android-64
  99. conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
  100. artifact_platform: arm64-v8a
  101. runs-on: ${{ matrix.os }}
  102. defaults:
  103. run:
  104. shell: bash
  105. steps:
  106. - uses: actions/checkout@v4
  107. with:
  108. submodules: recursive
  109. - name: Ensure LF line endings
  110. if: ${{ startsWith(matrix.preset, 'linux-clang-test') }}
  111. run: |
  112. find . -path ./.git -prune -o -path ./AI/FuzzyLite -prune -o -path ./test/googletest \
  113. -o -path ./osx -prune -o -type f \
  114. -not -name '*.png' -and -not -name '*.vcxproj*' -and -not -name '*.props' -and -not -name '*.wav' -and -not -name '*.webm' -and -not -name '*.ico' -and -not -name '*.bat' -print0 | \
  115. { ! xargs -0 grep -l -z -P '\r\n'; }
  116. - name: Validate JSON
  117. # the Python yaml module doesn't seem to work on mac-arm
  118. # also, running it on multiple presets is redundant and slightly increases already long CI built times
  119. if: ${{ startsWith(matrix.preset, 'linux-clang-test') }}
  120. run: |
  121. pip3 install jstyleson
  122. python3 CI/linux-qt6/validate_json.py
  123. - name: Dependencies
  124. run: source '${{github.workspace}}/CI/${{matrix.platform}}/before_install.sh'
  125. env:
  126. VCMI_BUILD_PLATFORM: x64
  127. # ensure the ccache for each PR is separate so they don't interfere with each other
  128. # fall back to ccache of the vcmi/vcmi repo if no PR-specific ccache is found
  129. - name: ccache for PRs
  130. uses: hendrikmuhs/[email protected]
  131. if: ${{ github.event.number != '' }}
  132. with:
  133. key: ${{ matrix.preset }}-PR-${{ github.event.number }}
  134. restore-keys: |
  135. ${{ matrix.preset }}-PR-${{ github.event.number }}
  136. ${{ matrix.preset }}-no-PR
  137. # actual cache takes up less space, at most ~1 GB
  138. max-size: "5G"
  139. verbose: 2
  140. - name: ccache for everything but PRs
  141. uses: hendrikmuhs/[email protected]
  142. if: ${{ (github.repository == 'vcmi/vcmi' && github.event.number == '' && github.ref == 'refs/heads/develop') || github.repository != 'vcmi/vcmi' }}
  143. with:
  144. key: ${{ matrix.preset }}-no-PR
  145. restore-keys: |
  146. ${{ matrix.preset }}-no-PR
  147. # actual cache takes up less space, at most ~1 GB
  148. max-size: "5G"
  149. verbose: 2
  150. - name: Prepare Heroes 3 data
  151. env:
  152. HEROES_3_DATA_PASSWORD: ${{ secrets.HEROES_3_DATA_PASSWORD }}
  153. if: ${{ env.HEROES_3_DATA_PASSWORD != '' && matrix.test == 1 }}
  154. run: |
  155. wget --progress=dot:giga https://github.com/vcmi-mods/vcmi-test-data/releases/download/v1.0/h3_assets.zip
  156. 7za x h3_assets.zip -p$HEROES_3_DATA_PASSWORD
  157. mkdir -p ~/.local/share/vcmi/
  158. mv h3_assets/* ~/.local/share/vcmi/
  159. - uses: actions/setup-python@v5
  160. if: "${{ matrix.conan_profile != '' }}"
  161. with:
  162. python-version: '3.10'
  163. - name: Conan setup
  164. if: "${{ matrix.conan_profile != '' }}"
  165. run: |
  166. pip3 install 'conan<2.0'
  167. conan profile new default --detect
  168. conan install . \
  169. --install-folder=conan-generated \
  170. --no-imports \
  171. --build=never \
  172. --profile:build=default \
  173. --profile:host=CI/conan/${{ matrix.conan_profile }} \
  174. ${{ matrix.conan_options }}
  175. env:
  176. GENERATE_ONLY_BUILT_CONFIG: 1
  177. - name: Build Number
  178. run: |
  179. source '${{github.workspace}}/CI/get_package_name.sh'
  180. if [ '${{ matrix.artifact_platform }}' ]; then
  181. VCMI_PACKAGE_FILE_NAME+="-${{ matrix.artifact_platform }}"
  182. fi
  183. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  184. echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
  185. echo VCMI_PACKAGE_GITVERSION="$VCMI_PACKAGE_GITVERSION" >> $GITHUB_ENV
  186. env:
  187. PULL_REQUEST: ${{ github.event.pull_request.number }}
  188. - name: Configure
  189. run: |
  190. if [[ ${{matrix.preset}} == linux-gcc-test ]]; then GCC13=1; fi
  191. cmake -DENABLE_CCACHE:BOOL=ON --preset ${{ matrix.preset }} ${GCC13:+-DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13}
  192. - name: Build
  193. run: |
  194. cmake --build --preset ${{matrix.preset}}
  195. - name: Test
  196. env:
  197. HEROES_3_DATA_PASSWORD: ${{ secrets.HEROES_3_DATA_PASSWORD }}
  198. if: ${{ env.HEROES_3_DATA_PASSWORD != '' && matrix.test == 1 }}
  199. run: |
  200. ctest --preset ${{matrix.preset}}
  201. - name: Kill XProtect to work around CPack issue on macOS
  202. if: ${{ startsWith(matrix.platform, 'mac') }}
  203. run: |
  204. # Cf. https://github.com/actions/runner-images/issues/7522#issuecomment-1556766641
  205. echo Killing...; sudo pkill -9 XProtect >/dev/null || true;
  206. echo "Waiting..."; counter=0; while pgrep XProtect && ((counter < 20)); do sleep 3; ((counter++)); done
  207. pgrep XProtect || true
  208. - name: Pack
  209. id: cpack
  210. if: ${{ matrix.pack == 1 }}
  211. run: |
  212. cd '${{github.workspace}}/out/build/${{matrix.preset}}'
  213. CPACK_PATH=`which -a cpack | grep -m1 -v -i chocolatey`
  214. counter=0; until "$CPACK_PATH" -C ${{matrix.pack_type}} ${{ matrix.cpack_args }} || ((counter > 20)); do sleep 3; ((counter++)); done
  215. test -f '${{github.workspace}}/CI/${{matrix.platform}}/post_pack.sh' \
  216. && '${{github.workspace}}/CI/${{matrix.platform}}/post_pack.sh' '${{github.workspace}}' "$(ls '${{ env.VCMI_PACKAGE_FILE_NAME }}'.*)"
  217. rm -rf _CPack_Packages
  218. - name: Create Android package
  219. if: ${{ startsWith(matrix.platform, 'android') }}
  220. run: |
  221. cd android
  222. ./gradlew assembleDaily --info
  223. echo ANDROID_APK_PATH="$(ls ${{ github.workspace }}/android/vcmi-app/build/outputs/apk/daily/*.${{ matrix.extension }})" >> $GITHUB_ENV
  224. - name: Additional logs
  225. if: ${{ failure() && steps.cpack.outcome == 'failure' && matrix.platform == 'msvc' }}
  226. run: |
  227. cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/project.nsi'
  228. cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/NSISOutput.log'
  229. - name: Artifacts
  230. if: ${{ matrix.pack == 1 }}
  231. uses: actions/upload-artifact@v4
  232. with:
  233. name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
  234. path: |
  235. ${{github.workspace}}/out/build/${{matrix.preset}}/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
  236. - name: Android artifacts
  237. if: ${{ startsWith(matrix.platform, 'android') }}
  238. uses: actions/upload-artifact@v4
  239. with:
  240. name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
  241. path: |
  242. ${{ env.ANDROID_APK_PATH }}
  243. - name: Symbols
  244. if: ${{ matrix.platform == 'msvc' }}
  245. uses: actions/upload-artifact@v4
  246. with:
  247. name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }} - symbols
  248. path: |
  249. ${{github.workspace}}/**/*.pdb
  250. - name: Android JNI ${{matrix.platform}}
  251. if: ${{ startsWith(matrix.platform, 'android') && github.ref == 'refs/heads/master' }}
  252. uses: actions/upload-artifact@v4
  253. with:
  254. name: Android JNI ${{matrix.platform}}
  255. path: |
  256. ${{ github.workspace }}/android/vcmi-app/src/main/jniLibs
  257. - name: Upload build
  258. 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' }}
  259. continue-on-error: true
  260. run: |
  261. if cd '${{github.workspace}}/android/vcmi-app/build/outputs/apk/daily' ; then
  262. mv '${{ env.ANDROID_APK_PATH }}' "$VCMI_PACKAGE_FILE_NAME.${{ matrix.extension }}"
  263. else
  264. cd '${{github.workspace}}/out/build/${{matrix.preset}}'
  265. fi
  266. source '${{github.workspace}}/CI/upload_package.sh'
  267. env:
  268. DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
  269. PACKAGE_EXTENSION: ${{ matrix.extension }}
  270. # copy-pasted mostly
  271. bundle_release:
  272. needs: build
  273. if: always() && github.ref == 'refs/heads/master'
  274. strategy:
  275. matrix:
  276. include:
  277. - platform: android-32
  278. os: ubuntu-22.04
  279. extension: aab
  280. preset: android-conan-ninja-release
  281. conan_profile: android-32
  282. conan_options: --conf tools.android:ndk_path=$ANDROID_NDK_ROOT
  283. artifact_platform: aab
  284. runs-on: ${{ matrix.os }}
  285. defaults:
  286. run:
  287. shell: bash
  288. steps:
  289. - uses: actions/checkout@v4
  290. with:
  291. submodules: recursive
  292. - name: Dependencies
  293. run: source '${{github.workspace}}/CI/${{matrix.platform}}/before_install.sh'
  294. env:
  295. VCMI_BUILD_PLATFORM: x64
  296. - uses: actions/setup-python@v5
  297. if: "${{ matrix.conan_profile != '' }}"
  298. with:
  299. python-version: '3.10'
  300. - name: Conan setup
  301. if: "${{ matrix.conan_profile != '' }}"
  302. run: |
  303. pip3 install 'conan<2.0'
  304. conan profile new default --detect
  305. conan install . \
  306. --install-folder=conan-generated \
  307. --no-imports \
  308. --build=never \
  309. --profile:build=default \
  310. --profile:host=CI/conan/${{ matrix.conan_profile }} \
  311. ${{ matrix.conan_options }}
  312. env:
  313. GENERATE_ONLY_BUILT_CONFIG: 1
  314. - name: Build Number
  315. run: |
  316. source '${{github.workspace}}/CI/get_package_name.sh'
  317. if [ '${{ matrix.artifact_platform }}' ]; then
  318. VCMI_PACKAGE_FILE_NAME+="-${{ matrix.artifact_platform }}"
  319. fi
  320. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  321. echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
  322. echo VCMI_PACKAGE_GITVERSION="$VCMI_PACKAGE_GITVERSION" >> $GITHUB_ENV
  323. env:
  324. PULL_REQUEST: ${{ github.event.pull_request.number }}
  325. - name: CMake Preset
  326. run: |
  327. cmake --preset ${{ matrix.preset }}
  328. - name: Build Preset
  329. run: |
  330. cmake --build --preset ${{matrix.preset}}
  331. - name: Download libs x64
  332. uses: actions/download-artifact@v4
  333. with:
  334. name: Android JNI android-64
  335. path: ${{ github.workspace }}/android/vcmi-app/src/main/jniLibs/
  336. - name: Create Android package
  337. run: |
  338. cd android
  339. ./gradlew bundleRelease --info
  340. echo ANDROID_APK_PATH="$(ls ${{ github.workspace }}/android/vcmi-app/build/outputs/bundle/release/*.aab)" >> $GITHUB_ENV
  341. env:
  342. ANDROID_STORE_PASSWORD: ${{ secrets.ANDROID_STORE_PASSWORD }}
  343. ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
  344. - name: Android artifacts
  345. uses: actions/upload-artifact@v4
  346. with:
  347. name: ${{ env.VCMI_PACKAGE_FILE_NAME }}
  348. path: |
  349. ${{ env.ANDROID_APK_PATH }}