main.yml 13 KB

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