macos.yml 5.6 KB

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