macos.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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: MacOS
  18. on:
  19. workflow_dispatch:
  20. push:
  21. branches:
  22. - master
  23. tags:
  24. - '*'
  25. pull_request: {}
  26. jobs:
  27. macos:
  28. strategy:
  29. fail-fast: false
  30. matrix:
  31. os: [macos-12]
  32. build_type: [Debug, Release]
  33. glbinding: [ON, OFF]
  34. include:
  35. - os: macos-12
  36. build_type: Release
  37. glbinding: OFF
  38. release: ON
  39. runs-on: ${{ matrix.os }}
  40. steps:
  41. - uses: actions/checkout@v4
  42. with:
  43. # Fetch the whole tree so git describe works
  44. fetch-depth: 0
  45. submodules: recursive
  46. - name: Install macos dependencies
  47. if: ${{ matrix.os == 'macos-12' }}
  48. run: |
  49. # Use GLM 1.0.0 as later versions don't build with clang
  50. HOMEBREW_NO_AUTO_UPDATE=1 brew install --formula ./mk/brew/glm.rb --build-from-source
  51. brew install cmake googletest bash rename libogg libvorbis glew \
  52. openal-soft sdl2 sdl2_image sdl2_ttf freetype harfbuzz \
  53. fribidi glib gtk-doc glbinding@2 libraqm zlib
  54. brew link glbinding@2
  55. install_name_tool -change \
  56. '@rpath/libsharpyuv.0.dylib' \
  57. /usr/local/opt/webp/lib/libsharpyuv.0.dylib \
  58. /usr/local/opt/webp/lib/libwebp.7.dylib
  59. install_name_tool -change \
  60. '@rpath/libjxl_cms.0.10.dylib' \
  61. /usr/local/opt/jpeg-xl/lib/libjxl_cms.0.10.dylib \
  62. /usr/local/opt/jpeg-xl/lib/libjxl.dylib
  63. # Something funky happens with freetype if mono is left
  64. sudo mv /Library/Frameworks/Mono.framework \
  65. /Library/Frameworks/Mono.framework-disabled
  66. - name: Set compiler
  67. run: |
  68. # This ensures for now we use clang11
  69. # Clang12 runs into a bunch of fun with `include location
  70. # '/usr/local/include' is unsafe for cross-compilation` that we don't
  71. # care about for now
  72. echo "CXX=clang++" >> $GITHUB_ENV
  73. echo "CC=clang" >> $GITHUB_ENV
  74. - name: Configure build
  75. env:
  76. BUILD_TYPE: ${{ matrix.build_type }}
  77. GLBINDING: ${{ matrix.glbinding }}
  78. run: |
  79. cmake --version
  80. $CXX --version
  81. mkdir "build"
  82. cd "build"
  83. # TODO add -DGLBINDING_ENABLED=$USE_GLBINDING
  84. cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE $ARCH -DBUILD_TESTS=ON \
  85. -DWARNINGS=ON -DWERROR=ON -DGLBINDING_ENABLED=$GLBINDING \
  86. -DENABLE_DISCORD=ON -DCMAKE_INSTALL_MESSAGE=NEVER \
  87. -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_SUBDIR_BIN=bin \
  88. -DINSTALL_SUBDIR_SHARE=share/supertux2
  89. - name: Build and install
  90. working-directory: build
  91. run: |
  92. make -j3 VERBOSE=1
  93. make install DESTDIR="/tmp/supertux" VERBOSE=1
  94. - name: Run tests
  95. working-directory: build
  96. run: ./test_supertux2
  97. - name: Package
  98. env:
  99. OS_NAME: ${{ matrix.os }}
  100. ARCH: 64
  101. COMPILER_NAME: ${{ matrix.compiler }}
  102. BUILD_NAME: ${{ matrix.build_type }}
  103. PACKAGE: 'ON'
  104. working-directory: build
  105. run: ../.ci_scripts/package.sh
  106. - uses: actions/upload-artifact@v4
  107. with:
  108. name: "${{ matrix.os }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-dmg"
  109. path: build/upload/*.dmg
  110. if-no-files-found: ignore
  111. - uses: anshulrgoyal/upload-s3-action@master
  112. if: matrix.release && env.CI_KEY != null
  113. env:
  114. CI_KEY: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  115. with:
  116. aws_bucket: supertux-ci-downloads
  117. aws_key_id: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  118. aws_secret_access_key: ${{ secrets.CI_DOWNLOAD_SECRET_ACCESS_KEY }}
  119. source_dir: 'build/upload'
  120. destination_dir: "${{ github.sha }}/gh-actions/${{ matrix.os }}-${{ matrix.arch }}/${{ github.run_id }}"
  121. - name: Post uploaded file
  122. if: matrix.release && env.DOWNLOAD_APIKEY != null
  123. working-directory: build
  124. run: ../.ci_scripts/deploy.sh
  125. env:
  126. PREFIX: "${{ github.sha }}/gh-actions/${{ matrix.os }}-${{ matrix.arch }}/${{ github.run_id }}"
  127. DOWNLOAD_APIKEY: ${{ secrets.DOWNLOAD_APIKEY }}
  128. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  129. - name: Prepare Release
  130. if: startsWith(github.ref, 'refs/tags/') && matrix.release && github.repository_owner == 'supertux'
  131. env:
  132. OS: ${{ matrix.os }}
  133. run: |
  134. if [ "$OS" = "macos-12" ]; then
  135. rename 's/.dmg/-12.dmg/' build/upload/SuperTux-*
  136. fi
  137. - name: Create Release
  138. if: startsWith(github.ref, 'refs/tags/') && matrix.release && github.repository_owner == 'supertux'
  139. uses: softprops/action-gh-release@v1
  140. env:
  141. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  142. with:
  143. files: 'build/upload/SuperTux-*'
  144. draft: true