macos.yml 5.6 KB

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