gnulinux.yml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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: GNU/Linux
  18. on:
  19. push:
  20. branches:
  21. - master
  22. tags:
  23. - '*'
  24. pull_request: {}
  25. jobs:
  26. gnulinux:
  27. strategy:
  28. fail-fast: false
  29. matrix:
  30. arch: [32, 64]
  31. os: [ubuntu-20.04]
  32. compiler: [gcc, clang]
  33. build_type: [Debug, Release]
  34. glbinding: [ON, OFF]
  35. exclude:
  36. - arch: 32
  37. glbinding: ON
  38. include:
  39. - os: ubuntu-20.04
  40. build_type: Release
  41. compiler: gcc
  42. arch: 64
  43. glbinding: OFF
  44. release: ON
  45. source: ON
  46. documentation: ON
  47. - os: ubuntu-20.04
  48. build_type: Debug
  49. compiler: gcc
  50. arch: 64
  51. glbinding: OFF
  52. coverage: ON
  53. # TODO: Working Linux 32-bit packaging
  54. runs-on: ${{ matrix.os }}
  55. steps:
  56. - uses: actions/checkout@v2
  57. with:
  58. # Fetch the whole tree so git describe works
  59. fetch-depth: 0
  60. submodules: true
  61. - name: Install 64-bit dependencies
  62. if: ${{ matrix.arch == 64 }}
  63. run: |
  64. sudo apt-get update
  65. sudo apt-get install -y \
  66. cmake \
  67. build-essential \
  68. automake \
  69. gtk-doc-tools \
  70. rpm \
  71. rename \
  72. sshpass \
  73. clang-6.0 \
  74. g++-8 \
  75. gcc-multilib \
  76. g++-multilib \
  77. libgtest-dev \
  78. libc++-dev \
  79. libogg-dev \
  80. libvorbis-dev \
  81. libopenal-dev \
  82. libsdl2-dev \
  83. libsdl2-image-dev \
  84. libfreetype6-dev \
  85. libharfbuzz-dev \
  86. libfribidi-dev \
  87. libglib2.0-dev \
  88. libraqm-dev \
  89. libglew-dev \
  90. libglbinding-dev \
  91. libcurl4-openssl-dev \
  92. libglm-dev \
  93. zlib1g-dev \
  94. lcov \
  95. doxygen
  96. - name: Install 32-bit dependencies
  97. if: ${{ matrix.arch == 32 }}
  98. env:
  99. DOWNGRADE_PCRE: ${{ matrix.os == 'ubuntu-20.04' && '1' || '' }}
  100. run: |
  101. sudo dpkg --add-architecture i386
  102. sudo apt-get update
  103. if [ "$DOWNGRADE_PCRE" ]; then
  104. # Github is adding a lot of unnecessary deb.sury.org
  105. # packages into ubuntu-20.04, this causes
  106. # libharfbuzz-dev:i386 to fail due to issues related to
  107. # libpcre2-8-0 from deb.sury.org. Remove all that and
  108. # downgrade to official versions.
  109. sudo apt-get remove --yes php.* libzip4:amd64
  110. sudo apt-get install --yes --allow-downgrades \
  111. libpcre2-16-0:amd64=10.34-7 \
  112. libpcre2-32-0:amd64=10.34-7 \
  113. libpcre2-8-0:amd64=10.34-7 \
  114. libpcre2-dev:amd64=10.34-7 \
  115. libpcre2-posix2:amd64=10.34-7
  116. fi
  117. sudo apt-get install -y \
  118. cmake \
  119. build-essential \
  120. automake \
  121. gtk-doc-tools \
  122. rpm \
  123. rename \
  124. sshpass \
  125. gcc-multilib \
  126. g++-multilib \
  127. libgtest-dev:i386 \
  128. libogg-dev:i386 \
  129. libvorbis-dev:i386 \
  130. libopenal-dev:i386 \
  131. libsdl2-dev:i386 \
  132. libsdl2-image-dev:i386 \
  133. libfreetype6-dev:i386 \
  134. libcurl4-openssl-dev:i386 \
  135. libharfbuzz-dev:i386 \
  136. libfribidi-dev:i386 \
  137. libglm-dev \
  138. zlib1g-dev
  139. # Nethier GLEW nor glbinding exist in 32-bit for Ubuntu 20.04, so snatch the debs from 16.04 instead
  140. wget archive.ubuntu.com/ubuntu/pool/main/g/glew/libglew1.13_1.13.0-2_i386.deb && sudo dpkg -i libglew1.13_1.13.0-2_i386.deb
  141. wget archive.ubuntu.com/ubuntu/pool/main/g/glew/libglew-dev_1.13.0-2_i386.deb && sudo dpkg -i libglew-dev_1.13.0-2_i386.deb
  142. - name: Set compiler (gcc)
  143. if: ${{ matrix.compiler == 'gcc' }}
  144. run: |
  145. echo "CXX=g++" >> $GITHUB_ENV
  146. echo "CC=gcc" >> $GITHUB_ENV
  147. - name: Set compiler (clang)
  148. if: ${{ matrix.compiler == 'clang' }}
  149. run: |
  150. echo "CXX=clang++" >> $GITHUB_ENV
  151. echo "CC=clang" >> $GITHUB_ENV
  152. - name: Configure build
  153. env:
  154. BUILD_TYPE: ${{ matrix.build_type }}
  155. ARCH: ${{ matrix.arch == 32 && '-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32' || '' }}
  156. MAKE_DOCS: ${{ matrix.documentation }}
  157. GLBINDING: ${{ matrix.glbinding }}
  158. # FIXME: GoogleTest isn't detected by CMake on Ubuntu 18.04
  159. # (also check the step that invokes the tests with ./test_supertux2)
  160. TESTS: ${{ matrix.os == 'ubuntu-20.04' }}
  161. run: |
  162. cmake --version
  163. $CXX --version
  164. mkdir "build"
  165. cd "build"
  166. cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE $ARCH -DBUILD_TESTS=$TESTS \
  167. -DWARNINGS=ON -DWERROR=ON -DGLBINDING_ENABLED=$GLBINDING \
  168. -DCMAKE_INSTALL_MESSAGE=NEVER -DCMAKE_INSTALL_PREFIX=/usr \
  169. -DBUILD_DOCUMENTATION=$MAKE_DOCS -DINSTALL_SUBDIR_BIN=bin \
  170. -DINSTALL_SUBDIR_SHARE=share/supertux2 -DENABLE_DISCORD=ON
  171. - name: Build and install
  172. working-directory: build
  173. run: |
  174. make -j3 VERBOSE=1
  175. make install DESTDIR="/tmp/supertux" VERBOSE=1
  176. - name: Run tests
  177. # FIXME: GoogleTest isn't detected by CMake on Ubuntu 18.04
  178. # (also check the step that invokes CMake with -DBUILD_TESTS)
  179. if: ${{ matrix.os == 'ubuntu-20.04' }}
  180. working-directory: build
  181. run: ./test_supertux2
  182. - name: Make coverage
  183. if: ${{ matrix.coverage }}
  184. working-directory: build
  185. run: |
  186. lcov --capture --directory . --exclude '/usr/*' --exclude '*/tests/*'\
  187. --exclude '*/external/*' --output-file coverage.info
  188. mkdir coverage
  189. cd coverage
  190. genhtml ../coverage.info
  191. - name: Make documentation
  192. if: ${{ matrix.documentation }}
  193. working-directory: build
  194. run: |
  195. doxygen docs/Doxyfile
  196. - name: Package
  197. if: ${{ matrix.arch != '32' }}
  198. env:
  199. OS_NAME: ${{ matrix.os }}
  200. ARCH: ${{ matrix.arch }} # TODO: Working Linux 32-bit packaging
  201. COMPILER_NAME: ${{ matrix.compiler }}
  202. BUILD_NAME: ${{ matrix.build_type }}
  203. PACKAGE: 'ON'
  204. SOURCE: ${{ matrix.source }}
  205. working-directory: build
  206. run: ../.ci_scripts/package.sh
  207. - name: Upload AppImage
  208. uses: actions/upload-artifact@v2
  209. with:
  210. name: "${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-appimage"
  211. path: build/upload/*.AppImage
  212. if-no-files-found: ignore
  213. - name: Upload source
  214. uses: actions/upload-artifact@v2
  215. with:
  216. name: "source"
  217. path: build/upload/*Source.tar.gz
  218. if-no-files-found: ignore
  219. - name: Upload coverage
  220. uses: actions/upload-artifact@v2
  221. with:
  222. name: "coverage"
  223. path: build/coverage/*
  224. if-no-files-found: ignore
  225. - name: Upload documentation
  226. uses: actions/upload-artifact@v2
  227. with:
  228. name: "documentation"
  229. path: build/docs/doxygen/html/*
  230. if-no-files-found: ignore
  231. - name: Upload tar archives
  232. uses: actions/upload-artifact@v2
  233. with:
  234. name: "${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}${{ matrix.glbinding == 'ON' && '-glbinding' || '' }}-tgz"
  235. path: build/upload/*Linux.tar.gz
  236. if-no-files-found: ignore
  237. - name: Upload to nightlies
  238. uses: anshulrgoyal/upload-s3-action@master
  239. if: matrix.release && env.CI_KEY != null
  240. env:
  241. CI_KEY: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  242. with:
  243. aws_bucket: supertux-ci-downloads
  244. aws_key_id: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  245. aws_secret_access_key: ${{ secrets.CI_DOWNLOAD_SECRET_ACCESS_KEY }}
  246. source_dir: 'build/upload'
  247. destination_dir: "${{ github.sha }}/gh-actions/${{ matrix.os }}-${{ matrix.arch }}/${{ github.run_id }}"
  248. - name: Post uploaded file
  249. if: matrix.release && env.DOWNLOAD_APIKEY != null
  250. working-directory: build
  251. run: ../.ci_scripts/deploy.sh
  252. env:
  253. PREFIX: "${{ github.sha }}/gh-actions/${{ matrix.os }}-${{ matrix.arch }}/${{ github.run_id }}"
  254. DOWNLOAD_APIKEY: ${{ secrets.DOWNLOAD_APIKEY }}
  255. - name: Prepare Release
  256. if: startsWith(github.ref, 'refs/tags/') && matrix.release && github.repository_owner == 'supertux'
  257. env:
  258. OS: ${{ matrix.os }}
  259. ARCH: ${{ matrix.arch }}
  260. run: |
  261. if [ "$ARCH" = "32" ]; then
  262. rename 's/.tar.gz/-32.tar.gz/' build/upload/SuperTux-*
  263. fi
  264. - name: Create Release
  265. if: startsWith(github.ref, 'refs/tags/') && matrix.release && github.repository_owner == 'supertux'
  266. uses: softprops/action-gh-release@v1
  267. env:
  268. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  269. with:
  270. files: 'build/upload/SuperTux-*'
  271. draft: true