windows.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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@v3
  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. shell: pwsh
  99. working-directory: build
  100. env:
  101. BUILD_TYPE: ${{ matrix.build_type }}
  102. run: |
  103. cpack -C $Env:BUILD_TYPE
  104. if ($LASTEXITCODE -ne 0)
  105. {
  106. $code = $LASTEXITCODE
  107. type ./_CPack_Packages/win64/WIX/wix.log
  108. exit $code
  109. }
  110. else
  111. {
  112. mkdir upload
  113. mv *.msi upload/
  114. }
  115. - name: Upload MSI Installer
  116. uses: actions/upload-artifact@v4
  117. with:
  118. name: "windows-${{ matrix.arch }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-installer"
  119. path: build/upload/*.msi
  120. if-no-files-found: ignore
  121. - name: Package Portable Archive
  122. working-directory: build
  123. env:
  124. BUILD_TYPE: ${{ matrix.build_type }}
  125. run: |
  126. mkdir -Force SuperTux-${{ github.sha }}-portable
  127. cmake --install . --config $Env:BUILD_TYPE --prefix .\SuperTux-${{ github.sha }}-portable
  128. # Because github puts assets in zips, if you upload a zip,
  129. # it will upload another zip. I have disabled this code because
  130. # of that, but in case you wanted to know how to generate a portable release,
  131. # here it is.
  132. <#
  133. cpack -C $Env:BUILD_TYPE -G ZIP
  134. mv *.zip SuperTux-${{ github.sha }}-portable/
  135. #>
  136. - name: Upload Portable Package
  137. uses: actions/upload-artifact@v4
  138. with:
  139. name: "windows-${{ matrix.arch }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-portable"
  140. path: build/SuperTux-${{ github.sha }}-portable
  141. if-no-files-found: ignore
  142. - uses: anshulrgoyal/upload-s3-action@master
  143. if: matrix.release && env.CI_KEY != null
  144. env:
  145. CI_KEY: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  146. with:
  147. aws_bucket: supertux-ci-downloads
  148. aws_key_id: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  149. aws_secret_access_key: ${{ secrets.CI_DOWNLOAD_SECRET_ACCESS_KEY }}
  150. source_dir: 'build/upload'
  151. destination_dir: "${{ github.sha }}/gh-actions/windows-${{ matrix.arch }}/${{ github.run_id }}"
  152. - name: Post uploaded file
  153. shell: bash
  154. if: matrix.release && env.DOWNLOAD_APIKEY != null
  155. working-directory: build
  156. run: ../.ci_scripts/deploy.sh
  157. env:
  158. PREFIX: "${{ github.sha }}/gh-actions/windows-${{ matrix.arch }}/${{ github.run_id }}"
  159. DOWNLOAD_APIKEY: ${{ secrets.DOWNLOAD_APIKEY }}
  160. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  161. IS_WINDOWS: true
  162. - name: Create Release
  163. if: startsWith(github.ref, 'refs/tags/') && matrix.release && github.repository_owner == 'supertux'
  164. uses: softprops/action-gh-release@v1
  165. env:
  166. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  167. with:
  168. files: 'build/upload/SuperTux-*.msi'
  169. draft: true