windows.yml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. # SuperTux
  2. # Copyright (C) 2020-2021 Jacob Burroughs <maths22@gmail.com>
  3. # 2020-2022 A. Semphris <semphris@protonmail.com>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. name: Windows
  18. on:
  19. workflow_dispatch:
  20. push:
  21. branches:
  22. - master
  23. tags:
  24. - '*'
  25. pull_request: {}
  26. jobs:
  27. windows:
  28. strategy:
  29. fail-fast: false
  30. matrix:
  31. arch: [x64, x86]
  32. build_type: [Debug, RelWithDebInfo]
  33. glbinding: [OFF] # [ON, OFF] # FIXME: Fix Windows glbinding builds
  34. include:
  35. - build_type: RelWithDebInfo
  36. arch: x64
  37. glbinding: OFF
  38. release: ON
  39. - build_type: RelWithDebInfo
  40. arch: x86
  41. glbinding: OFF
  42. release: ON
  43. runs-on: windows-latest
  44. steps:
  45. - uses: actions/checkout@v4
  46. with:
  47. # Fetch the whole tree so git describe works
  48. fetch-depth: 0
  49. submodules: recursive
  50. - name: Use cached dependencies
  51. id: cache-dependencies
  52. uses: actions/cache@v4
  53. with:
  54. path: C:/vcpkg/installed
  55. key: ${{ runner.os }}-${{ matrix.arch }}-dependencies-${{ hashFiles('.github/workflows/windows.yml') }}
  56. - name: Install dependencies
  57. if: steps.cache-dependencies.outputs.cache-hit != 'true'
  58. env:
  59. ARCH: ${{ matrix.arch }}
  60. run: |
  61. vcpkg integrate install
  62. vcpkg install gtest:$Env:ARCH-windows
  63. vcpkg install curl:$Env:ARCH-windows
  64. vcpkg install --recurse freetype:$Env:ARCH-windows
  65. vcpkg install glew:$Env:ARCH-windows
  66. vcpkg install glbinding:$Env:ARCH-windows
  67. vcpkg install libogg:$Env:ARCH-windows
  68. vcpkg install libraqm:$Env:ARCH-windows
  69. vcpkg install libvorbis:$Env:ARCH-windows
  70. vcpkg install openal-soft:$Env:ARCH-windows
  71. vcpkg install sdl2:$Env:ARCH-windows
  72. vcpkg install sdl2-image[libjpeg-turbo]:$Env:ARCH-windows
  73. vcpkg install glm:$Env:ARCH-windows
  74. vcpkg install zlib:$Env:ARCH-windows
  75. - name: Configure bulid
  76. env:
  77. ARCH: ${{ matrix.arch }}
  78. BUILD_TYPE: ${{ matrix.build_type }}
  79. GLBINDING: ${{ matrix.glbinding }}
  80. run: |
  81. cmake --version
  82. mkdir build
  83. cd build
  84. cmake .. -G "Visual Studio 17 2022" -A $Env:ARCH.replace("x86", "Win32") "-DGLBINDING_ENABLED=$Env:GLBINDING" -DENABLE_DISCORD=ON -DVCPKG_BUILD=ON -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake -DHAVE_SDL=true -DPACKAGE_VCREDIST=true "-DCMAKE_BUILD_TYPE=$Env:BUILD_TYPE" -DBUILD_TESTS=ON
  85. - name: Build and install
  86. working-directory: build
  87. env:
  88. BUILD_TYPE: ${{ matrix.build_type }}
  89. run: |
  90. cmake --build . --config $Env:BUILD_TYPE
  91. - name: Run Tests
  92. working-directory: build
  93. env:
  94. BUILD_TYPE: ${{ matrix.build_type }}
  95. run: |
  96. "./$Env:BUILD_TYPE/run_tests.exe"
  97. - name: Package MSI Installer
  98. if: matrix.build_type != 'Debug' && matrix.glbinding == 'OFF'
  99. shell: pwsh
  100. working-directory: build
  101. env:
  102. BUILD_TYPE: ${{ matrix.build_type }}
  103. run: |
  104. cpack -C $Env:BUILD_TYPE
  105. if ($LASTEXITCODE -ne 0)
  106. {
  107. $code = $LASTEXITCODE
  108. type ./_CPack_Packages/win64/WIX/wix.log
  109. exit $code
  110. }
  111. else
  112. {
  113. mkdir upload
  114. mv *.msi upload/
  115. }
  116. - name: Upload MSI Installer
  117. uses: actions/upload-artifact@v4
  118. with:
  119. name: "windows-${{ matrix.arch }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-installer"
  120. path: build/upload/*.msi
  121. if-no-files-found: ignore
  122. - name: Package Portable Archive
  123. working-directory: build
  124. env:
  125. BUILD_TYPE: ${{ matrix.build_type }}
  126. run: |
  127. mkdir -Force SuperTux-${{ github.sha }}-portable
  128. cmake --install . --config $Env:BUILD_TYPE --prefix .\SuperTux-${{ github.sha }}-portable
  129. # Because github puts assets in zips, if you upload a zip,
  130. # it will upload another zip. I have disabled this code because
  131. # of that, but in case you wanted to know how to generate a portable release,
  132. # here it is.
  133. <#
  134. cpack -C $Env:BUILD_TYPE -G ZIP
  135. mv *.zip SuperTux-${{ github.sha }}-portable/
  136. #>
  137. - name: Upload Portable Package
  138. if: matrix.build_type != 'Debug' && matrix.glbinding == 'OFF'
  139. uses: actions/upload-artifact@v4
  140. with:
  141. name: "windows-${{ matrix.arch }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-portable"
  142. path: build/SuperTux-${{ github.sha }}-portable
  143. if-no-files-found: ignore
  144. - uses: anshulrgoyal/upload-s3-action@master
  145. if: matrix.release && env.CI_KEY != null
  146. env:
  147. CI_KEY: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  148. with:
  149. aws_bucket: supertux-ci-downloads
  150. aws_key_id: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  151. aws_secret_access_key: ${{ secrets.CI_DOWNLOAD_SECRET_ACCESS_KEY }}
  152. source_dir: 'build/upload'
  153. destination_dir: "${{ github.sha }}/gh-actions/windows-${{ matrix.arch }}/${{ github.run_id }}"
  154. - name: Post uploaded file
  155. shell: bash
  156. if: matrix.release && env.DOWNLOAD_APIKEY != null
  157. working-directory: build
  158. run: ../.ci_scripts/deploy.sh
  159. env:
  160. PREFIX: "${{ github.sha }}/gh-actions/windows-${{ matrix.arch }}/${{ github.run_id }}"
  161. DOWNLOAD_APIKEY: ${{ secrets.DOWNLOAD_APIKEY }}
  162. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  163. IS_WINDOWS: true
  164. - name: Create Release
  165. if: startsWith(github.ref, 'refs/tags/') && matrix.release && github.repository_owner == 'supertux'
  166. uses: softprops/action-gh-release@v1
  167. env:
  168. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  169. with:
  170. files: 'build/upload/SuperTux-*.msi'
  171. draft: true