main.yml 17 KB

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