main.yml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. - os: ubuntu-latest
  63. build_type: Debug
  64. compiler: gcc
  65. arch: 64
  66. coverage: 'ON'
  67. runs-on: ${{ matrix.os }}
  68. steps:
  69. - uses: actions/checkout@v2
  70. with:
  71. # Fetch the whole tree so git describe works
  72. fetch-depth: 0
  73. submodules: true
  74. - name: Install 64-bit linux dependencies
  75. if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 64 }}
  76. run: |
  77. sudo apt-get update
  78. sudo apt-get install -y \
  79. cmake \
  80. build-essential \
  81. automake \
  82. gtk-doc-tools \
  83. rpm \
  84. rename \
  85. sshpass \
  86. clang-6.0 \
  87. g++-8 \
  88. gcc-multilib \
  89. g++-multilib \
  90. libgtest-dev \
  91. libc++-dev \
  92. libogg-dev \
  93. libvorbis-dev \
  94. libopenal-dev \
  95. libboost-all-dev \
  96. libsdl2-dev \
  97. libsdl2-image-dev \
  98. libfreetype6-dev \
  99. libharfbuzz-dev \
  100. libfribidi-dev \
  101. libglib2.0-dev \
  102. libraqm-dev \
  103. libglew-dev \
  104. libcurl4-openssl-dev \
  105. libglm-dev \
  106. zlib1g-dev \
  107. lcov
  108. - name: Install 32-bit linux dependencies
  109. if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == 32 }}
  110. run: |
  111. sudo dpkg --add-architecture i386
  112. sudo apt-get update
  113. # Github is adding a lot of unnecessary deb.sury.org
  114. # packages into ubuntu-latest, this causes
  115. # libharfbuzz-dev:i386 to fail due to issues related to
  116. # libpcre2-8-0 from deb.sury.org. Remove all that and
  117. # downgrade to official versions.
  118. sudo apt-get remove --yes php.* libzip4:amd64
  119. sudo apt-get install --yes --allow-downgrades \
  120. libpcre2-16-0:amd64=10.34-7 \
  121. libpcre2-32-0:amd64=10.34-7 \
  122. libpcre2-8-0:amd64=10.34-7 \
  123. libpcre2-dev:amd64=10.34-7 \
  124. libpcre2-posix2:amd64=10.34-7
  125. sudo apt-get install -y \
  126. cmake \
  127. build-essential \
  128. automake \
  129. gtk-doc-tools \
  130. rpm \
  131. rename \
  132. sshpass \
  133. gcc-multilib \
  134. g++-multilib \
  135. libgtest-dev:i386 \
  136. libogg-dev:i386 \
  137. libvorbis-dev:i386 \
  138. libopenal-dev:i386 \
  139. libboost-date-time-dev:i386 \
  140. libboost-filesystem-dev:i386 \
  141. libboost-locale-dev:i386 \
  142. libsdl2-dev:i386 \
  143. libsdl2-image-dev:i386 \
  144. libfreetype6-dev:i386 \
  145. libcurl4-openssl-dev:i386 \
  146. libharfbuzz-dev:i386 \
  147. libfribidi-dev:i386 \
  148. libglm-dev \
  149. zlib1g-dev
  150. # Nethier GLEW nor glbinding exist in 32-bit for Ubuntu 20.04, so snatch the debs from 16.04 instead
  151. 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
  152. 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
  153. - name: Install macos dependencies
  154. if: ${{ matrix.os == 'macos-10.15' || matrix.os == 'macos-11' }}
  155. run: |
  156. brew install boost cmake googletest bash rename libogg libvorbis glew openal-soft sdl2 sdl2_image sdl2_ttf \
  157. freetype harfbuzz fribidi glib gtk-doc glbinding libraqm glm zlib
  158. # Something funky happens with freetype if mono is left
  159. sudo mv /Library/Frameworks/Mono.framework /Library/Frameworks/Mono.framework-disabled
  160. - name: Set compiler (gcc)
  161. if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc' }}
  162. run: |
  163. echo "CXX=g++" >> $GITHUB_ENV
  164. echo "CC=gcc" >> $GITHUB_ENV
  165. - name: Set compiler (clang)
  166. if: ${{ matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang' }}
  167. run: |
  168. echo "CXX=clang++" >> $GITHUB_ENV
  169. echo "CC=clang" >> $GITHUB_ENV
  170. - name: Set compiler (macos)
  171. if: ${{ matrix.os == 'macos-10.15' || matrix.os == 'macos-11' }}
  172. run: |
  173. # This ensures for now we use clang11
  174. # Clang12 runs into a bunch of fun with `include location '/usr/local/include' is unsafe for cross-compilation`
  175. # that we don't care about for now
  176. echo "CXX=clang++" >> $GITHUB_ENV
  177. echo "CC=clang" >> $GITHUB_ENV
  178. - name: Configure build
  179. env:
  180. BUILD_TYPE: ${{ matrix.build_type }}
  181. ARCH: ${{ matrix.arch == 32 && '-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32' || '' }}
  182. run: |
  183. cmake --version
  184. $CXX --version
  185. mkdir "build"
  186. cd "build"
  187. # TODO add -DGLBINDING_ENABLED=$USE_GLBINDING
  188. 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
  189. - name: Build and install
  190. working-directory: build
  191. run: |
  192. make -j3 VERBOSE=1
  193. make install DESTDIR="/tmp/supertux" VERBOSE=1
  194. - name: Run tests
  195. working-directory: build
  196. run: ./test_supertux2
  197. - name: Make coverage
  198. if: ${{ matrix.coverage }}
  199. working-directory: build
  200. run: |
  201. lcov --capture --directory . --exclude '/usr/*' --exclude '*/tests/*' --exclude '*/external/*' --output-file coverage.info
  202. mkdir coverage
  203. cd coverage
  204. genhtml ../coverage.info
  205. - name: Package
  206. if: ${{ matrix.os != 'ubuntu-latest' || matrix.arch != '32' }}
  207. env:
  208. OS_NAME: ${{ matrix.os }}
  209. ARCH: ${{ matrix.arch }}
  210. COMPILER_NAME: ${{ matrix.compiler }}
  211. BUILD_NAME: ${{ matrix.build_type }}
  212. PACKAGE: 'ON'
  213. working-directory: build
  214. run: ../.ci_scripts/package.sh
  215. - name: Package (Linux 32-bit)
  216. if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch == '32' }}
  217. env:
  218. OS_NAME: ${{ matrix.os }}
  219. ARCH: ${{ matrix.arch }}
  220. COMPILER_NAME: ${{ matrix.compiler }}
  221. BUILD_NAME: ${{ matrix.build_type }}
  222. PACKAGE: 'ON'
  223. working-directory: build
  224. run: |
  225. cpack -G TGZ
  226. mkdir -p upload/
  227. mv SuperTux* upload/
  228. # Github actions is dumb and won't let you download single files from artifacts, so break up the artifacts instead
  229. - uses: actions/upload-artifact@v2
  230. with:
  231. name: "${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}-appimage"
  232. path: build/upload/*.AppImage
  233. if-no-files-found: ignore
  234. - uses: actions/upload-artifact@v2
  235. with:
  236. name: "source"
  237. path: build/upload/*Source.tar.gz
  238. if-no-files-found: ignore
  239. - uses: actions/upload-artifact@v2
  240. with:
  241. name: "${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}-tgz"
  242. path: build/upload/*Linux.tar.gz
  243. if-no-files-found: ignore
  244. - uses: actions/upload-artifact@v2
  245. with:
  246. name: "${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}-dmg"
  247. path: build/upload/*.dmg
  248. if-no-files-found: ignore
  249. - uses: actions/upload-artifact@v2
  250. with:
  251. name: "coverage"
  252. path: build/coverage/*
  253. - uses: anshulrgoyal/upload-s3-action@master
  254. # These all have repository_owner conditions because the secret isn't available to other owners
  255. if: matrix.release == 'ON' && env.CI_KEY != null
  256. env:
  257. CI_KEY: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  258. with:
  259. aws_bucket: supertux-ci-downloads
  260. aws_key_id: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  261. aws_secret_access_key: ${{ secrets.CI_DOWNLOAD_SECRET_ACCESS_KEY }}
  262. source_dir: 'build/upload'
  263. destination_dir: "${{ github.sha }}/gh-actions/${{ matrix.os }}-${{ matrix.arch }}/${{ github.run_id }}"
  264. - name: Post uploaded file
  265. if: matrix.release == 'ON' && env.DOWNLOAD_APIKEY != null
  266. working-directory: build
  267. run: ../.ci_scripts/deploy.sh
  268. env:
  269. PREFIX: "${{ github.sha }}/gh-actions/${{ matrix.os }}-${{ matrix.arch }}/${{ github.run_id }}"
  270. DOWNLOAD_APIKEY: ${{ secrets.DOWNLOAD_APIKEY }}
  271. - name: Prepare Release
  272. if: startsWith(github.ref, 'refs/tags/') && matrix.release == 'ON' && github.repository_owner == 'supertux'
  273. env:
  274. OS: ${{ matrix.os }}
  275. ARCH: ${{ matrix.arch }}
  276. run: |
  277. if [ "$ARCH" = "32" ]; then
  278. rename 's/.tar.gz/-32.tar.gz/' build/upload/SuperTux-*
  279. fi
  280. if [ "$OS" = "macos-10.15" ]; then
  281. rename 's/.dmg/-10.15.dmg/' build/upload/SuperTux-*
  282. fi
  283. if [ "$OS" = "macos-11" ]; then
  284. rename 's/.dmg/-11.dmg/' build/upload/SuperTux-*
  285. fi
  286. - name: Create Release
  287. if: startsWith(github.ref, 'refs/tags/') && matrix.release == 'ON' && github.repository_owner == 'supertux'
  288. uses: softprops/action-gh-release@v1
  289. env:
  290. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  291. with:
  292. files: 'build/upload/SuperTux-*'
  293. draft: true
  294. build-windows:
  295. strategy:
  296. fail-fast: false
  297. matrix:
  298. arch: [x64, x86]
  299. build_type: [Debug, Release]
  300. include:
  301. - build_type: Release
  302. release: 'ON'
  303. runs-on: windows-latest
  304. steps:
  305. - uses: actions/checkout@v2
  306. with:
  307. # Fetch the whole tree so git describe works
  308. fetch-depth: 0
  309. submodules: true
  310. - name: Install dependencies
  311. env:
  312. ARCH: ${{ matrix.arch }}
  313. run: |
  314. vcpkg integrate install
  315. vcpkg install gtest:$Env:ARCH-windows
  316. vcpkg install boost-date-time:$Env:ARCH-windows
  317. vcpkg install boost-filesystem:$Env:ARCH-windows
  318. vcpkg install boost-format:$Env:ARCH-windows
  319. vcpkg install boost-iostreams:$Env:ARCH-windows
  320. vcpkg install boost-locale:$Env:ARCH-windows
  321. vcpkg install boost-optional:$Env:ARCH-windows
  322. vcpkg install boost-system:$Env:ARCH-windows
  323. vcpkg install curl:$Env:ARCH-windows
  324. vcpkg install --recurse freetype:$Env:ARCH-windows
  325. vcpkg install glew:$Env:ARCH-windows
  326. vcpkg install libogg:$Env:ARCH-windows
  327. vcpkg install libraqm:$Env:ARCH-windows
  328. vcpkg install libvorbis:$Env:ARCH-windows
  329. vcpkg install openal-soft:$Env:ARCH-windows
  330. vcpkg install sdl2:$Env:ARCH-windows
  331. vcpkg install sdl2-image[libjpeg-turbo]:$Env:ARCH-windows
  332. vcpkg install glm:$Env:ARCH-windows
  333. vcpkg install zlib:$Env:ARCH-windows
  334. - name: Configure bulid
  335. env:
  336. BUILD_TYPE: ${{ matrix.build_type }}
  337. ARCH: ${{ matrix.arch }}
  338. run: |
  339. cmake --version
  340. mkdir build
  341. cd build
  342. 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
  343. - name: Build and install
  344. working-directory: build
  345. env:
  346. BUILD_TYPE: ${{ matrix.build_type }}
  347. run: |
  348. cmake --build . --config $Env:BUILD_TYPE
  349. - name: Package
  350. working-directory: build
  351. env:
  352. BUILD_TYPE: ${{ matrix.build_type }}
  353. run: |
  354. cpack -C $Env:BUILD_TYPE
  355. mkdir upload
  356. mv *.msi upload/
  357. - uses: actions/upload-artifact@v2
  358. with:
  359. name: "windows-${{ matrix.arch }}-${{ matrix.build_type }}-installer"
  360. path: build/upload/*.msi
  361. if-no-files-found: ignore
  362. - uses: anshulrgoyal/upload-s3-action@master
  363. # These all have repository_owner conditions because the secret isn't available to other owners
  364. if: matrix.release == 'ON' && env.CI_KEY != null
  365. env:
  366. CI_KEY: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  367. with:
  368. aws_bucket: supertux-ci-downloads
  369. aws_key_id: ${{ secrets.CI_DOWNLOAD_ACCESS_KEY_ID }}
  370. aws_secret_access_key: ${{ secrets.CI_DOWNLOAD_SECRET_ACCESS_KEY }}
  371. source_dir: 'build/upload'
  372. destination_dir: "${{ github.sha }}/gh-actions/windows-${{ matrix.arch }}/${{ github.run_id }}"
  373. - name: Post uploaded file
  374. shell: bash
  375. if: matrix.release == 'ON' && env.DOWNLOAD_APIKEY != null
  376. working-directory: build
  377. run: ../.ci_scripts/deploy.sh
  378. env:
  379. PREFIX: "${{ github.sha }}/gh-actions/windows-${{ matrix.arch }}/${{ github.run_id }}"
  380. DOWNLOAD_APIKEY: ${{ secrets.DOWNLOAD_APIKEY }}
  381. IS_WINDOWS: true
  382. - name: Create Release
  383. if: startsWith(github.ref, 'refs/tags/') && matrix.release == 'ON' && github.repository_owner == 'supertux'
  384. uses: softprops/action-gh-release@v1
  385. env:
  386. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  387. with:
  388. files: 'build/upload/SuperTux-*'
  389. draft: true