build.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. name: Build
  2. on:
  3. push:
  4. branches: [main]
  5. tags: ['v*']
  6. pull_request:
  7. workflow_dispatch:
  8. jobs:
  9. steamworks-vote:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/checkout@v7
  13. - uses: actions/setup-node@v7
  14. with:
  15. node-version: 22
  16. - name: Install clang for bindgen
  17. run: sudo apt-get update && sudo apt-get install -y clang libclang-dev
  18. - name: Build patched steamworks.js
  19. env:
  20. STEAMWORKSJS_BUILD: build
  21. run: bash patches/steamworks-vote/build.sh "$RUNNER_TEMP/src"
  22. - name: Pack
  23. run: |
  24. mkdir -p "$RUNNER_TEMP/out"
  25. cd "$RUNNER_TEMP/src/steamworksjs"
  26. npm pack --pack-destination "$RUNNER_TEMP/out"
  27. cp dist/linux64/steamworksjs.linux-x64-gnu.node dist/linux64/libsteam_api.so "$RUNNER_TEMP/out/"
  28. - uses: actions/upload-artifact@v7
  29. with:
  30. name: steamworks-vote
  31. path: ${{ runner.temp }}/out/*
  32. if-no-files-found: error
  33. we-manager:
  34. needs: steamworks-vote
  35. # still build the app when the patch build breaks, it just falls back to unconfirmed votes then
  36. if: ${{ !cancelled() }}
  37. runs-on: ubuntu-latest
  38. steps:
  39. - uses: actions/checkout@v7
  40. - uses: actions/setup-node@v7
  41. with:
  42. node-version: 22
  43. cache: npm
  44. - run: npm ci
  45. - uses: actions/download-artifact@v8
  46. if: ${{ needs.steamworks-vote.result == 'success' }}
  47. with:
  48. name: steamworks-vote
  49. path: ${{ runner.temp }}/steamworks-vote
  50. - name: Use patched steamworks.js
  51. if: ${{ needs.steamworks-vote.result == 'success' }}
  52. run: npm install --no-save "$RUNNER_TEMP"/steamworks-vote/steamworks.js-*.tgz
  53. - run: npm run build
  54. - run: npx electron-builder --linux --publish never
  55. - uses: actions/upload-artifact@v7
  56. with:
  57. name: we-manager
  58. path: |
  59. dist/*.AppImage
  60. dist/*.deb
  61. if-no-files-found: error
  62. # the engine's portable tarball for the Flatpak: from the newest release that has one, else the newest artifact of the
  63. # engine's CMake workflow (a release only gets the tarball at the end of that run)
  64. engine-portable:
  65. runs-on: ubuntu-latest
  66. outputs:
  67. found: ${{ steps.fetch.outputs.found }}
  68. steps:
  69. - name: Fetch the portable engine
  70. id: fetch
  71. env:
  72. GH_TOKEN: ${{ github.token }}
  73. ENGINE: WallpaperEngineLover/linux-wallpaperengine-kde
  74. ASSET: linux-wallpaperengine-kde-portable-x86_64.tar.gz
  75. run: |
  76. mkdir -p engine
  77. tag=$(gh api "repos/$ENGINE/releases?per_page=30" \
  78. --jq "[.[] | select(any(.assets[]; .name == \"$ASSET\"))][0].tag_name // empty")
  79. if [ -n "$tag" ]; then
  80. echo "using release $tag"
  81. gh release download "$tag" -R "$ENGINE" -p "$ASSET" -D engine
  82. else
  83. # the newest unexpired artifact, also from a run that failed later on or is still going
  84. run=$(gh api "repos/$ENGINE/actions/artifacts?name=linux-wallpaperengine-kde-portable&per_page=10" \
  85. --jq '[.artifacts[] | select(.expired | not)][0].workflow_run.id // empty')
  86. if [ -n "$run" ] && gh run download "$run" -R "$ENGINE" -n linux-wallpaperengine-kde-portable -D engine; then
  87. echo "using the artifact of CMake run $run"
  88. fi
  89. fi
  90. if [ -f "engine/$ASSET" ]; then
  91. echo "found=true" >> "$GITHUB_OUTPUT"
  92. else
  93. echo "::warning::no portable linux-wallpaperengine-kde build in a release or a CMake run artifact, skipping the Flatpak"
  94. echo "found=false" >> "$GITHUB_OUTPUT"
  95. fi
  96. - uses: actions/upload-artifact@v7
  97. if: steps.fetch.outputs.found == 'true'
  98. with:
  99. name: engine-portable
  100. path: engine/linux-wallpaperengine-kde-portable-x86_64.tar.gz
  101. if-no-files-found: error
  102. # the app's .deb from above plus the portable engine, see packaging/flatpak
  103. flatpak:
  104. needs: [we-manager, engine-portable]
  105. if: needs.engine-portable.outputs.found == 'true'
  106. runs-on: ubuntu-latest
  107. container:
  108. image: ghcr.io/flathub-infra/flatpak-github-actions:freedesktop-25.08
  109. options: --privileged
  110. steps:
  111. - uses: actions/checkout@v7
  112. - uses: actions/download-artifact@v8
  113. with:
  114. name: we-manager
  115. path: ${{ runner.temp }}/we-manager
  116. - uses: actions/download-artifact@v8
  117. with:
  118. name: engine-portable
  119. path: packaging/flatpak
  120. - name: Collect sources
  121. run: cp "$RUNNER_TEMP"/we-manager/*.deb packaging/flatpak/we-manager.deb
  122. - uses: flatpak/flatpak-github-actions/flatpak-builder@v6
  123. with:
  124. bundle: we-manager.flatpak
  125. manifest-path: packaging/flatpak/io.github.WallpaperEngineLover.we_manager.yml
  126. cache-key: flatpak-builder-${{ github.sha }}
  127. upload-artifact: false
  128. - uses: actions/upload-artifact@v7
  129. with:
  130. name: we-manager-flatpak
  131. path: we-manager.flatpak
  132. if-no-files-found: error
  133. release:
  134. needs: [steamworks-vote, we-manager, flatpak]
  135. if: ${{ !cancelled() && startsWith(github.ref, 'refs/tags/v') && needs.we-manager.result == 'success' }}
  136. runs-on: ubuntu-latest
  137. permissions:
  138. contents: write
  139. steps:
  140. - uses: actions/checkout@v7
  141. - name: Check tag matches package.json version
  142. run: |
  143. version=$(node -p "require('./package.json').version")
  144. if [ "v$version" != "$GITHUB_REF_NAME" ]; then
  145. echo "tag $GITHUB_REF_NAME does not match package.json version $version"
  146. exit 1
  147. fi
  148. - uses: actions/download-artifact@v8
  149. with:
  150. path: release
  151. merge-multiple: true
  152. - name: Create release
  153. env:
  154. GH_TOKEN: ${{ github.token }}
  155. run: |
  156. gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes \
  157. release/*.AppImage release/*.deb $(ls release/steamworks.js-*.tgz release/*.flatpak 2>/dev/null)
  158. aur:
  159. needs: release
  160. runs-on: ubuntu-latest
  161. env:
  162. HAS_AUR_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY != '' }}
  163. steps:
  164. - uses: actions/checkout@v7
  165. - name: Set the version
  166. run: sed -i -e "s/^pkgver=.*/pkgver=${GITHUB_REF_NAME#v}/" -e "s/^pkgrel=.*/pkgrel=1/"
  167. packaging/aur/we-manager-bin/PKGBUILD
  168. - name: Publish we-manager-bin to the AUR
  169. if: env.HAS_AUR_KEY == 'true'
  170. uses: KSXGitHub/github-actions-deploy-aur@v4.1.1
  171. with:
  172. pkgname: we-manager-bin
  173. pkgbuild: ./packaging/aur/we-manager-bin/PKGBUILD
  174. updpkgsums: true
  175. commit_username: ${{ secrets.AUR_USERNAME }}
  176. commit_email: ${{ secrets.AUR_EMAIL }}
  177. ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
  178. commit_message: Update to ${{ github.ref_name }}