cmake.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. name: CMake
  2. on:
  3. release:
  4. types: [ published ]
  5. workflow_dispatch:
  6. jobs:
  7. formatting:
  8. name: Formatting check
  9. runs-on: ubuntu-latest
  10. steps:
  11. - uses: actions/checkout@v7
  12. - name: Run clang-format style check for C/C++ programs.
  13. uses: jidicula/clang-format-action@v4.18.0
  14. with:
  15. check-path: "src"
  16. exclude-regex: "(src/External)"
  17. - run: echo "Formatted with clang-format version ${{ steps.clang-format.outputs.clang-format-version }}"
  18. tests:
  19. #needs: formatting
  20. env:
  21. BUILD_TYPE: Release
  22. strategy:
  23. matrix:
  24. os: [ubuntu-24.04]
  25. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  26. # You can convert this to a matrix build if you need cross-platform coverage.
  27. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  28. runs-on: ${{ matrix.os }}
  29. steps:
  30. - uses: actions/checkout@v7
  31. with:
  32. submodules: true
  33. # cache some build information
  34. - name: ccache
  35. uses: hendrikmuhs/ccache-action@v1.2.24
  36. with:
  37. key: ${{ github.job }}-${{ matrix.os }}
  38. - name: Install dependencies
  39. run: sudo apt-get update && sudo apt-get -y install libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libfftw3-dev libfreetype-dev libdbus-1-dev libnode-dev
  40. - name: Configure CMake
  41. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  42. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  43. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=1 -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  44. - name: Build
  45. # Build your program with the given configuration
  46. run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target tests --verbose
  47. - name: Run tests
  48. # Run the unit tests available
  49. run: ${{github.workspace}}/build/output/tests
  50. build:
  51. needs: tests
  52. permissions:
  53. actions: read
  54. contents: read
  55. security-events: write
  56. strategy:
  57. matrix:
  58. include:
  59. - build_type: Release
  60. variant: kde
  61. disable_kde: 'OFF'
  62. - build_type: Release
  63. variant: generic
  64. disable_kde: 'ON'
  65. - build_type: Debug
  66. variant: kde
  67. disable_kde: 'OFF'
  68. runs-on: ubuntu-24.04
  69. steps:
  70. - uses: actions/checkout@v7
  71. with:
  72. submodules: true
  73. - name: ccache
  74. uses: hendrikmuhs/ccache-action@v1.2.24
  75. with:
  76. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}-${{ matrix.variant }}
  77. - name: Initialize CodeQL
  78. # Initializes the CodeQL tools for scanning.
  79. uses: github/codeql-action/init@v4
  80. if: ${{ matrix.build_type == 'Debug' }}
  81. with:
  82. languages: 'cpp'
  83. - name: Install dependencies
  84. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev libdbus-1-dev libnode-dev wayland-scanner++ wayland-protocols libwayland-dev
  85. - name: Configure CMake
  86. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DDISABLE_KDE_FEATURES=${{matrix.disable_kde}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache
  87. - name: Build
  88. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --parallel $(nproc) --verbose
  89. - name: Perform CodeQL Analysis
  90. if: ${{ matrix.build_type == 'Debug' }}
  91. uses: github/codeql-action/analyze@v4
  92. - name: Package
  93. if: ${{ matrix.build_type == 'Release' }}
  94. run: tools/package_release.sh build linux-wallpaperengine-${{ matrix.variant }}-ubuntu-24.04-x86_64 "$RUNNER_TEMP"
  95. - uses: actions/upload-artifact@v7
  96. if: ${{ matrix.build_type == 'Release' }}
  97. with:
  98. name: linux-wallpaperengine-${{ matrix.variant }}
  99. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-ubuntu-24.04-x86_64.tar.gz
  100. if-no-files-found: error
  101. distro-build:
  102. needs: tests
  103. strategy:
  104. fail-fast: false
  105. matrix:
  106. distro: [fedora-44, arch]
  107. variant: [kde, generic]
  108. include:
  109. - distro: arch
  110. image: archlinux:latest
  111. # libnode itself comes from the AUR below, these are its dependencies plus CEF's
  112. install: >-
  113. pacman -Syu --noconfirm --needed git base-devel curl cmake glew freeglut sdl2-compat lz4 zlib ffmpeg glm
  114. glfw mpv libpulse freetype2 harfbuzz dbus wayland wayland-protocols mesa libxrandr libxinerama
  115. libxcursor libxi libxxf86vm fftw gmp nss at-spi2-core libcups libxcomposite libxdamage libxkbcommon
  116. pango cairo alsa-lib libdrm libxshmfence ada brotli c-ares icu libffi libnghttp2 libnghttp3 libngtcp2
  117. libuv openssl simdjson zstd ninja procps-ng python
  118. - distro: fedora-44
  119. image: fedora:44
  120. install: >-
  121. dnf -y install git gcc gcc-c++ make cmake pkgconf-pkg-config binutils tar gzip
  122. libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel libXxf86vm-devel
  123. mesa-libGL-devel mesa-libEGL-devel glew-devel freeglut-devel sdl2-compat-devel lz4-devel
  124. zlib-ng-compat-devel ffmpeg-free-devel glm-devel glfw-devel mpv-devel pulseaudio-libs-devel
  125. freetype-devel harfbuzz-devel dbus-devel wayland-devel wayland-protocols-devel fftw-devel gmp-devel
  126. nodejs24-devel
  127. runs-on: ubuntu-24.04
  128. container: ${{ matrix.image }}
  129. steps:
  130. # git has to be there before checkout, otherwise it falls back to a tarball without submodules
  131. - name: Install dependencies
  132. run: ${{ matrix.install }}
  133. # Arch has V8's shared library only in the AUR (libnode, Node.js built with --shared): build it once per
  134. # package version and cache the package. LTO is off, makepkg's own -flto without node's --enable-lto handling
  135. # loses V8's assembly stack scanner at link time
  136. - name: Fetch libnode PKGBUILD
  137. if: matrix.distro == 'arch'
  138. id: libnode
  139. run: |
  140. mkdir -p /tmp/libnode
  141. curl -fsSL "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=libnode" -o /tmp/libnode/PKGBUILD
  142. sed -i -e '/--enable-lto/d' -e "/^makedepends=/i options=('!lto')" /tmp/libnode/PKGBUILD
  143. echo "version=$(. /tmp/libnode/PKGBUILD && echo $pkgver-$pkgrel)" >> "$GITHUB_OUTPUT"
  144. - name: Cache libnode package
  145. if: matrix.distro == 'arch'
  146. id: libnode-cache
  147. uses: actions/cache@v4
  148. with:
  149. path: /tmp/libnode-pkg
  150. key: libnode-${{ steps.libnode.outputs.version }}-nolto
  151. - name: Build libnode
  152. if: matrix.distro == 'arch' && steps.libnode-cache.outputs.cache-hit != 'true'
  153. run: |
  154. useradd -m builder
  155. chown -R builder /tmp/libnode
  156. su builder -c 'cd /tmp/libnode && makepkg --noconfirm --nodeps'
  157. mkdir -p /tmp/libnode-pkg
  158. cp /tmp/libnode/libnode-[0-9]*.pkg.tar.zst /tmp/libnode-pkg/
  159. - name: Install libnode
  160. if: matrix.distro == 'arch'
  161. run: pacman -U --noconfirm /tmp/libnode-pkg/libnode-[0-9]*.pkg.tar.zst
  162. # the smoke test installs it into a fresh Arch container
  163. - uses: actions/upload-artifact@v7
  164. if: matrix.distro == 'arch' && matrix.variant == 'kde'
  165. with:
  166. name: libnode-arch
  167. path: /tmp/libnode-pkg/libnode-[0-9]*.pkg.tar.zst
  168. if-no-files-found: error
  169. - uses: actions/checkout@v7
  170. with:
  171. submodules: true
  172. - name: Configure CMake
  173. run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DDISABLE_KDE_FEATURES=${{ matrix.variant == 'generic' && 'ON' || 'OFF' }}
  174. - name: Build
  175. run: cmake --build build --parallel $(nproc)
  176. - name: Package
  177. run: tools/package_release.sh build linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64 "$RUNNER_TEMP"
  178. - uses: actions/upload-artifact@v7
  179. with:
  180. name: linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}
  181. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-${{ matrix.distro }}-x86_64.tar.gz
  182. if-no-files-found: error
  183. # one tarball for every distribution: built on Debian 12 (glibc 2.36, the oldest base with FFmpeg 5.1 and a
  184. # V8 >= 10.2 libnode), every library that isn't the system's bundled, glibc floor 2.35 (Ubuntu 22.04), see
  185. # tools/package_release.sh
  186. portable:
  187. needs: tests
  188. strategy:
  189. matrix:
  190. variant: [kde, generic]
  191. runs-on: ubuntu-24.04
  192. container: debian:12
  193. steps:
  194. - name: Install dependencies
  195. env:
  196. DEBIAN_FRONTEND: noninteractive
  197. run: >-
  198. apt-get update && apt-get -y install --no-install-recommends git ca-certificates curl build-essential
  199. cmake pkg-config patchelf python3 binutils libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
  200. libgl-dev libegl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev
  201. libavutil-dev libswscale-dev libswresample-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev
  202. libpulse-dev libfftw3-dev libfreetype-dev libharfbuzz-dev libdbus-1-dev libnode-dev libwayland-dev
  203. wayland-protocols libgmp-dev libnss3 libnspr4 libcups2 libatk1.0-0 libatk-bridge2.0-0 libxcomposite1
  204. libxdamage1 libgbm1 libxkbcommon0 libasound2 libpango-1.0-0 libcairo2 libdrm2 libxshmfence1
  205. libatspi2.0-0
  206. - uses: actions/checkout@v7
  207. with:
  208. submodules: true
  209. - name: Configure CMake
  210. run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DDISABLE_KDE_FEATURES=${{ matrix.variant == 'generic' && 'ON' || 'OFF' }}
  211. - name: Build
  212. run: cmake --build build --parallel $(nproc)
  213. - name: Package
  214. run: tools/package_release.sh --portable build linux-wallpaperengine-${{ matrix.variant }}-portable-x86_64 "$RUNNER_TEMP"
  215. - uses: actions/upload-artifact@v7
  216. with:
  217. name: linux-wallpaperengine-${{ matrix.variant }}-portable
  218. path: ${{ runner.temp }}/linux-wallpaperengine-${{ matrix.variant }}-portable-x86_64.tar.gz
  219. if-no-files-found: error
  220. # every release tarball unpacked in a bare container of the distributions it is meant for: libraries resolve
  221. # (portable: with only what a desktop has; distribution builds: plus their packages, found by soname) and
  222. # --help runs
  223. smoke:
  224. needs: [build, distro-build, portable]
  225. strategy:
  226. fail-fast: false
  227. matrix:
  228. include:
  229. - { image: 'ubuntu:22.04', tarball: kde-portable }
  230. - { image: 'ubuntu:22.04', tarball: generic-portable }
  231. - { image: 'ubuntu:24.04', tarball: kde-portable }
  232. - { image: 'ubuntu:26.04', tarball: kde-portable }
  233. - { image: 'debian:12', tarball: kde-portable }
  234. - { image: 'debian:13', tarball: kde-portable }
  235. - { image: 'fedora:43', tarball: kde-portable }
  236. - { image: 'fedora:44', tarball: kde-portable }
  237. - { image: 'fedora:45', tarball: kde-portable }
  238. - { image: 'opensuse/leap:16.0', tarball: kde-portable }
  239. - { image: 'opensuse/tumbleweed', tarball: kde-portable }
  240. - { image: 'archlinux:latest', tarball: kde-portable }
  241. - { image: 'ubuntu:24.04', tarball: kde-ubuntu-24.04 }
  242. - { image: 'fedora:44', tarball: kde-fedora-44 }
  243. - { image: 'archlinux:latest', tarball: kde-arch }
  244. runs-on: ubuntu-24.04
  245. container: ${{ matrix.image }}
  246. steps:
  247. - uses: actions/checkout@v7
  248. - uses: actions/download-artifact@v8
  249. with:
  250. # the Ubuntu build's artifact has no distribution in its name
  251. name: linux-wallpaperengine-${{ matrix.tarball == 'kde-ubuntu-24.04' && 'kde' || matrix.tarball }}
  252. path: tarball
  253. - uses: actions/download-artifact@v8
  254. if: matrix.tarball == 'kde-arch'
  255. with:
  256. name: libnode-arch
  257. path: libnode
  258. - name: Smoke test
  259. run: |
  260. libnode=(libnode/libnode-[0-9]*.pkg.tar.zst)
  261. [ -e "${libnode[0]}" ] && export LIBNODE_PKG="$PWD/${libnode[0]}"
  262. tools/smoke_test_release.sh --install-deps tarball/*.tar.gz
  263. shell: bash
  264. release:
  265. needs: [build, distro-build, portable, smoke]
  266. if: startsWith(github.ref, 'refs/tags/')
  267. runs-on: ubuntu-latest
  268. permissions:
  269. contents: write
  270. steps:
  271. - uses: actions/checkout@v7
  272. - uses: actions/download-artifact@v8
  273. with:
  274. path: release
  275. merge-multiple: true
  276. - name: Upload to the release
  277. env:
  278. GH_TOKEN: ${{ github.token }}
  279. run: |
  280. # a release made on GitHub already exists, a manual run on a bare tag has none yet
  281. if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
  282. gh release upload "$GITHUB_REF_NAME" --clobber release/*.tar.gz
  283. else
  284. gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes release/*.tar.gz
  285. fi
  286. # the -bin package points at the release's portable tarball, so it is updated after the upload
  287. aur:
  288. needs: release
  289. runs-on: ubuntu-latest
  290. env:
  291. HAS_AUR_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY != '' }}
  292. steps:
  293. - uses: actions/checkout@v7
  294. - name: Set the version
  295. run: sed -i -e "s/^pkgver=.*/pkgver=${GITHUB_REF_NAME#v}/" -e "s/^pkgrel=.*/pkgrel=1/"
  296. packaging/aur/linux-wallpaperengine-kde-bin/PKGBUILD
  297. - name: Publish linux-wallpaperengine-kde-bin to the AUR
  298. if: env.HAS_AUR_KEY == 'true'
  299. uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
  300. with:
  301. pkgname: linux-wallpaperengine-kde-bin
  302. pkgbuild: ./packaging/aur/linux-wallpaperengine-kde-bin/PKGBUILD
  303. updpkgsums: true
  304. commit_username: ${{ secrets.AUR_USERNAME }}
  305. commit_email: ${{ secrets.AUR_EMAIL }}
  306. ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
  307. commit_message: Update to ${{ github.ref_name }}
  308. clang-build:
  309. needs: tests
  310. permissions:
  311. actions: read
  312. contents: read
  313. security-events: write
  314. strategy:
  315. matrix:
  316. build_type: [Debug, Release]
  317. # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
  318. # You can convert this to a matrix build if you need cross-platform coverage.
  319. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  320. runs-on: ubuntu-24.04
  321. steps:
  322. - uses: actions/checkout@v7
  323. with:
  324. submodules: true
  325. - name: ccache
  326. uses: hendrikmuhs/ccache-action@v1.2.24
  327. with:
  328. key: ${{ github.job }}-ubuntu-24.04-${{ matrix.build_type }}
  329. - name: Install dependencies
  330. run: sudo apt-get update && sudo apt-get -y install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl-dev libglew-dev freeglut3-dev libsdl2-dev liblz4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxxf86vm-dev libglm-dev libglfw3-dev libmpv-dev mpv libmpv2 libpulse-dev libpulse0 libfftw3-dev libfreetype-dev libdbus-1-dev libnode-dev wayland-scanner++ wayland-protocols libwayland-dev
  331. - name: Configure CMake
  332. # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
  333. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
  334. run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++
  335. - name: Build
  336. # Build your program with the given configuration
  337. run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} --verbose