build.yml 8.7 KB

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