main.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. name: Plugin Build
  2. on:
  3. push:
  4. paths-ignore:
  5. - '**.md'
  6. branches:
  7. - master
  8. - main
  9. tags:
  10. - '*'
  11. pull_request:
  12. paths-ignore:
  13. - '**.md'
  14. branches:
  15. - master
  16. - main
  17. jobs:
  18. clang_check:
  19. name: 01 - Code Format Check
  20. runs-on: ubuntu-22.04
  21. steps:
  22. - name: Checkout
  23. uses: actions/checkout@v3
  24. with:
  25. submodules: recursive
  26. - name: Install clang-format
  27. run: sudo apt-get install -y clang-format-13
  28. - name: Run clang-format
  29. run: ./.github/scripts/check-format.sh && ./.github/scripts/check-changes.sh
  30. - name: Install cmake-format
  31. run: sudo pip install cmakelang
  32. - name: Run cmake-format
  33. run: ./.github/scripts/check-cmake.sh
  34. macos_build:
  35. name: 02 - macOS
  36. runs-on: macos-12
  37. strategy:
  38. fail-fast: true
  39. matrix:
  40. arch: [x86_64, arm64, universal]
  41. if: always()
  42. needs: [clang_check]
  43. outputs:
  44. commitHash: ${{ steps.setup.outputs.commitHash }}
  45. env:
  46. CODESIGN_IDENT: '-'
  47. CODESIGN_IDENT_INSTALLER: ''
  48. MACOSX_DEPLOYMENT_TARGET: '10.15'
  49. defaults:
  50. run:
  51. shell: zsh {0}
  52. steps:
  53. - name: Checkout
  54. uses: actions/checkout@v3
  55. with:
  56. path: plugin
  57. submodules: recursive
  58. - name: Checkout obs-studio
  59. uses: actions/checkout@v3
  60. with:
  61. repository: 'obsproject/obs-studio'
  62. path: obs-studio
  63. fetch-depth: 0
  64. submodules: recursive
  65. - name: Setup Environment
  66. id: setup
  67. working-directory: ${{ github.workspace }}/plugin
  68. run: |
  69. ## SETUP ENVIRONMENT SCRIPT
  70. print '::group::Clean Homebrew Environment'
  71. typeset -a to_remove=()
  72. for formula (speexdsp curl php) {
  73. if [[ -d ${HOMEBREW_PREFIX}/opt/${formula} ]] to_remove+=(${formula})
  74. }
  75. if (( #to_remove > 0 )) brew uninstall --ignore-dependencies ${to_remove}
  76. print '::endgroup::'
  77. print '::group::Set up code signing'
  78. if [[ '${{ secrets.MACOS_SIGNING_APPLICATION_IDENTITY }}' != '' && \
  79. '${{ secrets.MACOS_SIGNING_INSTALLER_IDENTITY }}' != '' && \
  80. '${{ secrets.MACOS_SIGNING_CERT }}' != '' ]] {
  81. print 'haveCodesignIdent=true' >> $GITHUB_OUTPUT
  82. } else {
  83. print 'haveCodesignIdent=false' >> $GITHUB_OUTPUT
  84. }
  85. if [[ '${{ secrets.MACOS_NOTARIZATION_USERNAME }}' != '' && \
  86. '${{ secrets.MACOS_NOTARIZATION_PASSWORD }}' != '' ]] {
  87. print 'haveNotarizationUser=true' >> $GITHUB_OUTPUT
  88. } else {
  89. print 'haveNotarizationUser=false' >> $GITHUB_OUTPUT
  90. }
  91. print '::endgroup::'
  92. print "ccacheDate=$(date +"%Y-%m-%d")" >> $GITHUB_OUTPUT
  93. print "commitHash=${"$(git rev-parse HEAD)"[0,9]}" >> $GITHUB_OUTPUT
  94. print "pluginName=$(jq -r '.name' buildspec.json)" >> $GITHUB_OUTPUT
  95. - name: Restore Compilation Cache
  96. id: ccache-cache
  97. uses: actions/cache@v3
  98. with:
  99. path: ${{ github.workspace }}/.ccache
  100. key: macos-${{ matrix.arch }}-ccache-plugin-${{ steps.setup.outputs.ccacheDate }}
  101. restore-keys: |
  102. macos-${{ matrix.arch }}-ccache-plugin-
  103. - name: Check for GitHub Labels
  104. id: seekingTesters
  105. if: ${{ github.event_name == 'pull_request' }}
  106. run: |
  107. if [[ -n "$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s "${{ github.event.pull_request.url }}" | jq -e '.labels[] | select(.name == "Seeking Testers")')" ]] {
  108. print 'found=true' >> $GITHUB_OUTPUT
  109. } else {
  110. print 'found=false' >> $GITHUB_OUTPUT
  111. }
  112. - name: Install Apple Developer Certificate
  113. if: ${{ github.event_name != 'pull_request' && steps.setup.outputs.haveCodesignIdent == 'true' }}
  114. uses: apple-actions/import-codesign-certs@253ddeeac23f2bdad1646faac5c8c2832e800071
  115. with:
  116. keychain-password: ${{ github.run_id }}
  117. p12-file-base64: ${{ secrets.MACOS_SIGNING_CERT }}
  118. p12-password: ${{ secrets.MACOS_SIGNING_CERT_PASSWORD }}
  119. - name: Set Signing Identity
  120. if: ${{ github.event_name != 'pull_request' && steps.setup.outputs.haveCodesignIdent == 'true' }}
  121. run: |
  122. print "CODESIGN_IDENT=${{ secrets.MACOS_SIGNING_APPLICATION_IDENTITY }}" >> $GITHUB_ENV
  123. print "CODESIGN_IDENT_INSTALLER=${{ secrets.MACOS_SIGNING_INSTALLER_IDENTITY }}" >> $GITHUB_ENV
  124. - name: Build Plugin
  125. uses: ./plugin/.github/actions/build-plugin
  126. with:
  127. workingDirectory: ${{ github.workspace }}/plugin
  128. target: ${{ matrix.arch }}
  129. config: RelWithDebInfo
  130. codesign: 'true'
  131. codesignIdent: ${{ env.CODESIGN_IDENT }}
  132. - name: Package Plugin
  133. uses: ./plugin/.github/actions/package-plugin
  134. with:
  135. workingDirectory: ${{ github.workspace }}/plugin
  136. target: ${{ matrix.arch }}
  137. config: RelWithDebInfo
  138. codesign: ${{ github.event_name != 'pull_request' && steps.setup.outputs.haveCodesignIdent == 'true' }}
  139. notarize: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' && steps.setup.outputs.haveNotarizationUser == 'true' }}
  140. codesignIdent: ${{ env.CODESIGN_IDENT }}
  141. installerIdent: ${{ env.CODESIGN_IDENT_INSTALLER }}
  142. codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
  143. codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
  144. - name: Upload Build Artifact
  145. if: ${{ success() && (github.event_name != 'pull_request' || steps.seekingTesters.outputs.found == 'true') }}
  146. uses: actions/upload-artifact@v3
  147. with:
  148. name: ${{ steps.setup.outputs.pluginName }}-macos-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}
  149. path: ${{ github.workspace }}/plugin/release/${{ steps.setup.outputs.pluginName }}-*-macos-${{ matrix.arch }}.pkg
  150. linux_build:
  151. name: 02 - Linux
  152. runs-on: ubuntu-22.04
  153. strategy:
  154. fail-fast: true
  155. matrix:
  156. arch: [x86_64]
  157. if: always()
  158. needs: [clang_check]
  159. outputs:
  160. commitHash: ${{ steps.setup.outputs.commitHash }}
  161. defaults:
  162. run:
  163. shell: bash
  164. steps:
  165. - name: Checkout
  166. uses: actions/checkout@v3
  167. with:
  168. path: plugin
  169. submodules: recursive
  170. - name: Checkout obs-studio
  171. uses: actions/checkout@v3
  172. with:
  173. repository: 'obsproject/obs-studio'
  174. path: obs-studio
  175. fetch-depth: 0
  176. submodules: recursive
  177. - name: Setup Environment
  178. working-directory: ${{ github.workspace }}/plugin
  179. id: setup
  180. run: |
  181. ## SETUP ENVIRONMENT SCRIPT
  182. echo "ccacheDate=$(date +"%Y-%m-%d")" >> $GITHUB_OUTPUT
  183. echo "commitHash=$(git rev-parse HEAD | cut -c1-9)" >> $GITHUB_OUTPUT
  184. echo "pluginName=$(jq -r '.name' buildspec.json)" >> $GITHUB_OUTPUT
  185. - name: Restore Compilation Cache
  186. id: ccache-cache
  187. uses: actions/cache@v3
  188. with:
  189. path: ${{ github.workspace }}/.ccache
  190. key: linux-${{ matrix.arch }}-ccache-plugin-${{ steps.setup.outputs.ccacheDate }}
  191. restore-keys: |
  192. linux-${{ matrix.arch }}-ccache-plugin-
  193. - name: Check for GitHub Labels
  194. id: seekingTesters
  195. if: ${{ github.event_name == 'pull_request' }}
  196. run: |
  197. ## GITHUB LABEL SCRIPT
  198. if [[ -n "$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s "${{ github.event.pull_request.url }}" | jq -e '.labels[] | select(.name == "Seeking Testers")')" ]]; then
  199. echo 'found=true' >> $GITHUB_OUTPUT
  200. else
  201. echo 'found=false' >> $GITHUB_OUTPUT
  202. fi
  203. - name: Build Plugin
  204. uses: ./plugin/.github/actions/build-plugin
  205. with:
  206. workingDirectory: ${{ github.workspace }}/plugin
  207. target: ${{ matrix.arch }}
  208. config: RelWithDebInfo
  209. - name: Package Plugin
  210. uses: ./plugin/.github/actions/package-plugin
  211. with:
  212. workingDirectory: ${{ github.workspace }}/plugin
  213. target: ${{ matrix.arch }}
  214. config: RelWithDebInfo
  215. - name: Upload Build Artifact
  216. if: ${{ success() && (github.event_name != 'pull_request' || steps.seekingTesters.outputs.found == 'true') }}
  217. uses: actions/upload-artifact@v3
  218. with:
  219. name: ${{ steps.setup.outputs.pluginName }}-linux-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}
  220. path: ${{ github.workspace }}/plugin/release/${{ steps.setup.outputs.pluginName }}-*-linux-${{ matrix.arch }}.*
  221. windows_build:
  222. name: 02 - Windows
  223. runs-on: windows-2022
  224. strategy:
  225. fail-fast: true
  226. matrix:
  227. arch: [x64]
  228. if: always()
  229. needs: [clang_check]
  230. outputs:
  231. commitHash: ${{ steps.setup.outputs.commitHash }}
  232. defaults:
  233. run:
  234. shell: pwsh
  235. steps:
  236. - name: Checkout
  237. uses: actions/checkout@v3
  238. with:
  239. path: plugin
  240. submodules: recursive
  241. - name: Checkout obs-studio
  242. uses: actions/checkout@v3
  243. with:
  244. repository: 'obsproject/obs-studio'
  245. path: obs-studio
  246. fetch-depth: 0
  247. submodules: recursive
  248. - name: Setup Environment
  249. working-directory: ${{ github.workspace }}/plugin
  250. id: setup
  251. run: |
  252. ## SETUP ENVIRONMENT SCRIPT
  253. $CommitHash = (git rev-parse HEAD)[0..8] -join ''
  254. "commitHash=${CommitHash}" >> $env:GITHUB_OUTPUT
  255. $BuildSpec = Get-Content -Path buildspec.json -Raw | ConvertFrom-Json
  256. $PluginName = $BuildSpec.name
  257. "pluginName=${PluginName}" >> $env:GITHUB_OUTPUT
  258. - name: Check for GitHub Labels
  259. id: seekingTesters
  260. working-directory: ${{ github.workspace }}/plugin
  261. if: ${{ github.event_name == 'pull_request' }}
  262. run: |
  263. ## GITHUB LABEL SCRIPT
  264. $LabelFound = try {
  265. $Params = @{
  266. Authentication = 'Bearer'
  267. Token = (ConvertTo-SecureString '${{ secrets.GITHUB_TOKEN }}' -AsPlainText)
  268. Uri = '${{ github.event.pull_request.url }}'
  269. UseBasicParsing = $true
  270. }
  271. (Invoke-RestMethod @Params).labels.name.contains('Seeking Testers')
  272. } catch {
  273. $false
  274. }
  275. "found=$(([string]${LabelFound}).ToLower())" >> $env:GITHUB_OUTPUT
  276. - name: Build Plugin
  277. uses: ./plugin/.github/actions/build-plugin
  278. with:
  279. workingDirectory: ${{ github.workspace }}/plugin
  280. target: ${{ matrix.arch }}
  281. config: RelWithDebInfo
  282. visualStudio: 'Visual Studio 17 2022'
  283. - name: Package Plugin
  284. uses: ./plugin/.github/actions/package-plugin
  285. with:
  286. workingDirectory: ${{ github.workspace }}/plugin
  287. target: ${{ matrix.arch }}
  288. config: RelWithDebInfo
  289. - name: Upload Build Artifact
  290. if: ${{ success() && (github.event_name != 'pull_request' || steps.seekingTesters.outputs.found == 'true') }}
  291. uses: actions/upload-artifact@v3
  292. with:
  293. name: ${{ steps.setup.outputs.pluginName }}-windows-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}
  294. path: ${{ github.workspace }}/plugin/release/${{ steps.setup.outputs.pluginName }}-*.zip
  295. - name: Package Plugin Installer
  296. if: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' }}
  297. uses: ./plugin/.github/actions/package-plugin
  298. with:
  299. workingDirectory: ${{ github.workspace }}/plugin
  300. target: ${{ matrix.arch }}
  301. config: RelWithDebInfo
  302. createInstaller: true
  303. - name: Upload Installer Artifact
  304. if: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' }}
  305. uses: actions/upload-artifact@v3
  306. with:
  307. name: ${{ steps.setup.outputs.pluginName }}-windows-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}-installer
  308. path: ${{ github.workspace }}/plugin/release/${{ steps.setup.outputs.pluginName }}-*.exe
  309. make-release:
  310. name: 03 - Create and upload release
  311. runs-on: ubuntu-22.04
  312. if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
  313. needs: [macos_build, linux_build, windows_build]
  314. defaults:
  315. run:
  316. shell: bash
  317. permissions:
  318. contents: write
  319. steps:
  320. - name: Checkout
  321. uses: actions/checkout@v3
  322. with:
  323. path: plugin
  324. submodules: recursive
  325. - name: Get Metadata
  326. working-directory: ${{ github.workspace }}/plugin
  327. id: metadata
  328. run: |
  329. ## METADATA SCRIPT
  330. echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
  331. echo "pluginName=$(jq -r '.name' buildspec.json)" >> $GITHUB_OUTPUT
  332. - name: Download build artifacts
  333. uses: actions/download-artifact@v3
  334. - name: Generate Checksums
  335. run: |
  336. ## CHECKSUM GENERATION SCRIPT
  337. shopt -s extglob
  338. echo "### Checksums" > ${{ github.workspace }}/CHECKSUMS.txt
  339. for file in ${{ github.workspace }}/**/@(*.pkg|*.exe|*.deb|*.zip); do
  340. echo " ${file##*/}: $(sha256sum "${file}" | cut -d " " -f 1)" >> ${{ github.workspace }}/CHECKSUMS.txt
  341. done
  342. - name: Create Release
  343. id: create_release
  344. uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
  345. with:
  346. draft: false
  347. prerelease: ${{ contains(steps.metadata.outputs.version, 'rc') || contains(steps.metadata.outputs.version, 'beta') }}
  348. tag_name: ${{ steps.metadata.outputs.version }}
  349. name: "${{ steps.metadata.outputs.pluginName }} ${{ steps.metadata.outputs.version }}"
  350. body_path: ${{ github.workspace }}/CHECKSUMS.txt
  351. files: |
  352. ${{ github.workspace }}/**/*.zip
  353. ${{ github.workspace }}/**/*.exe
  354. ${{ github.workspace }}/**/*.deb
  355. ${{ github.workspace }}/**/*.pkg