build-project.yaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. name: Build Project
  2. on:
  3. workflow_call:
  4. jobs:
  5. check-event:
  6. name: Event Data 🔎
  7. runs-on: ubuntu-22.04
  8. defaults:
  9. run:
  10. shell: bash
  11. outputs:
  12. package: ${{ steps.setup.outputs.package }}
  13. codesign: ${{ steps.setup.outputs.codesign }}
  14. notarize: ${{ steps.setup.outputs.notarize }}
  15. config: ${{ steps.setup.outputs.config }}
  16. commitHash: ${{ steps.setup.outputs.commitHash }}
  17. steps:
  18. - uses: actions/checkout@v4
  19. with:
  20. fetch-depth: 0
  21. - name: Check Event Data ☑️
  22. id: setup
  23. env:
  24. GH_TOKEN: ${{ github.token }}
  25. run: |
  26. : Check Event Data ☑️
  27. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  28. case "${GITHUB_EVENT_NAME}" in
  29. pull_request)
  30. config_data=('codesign:false' 'notarize:false' 'package:false' 'config:RelWithDebInfo')
  31. if gh pr view ${{ github.event.number }} --json labels \
  32. | jq -e -r '.labels[] | select(.name == "Seeking Testers")' > /dev/null; then
  33. config_data[0]='codesign:true'
  34. config_data[2]='package:true'
  35. fi
  36. ;;
  37. push)
  38. config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo')
  39. if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then
  40. config_data[1]='notarize:true'
  41. config_data[3]='config:Release'
  42. fi
  43. ;;
  44. workflow_dispatch)
  45. config_data=('codesign:true' 'notarize:false' 'package:false' 'config:RelWithDebInfo')
  46. ;;
  47. schedule)
  48. config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo')
  49. ;;
  50. *) ;;
  51. esac
  52. for config in "${config_data[@]}"; do
  53. IFS=':' read -r key value <<< "${config}"
  54. echo "${key}=${value}" >> $GITHUB_OUTPUT
  55. done
  56. echo "commitHash=${GITHUB_SHA:0:9}" >> $GITHUB_OUTPUT
  57. macos-build:
  58. name: macOS 🍏
  59. runs-on: macos-14
  60. needs: check-event
  61. strategy:
  62. fail-fast: false
  63. matrix:
  64. target: [arm64, x86_64]
  65. defaults:
  66. run:
  67. shell: zsh --no-rcs --errexit --pipefail {0}
  68. steps:
  69. - uses: actions/checkout@v4
  70. with:
  71. submodules: recursive
  72. fetch-depth: 0
  73. - name: Set Up Environment 🔧
  74. id: setup
  75. run: |
  76. : Set Up Environment 🔧
  77. if (( ${+RUNNER_DEBUG} )) setopt XTRACE
  78. print '::group::Enable Xcode 15.2'
  79. sudo xcode-select --switch /Applications/Xcode_15.2.app/Contents/Developer
  80. print '::endgroup::'
  81. print '::group::Clean Homebrew Environment'
  82. local -a to_remove=()
  83. for formula (curl) {
  84. if [[ -d ${HOMEBREW_PREFIX}/opt/${formula} ]] to_remove+=(${formula})
  85. }
  86. if (( #to_remove )) brew uninstall --ignore-dependencies ${to_remove}
  87. print '::endgroup::'
  88. local -A arch_names=(x86_64 intel arm64 apple)
  89. print "cpuName=${arch_names[${{ matrix.target }}]}" >> $GITHUB_OUTPUT
  90. - uses: actions/cache/restore@v4
  91. id: ccache-cache
  92. with:
  93. path: ${{ github.workspace }}/.ccache
  94. key: ${{ runner.os }}-ccache-${{ matrix.target }}-${{ needs.check-event.outputs.config }}
  95. restore-keys: |
  96. ${{ runner.os }}-ccache-${{ matrix.target }}-
  97. - name: Set Up Code Signing 🔑
  98. uses: ./.github/actions/setup-macos-codesigning
  99. if: fromJSON(needs.check-event.outputs.codesign)
  100. id: codesign
  101. with:
  102. codesignIdentity: ${{ secrets.MACOS_SIGNING_IDENTITY }}
  103. codesignCertificate: ${{ secrets.MACOS_SIGNING_CERT }}
  104. certificatePassword: ${{ secrets.MACOS_SIGNING_CERT_PASSWORD }}
  105. keychainPassword: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  106. provisioningProfile: ${{ secrets.MACOS_SIGNING_PROVISIONING_PROFILE }}
  107. notarizationUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
  108. notarizationPassword: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
  109. - name: Build OBS Studio 🧱
  110. uses: ./.github/actions/build-obs
  111. env:
  112. TWITCH_CLIENTID: ${{ secrets.TWITCH_CLIENT_ID }}
  113. TWITCH_HASH: ${{ secrets.TWITCH_HASH }}
  114. RESTREAM_CLIENTID: ${{ secrets.RESTREAM_CLIENTID }}
  115. RESTREAM_HASH: ${{ secrets.RESTREAM_HASH }}
  116. YOUTUBE_CLIENTID: ${{ secrets.YOUTUBE_CLIENTID }}
  117. YOUTUBE_CLIENTID_HASH: ${{ secrets.YOUTUBE_CLIENTID_HASH }}
  118. YOUTUBE_SECRET: ${{ secrets.YOUTUBE_SECRET }}
  119. YOUTUBE_SECRET_HASH: ${{ secrets.YOUTUBE_SECRET_HASH }}
  120. with:
  121. target: ${{ matrix.target }}
  122. config: ${{ needs.check-event.outputs.config }}
  123. codesign: ${{ fromJSON(needs.check-event.outputs.codesign) }}
  124. codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
  125. codesignTeam: ${{ steps.codesign.outputs.codesignTeam }}
  126. provisioningProfileUUID: ${{ steps.codesign.outputs.provisioningProfileUUID }}
  127. - name: Package OBS Studio 📀
  128. uses: ./.github/actions/package-obs
  129. with:
  130. target: ${{ matrix.target }}
  131. config: ${{ needs.check-event.outputs.config }}
  132. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  133. codesign: ${{ fromJSON(needs.check-event.outputs.codesign) && fromJSON(steps.codesign.outputs.haveCodesignIdent) }}
  134. codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
  135. notarize: ${{ fromJSON(needs.check-event.outputs.notarize) && fromJSON(steps.codesign.outputs.haveNotarizationUser) }}
  136. codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
  137. codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
  138. - name: Upload Artifacts 📡
  139. uses: actions/upload-artifact@v4
  140. with:
  141. name: obs-studio-macos-${{ matrix.target }}-${{ needs.check-event.outputs.commitHash }}
  142. path: ${{ github.workspace }}/build_macos/obs-studio-*-macos-${{ steps.setup.outputs.cpuName }}.*
  143. - name: Upload Debug Symbol Artifacts 🪲
  144. uses: actions/upload-artifact@v4
  145. if: ${{ needs.check-event.outputs.config == 'Release' }}
  146. with:
  147. name: obs-studio-macos-${{ matrix.target }}-${{ needs.check-event.outputs.commitHash }}-dSYMs
  148. path: ${{ github.workspace }}/build_macos/obs-studio-*-macos-${{ steps.setup.outputs.cpuName }}-dSYMs.tar.xz
  149. - uses: actions/cache/save@v4
  150. if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
  151. with:
  152. path: ${{ github.workspace }}/.ccache
  153. key: ${{ runner.os }}-ccache-${{ matrix.target }}-${{ needs.check-event.outputs.config }}
  154. ubuntu-build:
  155. name: Ubuntu 🐧
  156. runs-on: ubuntu-22.04
  157. needs: check-event
  158. defaults:
  159. run:
  160. shell: bash
  161. steps:
  162. - uses: actions/checkout@v4
  163. with:
  164. submodules: recursive
  165. fetch-depth: 0
  166. - uses: actions/cache/restore@v4
  167. id: ccache-cache
  168. with:
  169. path: ${{ github.workspace }}/.ccache
  170. key: ${{ runner.os }}-ccache-x86_64-${{ needs.check-event.outputs.config }}
  171. restore-keys: |
  172. ${{ runner.os }}-ccache-x86_64-
  173. - name: Build OBS Studio 🧱
  174. uses: ./.github/actions/build-obs
  175. env:
  176. TWITCH_CLIENTID: ${{ secrets.TWITCH_CLIENT_ID }}
  177. TWITCH_HASH: ${{ secrets.TWITCH_HASH }}
  178. RESTREAM_CLIENTID: ${{ secrets.RESTREAM_CLIENTID }}
  179. RESTREAM_HASH: ${{ secrets.RESTREAM_HASH }}
  180. YOUTUBE_CLIENTID: ${{ secrets.YOUTUBE_CLIENTID }}
  181. YOUTUBE_CLIENTID_HASH: ${{ secrets.YOUTUBE_CLIENTID_HASH }}
  182. YOUTUBE_SECRET: ${{ secrets.YOUTUBE_SECRET }}
  183. YOUTUBE_SECRET_HASH: ${{ secrets.YOUTUBE_SECRET_HASH }}
  184. with:
  185. target: x86_64
  186. config: ${{ needs.check-event.outputs.config }}
  187. - name: Package OBS Studio 📀
  188. uses: ./.github/actions/package-obs
  189. with:
  190. target: x86_64
  191. config: ${{ needs.check-event.outputs.config }}
  192. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  193. - name: Upload Source Tarball 🗜️
  194. uses: actions/upload-artifact@v4
  195. with:
  196. name: obs-studio-ubuntu-22.04-sources-${{ needs.check-event.outputs.commitHash }}
  197. path: ${{ github.workspace }}/build_ubuntu/obs-studio-*-sources.*
  198. - name: Upload Artifacts 📡
  199. uses: actions/upload-artifact@v4
  200. with:
  201. name: obs-studio-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}
  202. path: ${{ github.workspace }}/build_ubuntu/obs-studio-*-x86_64-ubuntu-gnu.*
  203. - name: Upload Debug Symbol Artifacts 🪲
  204. uses: actions/upload-artifact@v4
  205. if: ${{ fromJSON(needs.check-event.outputs.package) }}
  206. with:
  207. name: obs-studio-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym
  208. path: ${{ github.workspace }}/build_ubuntu/obs-studio-*-x86_64-ubuntu-gnu-dbgsym.ddeb
  209. - uses: actions/cache/save@v4
  210. if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
  211. with:
  212. path: ${{ github.workspace }}/.ccache
  213. key: ${{ runner.os }}-ccache-x86_64-${{ needs.check-event.outputs.config }}
  214. flatpak-build:
  215. name: Flatpak 📦
  216. runs-on: ubuntu-22.04
  217. needs: check-event
  218. defaults:
  219. run:
  220. shell: bash
  221. env:
  222. FLATPAK_BUILD_SHARE_PATH: flatpak_app/files/share
  223. container:
  224. image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.6
  225. options: --privileged
  226. steps:
  227. - uses: actions/checkout@v4
  228. with:
  229. submodules: recursive
  230. fetch-depth: 0
  231. set-safe-directory: ${{ env.GITHUB_WORKSPACE }}
  232. - name: Set Up Environment 🔧
  233. id: setup
  234. env:
  235. GH_TOKEN: ${{ github.token }}
  236. run: |
  237. : Set Up Environment 🔧
  238. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  239. git config --global --add safe.directory "${GITHUB_WORKSPACE}"
  240. echo '::group::Install actions/gh-actions-cache'
  241. gh extension install actions/gh-actions-cache
  242. echo '::endgroup::'
  243. cache_key='flatpak-builder-${{ hashFiles('build-aux/**/*.json') }}'
  244. cache_ref='master'
  245. read -r key size unit _ ref _ <<< \
  246. "$(gh actions-cache list -B ${cache_ref} --key "${cache_key}-x86_64" | head -1)"
  247. if [[ "${key}" ]]; then
  248. echo "cacheHit=true" >> $GITHUB_OUTPUT
  249. else
  250. echo "cacheHit=false" >> $GITHUB_OUTPUT
  251. fi
  252. echo "cacheKey=${cache_key}" >> $GITHUB_OUTPUT
  253. - name: Validate Flatpak manifest
  254. uses: ./.github/actions/flatpak-builder-lint
  255. with:
  256. artifact: manifest
  257. path: build-aux/com.obsproject.Studio.json
  258. - name: Build Flatpak Manifest 🧾
  259. uses: flathub-infra/flatpak-github-actions/flatpak-builder@23796715b3dfa4c86ddf50cf29c3cc8b3c82dca8
  260. with:
  261. build-bundle: ${{ fromJSON(needs.check-event.outputs.package) }}
  262. bundle: obs-studio-flatpak-${{ needs.check-event.outputs.commitHash }}.flatpak
  263. manifest-path: ${{ github.workspace }}/build-aux/com.obsproject.Studio.json
  264. cache: ${{ fromJSON(steps.setup.outputs.cacheHit) || (github.event_name == 'push' && github.ref_name == 'master')}}
  265. restore-cache: ${{ fromJSON(steps.setup.outputs.cacheHit) }}
  266. cache-key: ${{ steps.setup.outputs.cacheKey }}
  267. mirror-screenshots-url: https://dl.flathub.org/media
  268. - name: Validate AppStream
  269. uses: ./.github/actions/flatpak-builder-lint
  270. with:
  271. artifact: appstream
  272. path: ${{ env.FLATPAK_BUILD_SHARE_PATH }}/metainfo/com.obsproject.Studio.metainfo.xml
  273. - name: Verify Icon and Metadata in app-info
  274. working-directory: ${{ env.FLATPAK_BUILD_SHARE_PATH }}
  275. run: |
  276. : Verify Icon and Metadata in app-info
  277. test -f app-info/icons/flatpak/128x128/com.obsproject.Studio.png || { echo "::error::Missing 128x128 icon in app-info"; exit 1; }
  278. test -f app-info/xmls/com.obsproject.Studio.xml.gz || { echo "::error::Missing com.obsproject.Studio.xml.gz in app-info"; exit 1; }
  279. - name: Validate build directory
  280. uses: ./.github/actions/flatpak-builder-lint
  281. with:
  282. artifact: builddir
  283. path: flatpak_app
  284. - name: Validate repository
  285. uses: ./.github/actions/flatpak-builder-lint
  286. with:
  287. artifact: repo
  288. path: repo
  289. windows-build:
  290. name: Windows 🪟
  291. runs-on: windows-2022
  292. needs: check-event
  293. defaults:
  294. run:
  295. shell: pwsh
  296. steps:
  297. - uses: actions/checkout@v4
  298. with:
  299. submodules: recursive
  300. fetch-depth: 0
  301. - uses: actions/cache@v4
  302. id: ccache-cache
  303. if: github.event_name == 'pull_request'
  304. with:
  305. path: ${{ github.workspace }}/.ccache
  306. key: ${{ runner.os }}-ccache-x86_64-${{ needs.check-event.outputs.config }}
  307. restore-keys: |
  308. ${{ runner.os }}-ccache-x86_64-
  309. - name: Build OBS Studio 🧱
  310. uses: ./.github/actions/build-obs
  311. env:
  312. TWITCH_CLIENTID: ${{ secrets.TWITCH_CLIENT_ID }}
  313. TWITCH_HASH: ${{ secrets.TWITCH_HASH }}
  314. RESTREAM_CLIENTID: ${{ secrets.RESTREAM_CLIENTID }}
  315. RESTREAM_HASH: ${{ secrets.RESTREAM_HASH }}
  316. YOUTUBE_CLIENTID: ${{ secrets.YOUTUBE_CLIENTID }}
  317. YOUTUBE_CLIENTID_HASH: ${{ secrets.YOUTUBE_CLIENTID_HASH }}
  318. YOUTUBE_SECRET: ${{ secrets.YOUTUBE_SECRET }}
  319. YOUTUBE_SECRET_HASH: ${{ secrets.YOUTUBE_SECRET_HASH }}
  320. GPU_PRIORITY_VAL: ${{ secrets.GPU_PRIORITY_VAL }}
  321. with:
  322. target: x64
  323. config: ${{ needs.check-event.outputs.config }}
  324. - name: Package OBS Studio 📀
  325. uses: ./.github/actions/package-obs
  326. with:
  327. target: x64
  328. config: ${{ needs.check-event.outputs.config }}
  329. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  330. - name: Upload Artifacts 📡
  331. uses: actions/upload-artifact@v4
  332. with:
  333. name: obs-studio-windows-x64-${{ needs.check-event.outputs.commitHash }}
  334. path: ${{ github.workspace }}/build_x64/obs-studio-*-windows-x64.zip