main.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. # SuperTux
  2. # Copyright (C) 2020-2021 Jacob Burroughs <maths22@gmail.com>
  3. # 2020-2021 A. Semphris <semphris@protonmail.com>
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 3
  8. # of the License, or (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, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. name: main
  19. on:
  20. push:
  21. branches:
  22. - master
  23. tags:
  24. - '*'
  25. pull_request: {}
  26. # TODO the glbinding build
  27. jobs:
  28. build-unix:
  29. strategy:
  30. fail-fast: false
  31. matrix:
  32. arch: [32, 64]
  33. os: [ubuntu-latest, macos-10.15, macos-11]
  34. compiler: [gcc, clang]
  35. build_type: [Debug, Release]
  36. exclude:
  37. - os: macos-10.15
  38. compiler: gcc
  39. - os: macos-10.15
  40. arch: 32
  41. - os: macos-11
  42. compiler: gcc
  43. - os: macos-11
  44. arch: 32
  45. include:
  46. - os: ubuntu-latest
  47. build_type: Release
  48. compiler: gcc
  49. arch: 32
  50. release: 'ON'
  51. - os: ubuntu-latest
  52. build_type: Release
  53. compiler: gcc
  54. arch: 64
  55. release: 'ON'
  56. - os: macos-10.15
  57. build_type: Release
  58. release: 'ON'
  59. - os: macos-11
  60. build_type: Release
  61. release: 'ON'
  62. runs-on: ${{ matrix.os }}
  63. steps:
  64. - uses: actions/checkout@v2
  65. with:
  66. # Fetch the whole tree so git describe works
  67. fetch-depth: 0
  68. submodules: true
  69. - name: Install 64-bit linux dependencies
  70. if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 64 }}
  71. run: |
  72. sudo apt-get update
  73. sudo apt-get install -y \
  74. cmake \
  75. build-essential \
  76. automake \
  77. gtk-doc-tools \
  78. rpm \
  79. sshpass \
  80. clang-6.0 \
  81. g++-8 \
  82. gcc-multilib \
  83. g++-multilib \
  84. libgtest-dev \
  85. libc++-dev \
  86. libogg-dev \
  87. libvorbis-dev \
  88. libopenal-dev \
  89. libboost-all-dev \
  90. libsdl2-dev \
  91. libsdl2-image-dev \
  92. libfreetype6-dev \
  93. libharfbuzz-dev \
  94. libfribidi-dev \
  95. libglib2.0-dev \
  96. libraqm-dev \
  97. libglew-dev \
  98. libcurl4-openssl-dev \
  99. libglm-dev \
  100. zlib1g-dev
  101. - name: Install 32-bit linux dependencies
  102. if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 32 }}
  103. run: |
  104. sudo dpkg --add-architecture i386
  105. sudo apt-get update
  106. # Github is adding a lot of unnecessary deb.sury.org
  107. # packages into ubuntu-latest, this causes
  108. # libharfbuzz-dev:i386 to fail due to issues related to
  109. # libpcre2-8-0 from deb.sury.org. Remove all that and
  110. # downgrade to official versions.
  111. sudo apt-get remove --yes php.* libzip4:amd64
  112. sudo apt-get install --yes --allow-downgrades \
  113. libpcre2-16-0:amd64=10.34-7 \
  114. libpcre2-32-0:amd64=10.34-7 \
  115. libpcre2-8-0:amd64=10.34-7 \
  116. libpcre2-dev:amd64=10.34-7 \
  117. libpcre2-posix2:amd64=10.34-7
  118. sudo apt-get install -y \
  119. cmake \
  120. build-essential \
  121. automake \
  122. gtk-doc-tools \
  123. rpm \
  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. libboost-date-time-dev:i386 \
  132. libboost-filesystem-dev:i386 \
  133. libboost-locale-dev:i386 \
  134. libsdl2-dev:i386 \
  135. libsdl2-image-dev:i386 \
  136. libfreetype6-dev:i386 \
  137. libcurl4-openssl-dev:i386 \
  138. libharfbuzz-dev:i386 \
  139. libfribidi-dev:i386 \
  140. libglm-dev \
  141. zlib1g-dev
  142. # Nethier GLEW nor glbinding exist in 32-bit for Ubuntu 20.04, so snatch the debs from 16.04 instead
  143. 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
  144. 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
  145. - name: Install macos dependencies
  146. if: ${{ matrix.os == 'macos-10.15' || matrix.os == 'macos-11' }}
  147. run: |
  148. brew install boost cmake googletest bash libogg libvorbis glew openal-soft sdl2 sdl2_image sdl2_ttf \
  149. freetype harfbuzz fribidi glib gtk-doc glbinding libraqm glm zlib
  150. # Something funky happens with freetype if mono is left
  151. sudo mv /Library/Frameworks/Mono.framework /Library/Frameworks/Mono.framework-disabled
  152. - name: Set compiler (gcc)
  153. if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc' }}
  154. run: |
  155. echo "CXX=g++" >> $GITHUB_ENV
  156. echo "CC=gcc" >> $GITHUB_ENV
  157. - name: Set compiler (clang)
  158. if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang' }}
  159. run: |
  160. echo "CXX=clang++" >> $GITHUB_ENV
  161. echo "CC=clang" >> $GITHUB_ENV
  162. - name: Set compiler (macos)
  163. if: ${{ matrix.os == 'macos-10.15' || matrix.os == 'macos-11' }}
  164. run: |
  165. # This ensures for now we use clang11
  166. # Clang12 runs into a bunch of fun with `include location '/usr/local/include' is unsafe for cross-compilation`
  167. # that we don't care about for now
  168. echo "CXX=clang++" >> $GITHUB_ENV
  169. echo "CC=clang" >> $GITHUB_ENV
  170. - name: Configure build
  171. env:
  172. BUILD_TYPE: ${{ matrix.build_type }}
  173. ARCH: ${{ matrix.arch == 32 && '-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32' || '' }}
  174. run: |
  175. cmake --version
  176. $CXX --version
  177. mkdir "build"
  178. cd "build"
  179. # TODO add -DGLBINDING_ENABLED=$USE_GLBINDING
  180. cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${ARCH} -DENABLE_DISCORD=ON -DWARNINGS=ON -DWERROR=ON -DBUILD_TESTS=ON -DCMAKE_INSTALL_MESSAGE=NEVER -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_SUBDIR_BIN=bin -DINSTALL_SUBDIR_SHARE=share/supertux2
  181. - name: Build and install
  182. working-directory: build
  183. run: |
  184. make -j3 VERBOSE=1
  185. make install DESTDIR="/tmp/supertux" VERBOSE=1
  186. - name: Run tests
  187. working-directory: build
  188. run: ./test_supertux2
  189. - name: Package
  190. if: ${{ matrix.os != 'ubuntu-latest' || matrix.arch != '32' }}
  191. env:
  192. OS_NAME: ${{ matrix.os }}
  193. ARCH: ${{ matrix.arch }}
  194. COMPILER_NAME: ${{ matrix.compiler }}
  195. BUILD_NAME: ${{ matrix.build_type }}
  196. PACKAGE: 'ON'
  197. working-directory: build
  198. run: ../.ci_scripts/package.sh
  199. - name: Package (Linux 32-bit)
  200. if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == '32' }}
  201. env:
  202. OS_NAME: ${{ matrix.os }}
  203. ARCH: ${{ matrix.arch }}
  204. COMPILER_NAME: ${{ matrix.compiler }}
  205. BUILD_NAME: ${{ matrix.build_type }}
  206. PACKAGE: 'ON'
  207. working-directory: build
  208. run: |
  209. cpack -G TGZ
  210. mkdir -p upload/
  211. mv SuperTux* upload/
  212. # Github actions is dumb and won't let you download single files from artifacts, so break up the artifacts instead
  213. - uses: actions/upload-artifact@v2
  214. with:
  215. name: "${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}-appimage"
  216. path: build/upload/*.AppImage
  217. if-no-files-found: ignore
  218. - uses: actions/upload-artifact@v2
  219. with:
  220. name: "source"
  221. path: build/upload/*Source.tar.gz
  222. if-no-files-found: ignore
  223. - uses: actions/upload-artifact@v2
  224. with:
  225. name: "${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}-tgz"
  226. path: build/upload/*Linux.tar.gz
  227. if-no-files-found: ignore
  228. - uses: actions/upload-artifact@v2
  229. with:
  230. name: "${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}-dmg"
  231. path: build/upload/*.dmg
  232. if-no-files-found: ignore
  233. - uses: anshulrgoyal/upload-s3-action@master
  234. # These all have repository_owner conditions because the secret isn't available to other owners
  235. if: matrix.release == 'ON' && env.CI_KEY != null
  236. env:
  237. CI_KEY: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  238. with:
  239. aws_bucket: supertux-ci-downloads
  240. aws_key_id: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  241. aws_secret_access_key: ${{ secrets.CI_DOWNLOAD_SECRET_ACCESS_KEY }}
  242. source_dir: 'build/upload'
  243. destination_dir: "${{ github.sha }}/gh-actions/${{ matrix.os }}-${{ matrix.arch }}/${{ github.run_id }}"
  244. - name: Post uploaded file
  245. if: matrix.release == 'ON' && env.DOWNLOAD_APIKEY != null
  246. working-directory: build
  247. run: ../.ci_scripts/deploy.sh
  248. env:
  249. PREFIX: "${{ github.sha }}/gh-actions/${{ matrix.os }}-${{ matrix.arch }}/${{ github.run_id }}"
  250. DOWNLOAD_APIKEY: ${{ secrets.DOWNLOAD_APIKEY }}
  251. - name: Create Release
  252. if: startsWith(github.ref, 'refs/tags/') && matrix.release == 'ON' && github.repository_owner == 'supertux'
  253. uses: softprops/action-gh-release@v1
  254. env:
  255. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  256. with:
  257. files: 'build/upload/SuperTux-*'
  258. draft: true
  259. build-windows:
  260. strategy:
  261. fail-fast: false
  262. matrix:
  263. arch: [x64, x86]
  264. build_type: [Debug, Release]
  265. include:
  266. - build_type: Release
  267. release: 'ON'
  268. runs-on: windows-latest
  269. steps:
  270. - uses: actions/checkout@v2
  271. with:
  272. # Fetch the whole tree so git describe works
  273. fetch-depth: 0
  274. submodules: true
  275. - name: Install dependencies
  276. env:
  277. ARCH: ${{ matrix.arch }}
  278. run: |
  279. vcpkg integrate install
  280. vcpkg install gtest:$Env:ARCH-windows
  281. vcpkg install boost-date-time:$Env:ARCH-windows
  282. vcpkg install boost-filesystem:$Env:ARCH-windows
  283. vcpkg install boost-format:$Env:ARCH-windows
  284. vcpkg install boost-iostreams:$Env:ARCH-windows
  285. vcpkg install boost-locale:$Env:ARCH-windows
  286. vcpkg install boost-optional:$Env:ARCH-windows
  287. vcpkg install boost-system:$Env:ARCH-windows
  288. vcpkg install curl:$Env:ARCH-windows
  289. vcpkg install --recurse freetype:$Env:ARCH-windows
  290. vcpkg install glew:$Env:ARCH-windows
  291. vcpkg install libogg:$Env:ARCH-windows
  292. vcpkg install libraqm:$Env:ARCH-windows
  293. vcpkg install libvorbis:$Env:ARCH-windows
  294. vcpkg install openal-soft:$Env:ARCH-windows
  295. vcpkg install sdl2:$Env:ARCH-windows
  296. vcpkg install sdl2-image[libjpeg-turbo]:$Env:ARCH-windows
  297. vcpkg install glm:$Env:ARCH-windows
  298. vcpkg install zlib:$Env:ARCH-windows
  299. - name: Configure bulid
  300. env:
  301. BUILD_TYPE: ${{ matrix.build_type }}
  302. ARCH: ${{ matrix.arch }}
  303. run: |
  304. cmake --version
  305. mkdir build
  306. cd build
  307. cmake .. -G "Visual Studio 16 2019" -A $Env:ARCH.replace("x86", "Win32") -DENABLE_DISCORD=ON -DVCPKG_BUILD=ON -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake -DHAVE_SDL=true -DPACKAGE_VCREDIST=true -DCMAKE_BUILD_TYPE=$Env:BUILD_TYPE -DBUILD_TESTS=ON
  308. - name: Build and install
  309. working-directory: build
  310. env:
  311. BUILD_TYPE: ${{ matrix.build_type }}
  312. run: |
  313. cmake --build . --config $Env:BUILD_TYPE
  314. - name: Package
  315. working-directory: build
  316. env:
  317. BUILD_TYPE: ${{ matrix.build_type }}
  318. run: |
  319. cpack -C $Env:BUILD_TYPE
  320. mkdir upload
  321. mv *.msi upload/
  322. - uses: actions/upload-artifact@v2
  323. with:
  324. name: "windows-${{ matrix.arch }}-${{ matrix.build_type }}-installer"
  325. path: build/upload/*.msi
  326. if-no-files-found: ignore
  327. - uses: anshulrgoyal/upload-s3-action@master
  328. # These all have repository_owner conditions because the secret isn't available to other owners
  329. if: matrix.release == 'ON' && env.CI_KEY != null
  330. env:
  331. CI_KEY: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  332. with:
  333. aws_bucket: supertux-ci-downloads
  334. aws_key_id: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  335. aws_secret_access_key: ${{ secrets.CI_DOWNLOAD_SECRET_ACCESS_KEY }}
  336. source_dir: 'build/upload'
  337. destination_dir: "${{ github.sha }}/gh-actions/windows-${{ matrix.arch }}/${{ github.run_id }}"
  338. - name: Post uploaded file
  339. shell: bash
  340. if: matrix.release == 'ON' && env.DOWNLOAD_APIKEY != null
  341. working-directory: build
  342. run: ../.ci_scripts/deploy.sh
  343. env:
  344. PREFIX: "${{ github.sha }}/gh-actions/windows-${{ matrix.arch }}/${{ github.run_id }}"
  345. DOWNLOAD_APIKEY: ${{ secrets.DOWNLOAD_APIKEY }}
  346. IS_WINDOWS: true
  347. - name: Create Release
  348. if: startsWith(github.ref, 'refs/tags/') && matrix.release == 'ON' && github.repository_owner == 'supertux'
  349. uses: softprops/action-gh-release@v1
  350. env:
  351. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  352. with:
  353. files: 'build/upload/SuperTux-*'
  354. draft: true