github.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. name: VCMI
  2. on:
  3. push:
  4. branches:
  5. - features/*
  6. - develop
  7. pull_request:
  8. env:
  9. # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  10. BUILD_TYPE: Release
  11. jobs:
  12. build:
  13. strategy:
  14. matrix:
  15. include:
  16. - platform: linux
  17. os: ubuntu-20.04
  18. test: 0
  19. preset: linux-clang-release
  20. - platform: linux
  21. os: ubuntu-20.04
  22. test: 0
  23. preset: linux-gcc-release
  24. - platform: mac
  25. os: macos-10.15
  26. test: 0
  27. pack: 1
  28. extension: dmg
  29. preset: macos-ninja-release
  30. - platform: mxe
  31. os: ubuntu-20.04
  32. mxe: i686-w64-mingw32.shared
  33. test: 0
  34. pack: 1
  35. cpack_args: -D CPACK_NSIS_EXECUTABLE=`which makensis`
  36. extension: exe
  37. cmake_args: -G Ninja
  38. - platform: msvc
  39. os: windows-latest
  40. test: 0
  41. pack: 1
  42. extension: exe
  43. preset: windows-msvc-release
  44. runs-on: ${{ matrix.os }}
  45. defaults:
  46. run:
  47. shell: bash
  48. steps:
  49. - uses: actions/checkout@v3
  50. with:
  51. submodules: recursive
  52. - name: Dependencies
  53. run: source '${{github.workspace}}/CI/${{matrix.platform}}/before_install.sh'
  54. env:
  55. MXE_TARGET: ${{ matrix.mxe }}
  56. VCMI_BUILD_PLATFORM: x64
  57. - name: Git branch name
  58. id: git-branch-name
  59. uses: EthanSK/git-branch-name-action@v1
  60. - name: Build Number
  61. run: |
  62. source '${{github.workspace}}/CI/get_package_name.sh'
  63. echo VCMI_PACKAGE_FILE_NAME="$VCMI_PACKAGE_FILE_NAME" >> $GITHUB_ENV
  64. echo VCMI_PACKAGE_NAME_SUFFIX="$VCMI_PACKAGE_NAME_SUFFIX" >> $GITHUB_ENV
  65. env:
  66. PULL_REQUEST: ${{ github.event.pull_request.number }}
  67. - name: Configure CMake
  68. if: "${{ matrix.preset == '' }}"
  69. run: |
  70. mkdir -p '${{github.workspace}}/out/build/${{matrix.preset}}'
  71. cd '${{github.workspace}}/out/build/${{matrix.preset}}'
  72. cmake \
  73. ../.. -GNinja \
  74. ${{matrix.cmake_args}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
  75. -DENABLE_TEST=${{matrix.test}} \
  76. -DPACKAGE_NAME_SUFFIX:STRING="$VCMI_PACKAGE_NAME_SUFFIX" \
  77. -DPACKAGE_FILE_NAME:STRING="$VCMI_PACKAGE_FILE_NAME"
  78. env:
  79. CC: ${{ matrix.cc }}
  80. CXX: ${{ matrix.cxx }}
  81. - name: CMake Preset
  82. if: "${{ matrix.preset != '' }}"
  83. run: |
  84. cmake --preset ${{ matrix.preset }}
  85. - name: Build
  86. if: "${{ matrix.preset == '' }}"
  87. run: |
  88. cmake --build '${{github.workspace}}/out/build/${{matrix.preset}}'
  89. - name: Build Preset
  90. if: "${{ matrix.preset != '' }}"
  91. run: |
  92. cmake --build --preset ${{matrix.preset}}
  93. - name: Test
  94. if: ${{ matrix.test == 1 && matrix.preset != ''}}
  95. run: |
  96. ctest --preset ${{matrix.preset}}
  97. - name: Pack
  98. id: cpack
  99. if: ${{ matrix.pack == 1 }}
  100. run: |
  101. cd '${{github.workspace}}/out/build/${{matrix.preset}}'
  102. CPACK_PATH=`which -a cpack | grep -m1 -v -i chocolatey`
  103. "$CPACK_PATH" -C ${{env.BUILD_TYPE}} ${{ matrix.cpack_args }}
  104. rm -rf _CPack_Packages
  105. - name: Additional logs
  106. if: ${{ failure() && steps.cpack.outcome == 'failure' && matrix.platform == 'mxe' }}
  107. run: |
  108. cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/project.nsi'
  109. cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/NSISOutput.log'
  110. - name: Artifacts
  111. if: ${{ matrix.pack == 1 }}
  112. uses: actions/upload-artifact@v3
  113. with:
  114. name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
  115. path: |
  116. ${{github.workspace}}/**/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
  117. - name: Upload build
  118. if: ${{ matrix.pack == 1 && (github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/features/')) && matrix.platform != 'msvc' }}
  119. run: |
  120. cd '${{github.workspace}}/out/build/${{matrix.preset}}'
  121. source '${{github.workspace}}/CI/upload_package.sh'
  122. env:
  123. DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
  124. PACKAGE_EXTENSION: ${{ matrix.extension }}
  125. - uses: act10ns/slack@v1
  126. with:
  127. status: ${{ job.status }}
  128. channel: '#notifications'
  129. env:
  130. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  131. if: always()
  132. - name: Trigger Android
  133. uses: peter-evans/repository-dispatch@v1
  134. if: ${{ github.ref == 'refs/heads/develop' && matrix.platform == 'mxe' }}
  135. with:
  136. token: ${{ secrets.VCMI_ANDROID_ACCESS_TOKEN }}
  137. repository: vcmi/vcmi-android
  138. event-type: vcmi