gnulinux.yml 10 KB

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