main.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. name: Plugin Build
  2. on:
  3. push:
  4. paths-ignore:
  5. - '**.md'
  6. branches:
  7. - master
  8. tags:
  9. - '*'
  10. pull_request:
  11. paths-ignore:
  12. - '**.md'
  13. branches:
  14. - master
  15. env:
  16. PLUGIN_NAME: 'obs-plugintemplate'
  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 '::set-output name=haveCodesignIdent::true'
  82. } else {
  83. print '::set-output name=haveCodesignIdent::false'
  84. }
  85. if [[ '${{ secrets.MACOS_NOTARIZATION_USERNAME }}' != '' && \
  86. '${{ secrets.MACOS_NOTARIZATION_PASSWORD }}' != '' ]] {
  87. print '::set-output name=haveNotarizationUser::true'
  88. } else {
  89. print '::set-output name=haveNotarizationUser::false'
  90. }
  91. print '::endgroup::'
  92. print "::set-output name=ccacheDate::$(date +"%Y-%m-%d")"
  93. print "::set-output name=commitHash::${"$(git rev-parse HEAD)"[0,9]}"
  94. - name: Restore Compilation Cache
  95. id: ccache-cache
  96. uses: actions/cache@v2.1.7
  97. with:
  98. path: ${{ github.workspace }}/.ccache
  99. key: macos-${{ matrix.arch }}-ccache-plugin-${{ steps.setup.outputs.ccacheDate }}
  100. restore-keys: |
  101. macos-${{ matrix.arch }}-ccache-plugin-
  102. - name: Check for GitHub Labels
  103. id: seekingTesters
  104. if: ${{ github.event_name == 'pull_request' }}
  105. run: |
  106. if [[ -n "$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s "${{ github.event.pull_request.url }}" | jq -e '.labels[] | select(.name == "Seeking Testers")')" ]] {
  107. print '::set-output name=found::true'
  108. } else {
  109. print '::set-output name=found::false'
  110. }
  111. - name: Install Apple Developer Certificate
  112. if: ${{ github.event_name != 'pull_request' && steps.setup.outputs.haveCodesignIdent == 'true' }}
  113. uses: apple-actions/import-codesign-certs@253ddeeac23f2bdad1646faac5c8c2832e800071
  114. with:
  115. keychain-password: ${{ github.run_id }}
  116. p12-file-base64: ${{ secrets.MACOS_SIGNING_CERT }}
  117. p12-password: ${{ secrets.MACOS_SIGNING_CERT_PASSWORD }}
  118. - name: Set Signing Identity
  119. if: ${{ github.event_name != 'pull_request' && steps.setup.outputs.haveCodesignIdent == 'true' }}
  120. run: |
  121. print "CODESIGN_IDENT=${{ secrets.MACOS_SIGNING_APPLICATION_IDENTITY }}" >> $GITHUB_ENV
  122. print "CODESIGN_IDENT_INSTALLER=${{ secrets.MACOS_SIGNING_INSTALLER_IDENTITY }}" >> $GITHUB_ENV
  123. - name: Build Plugin
  124. uses: ./plugin/.github/actions/build-plugin
  125. with:
  126. workingDirectory: ${{ github.workspace }}/plugin
  127. target: ${{ matrix.arch }}
  128. config: RelWithDebInfo
  129. codesign: 'true'
  130. codesignIdent: ${{ env.CODESIGN_IDENT }}
  131. - name: Package Plugin
  132. uses: ./plugin/.github/actions/package-plugin
  133. with:
  134. workingDirectory: ${{ github.workspace }}/plugin
  135. target: ${{ matrix.arch }}
  136. config: RelWithDebInfo
  137. codesign: ${{ github.event_name != 'pull_request' && steps.setup.outputs.haveCodesignIdent == 'true' }}
  138. notarize: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' && steps.setup.outputs.haveNotarizationUser == 'true' }}
  139. codesignIdent: ${{ env.CODESIGN_IDENT }}
  140. installerIdent: ${{ env.CODESIGN_IDENT_INSTALLER }}
  141. codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
  142. codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
  143. - name: Upload Build Artifact
  144. if: ${{ success() && (github.event_name != 'pull_request' || steps.seekingTesters.outputs.found == 'true') }}
  145. uses: actions/upload-artifact@v3
  146. with:
  147. name: ${{ env.PLUGIN_NAME }}-macos-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}
  148. path: ${{ github.workspace }}/plugin/release/${{ env.PLUGIN_NAME }}-*-macos-${{ matrix.arch }}.pkg
  149. linux_build:
  150. name: 02 - Linux
  151. runs-on: ubuntu-22.04
  152. strategy:
  153. fail-fast: true
  154. matrix:
  155. arch: [x86_64]
  156. if: always()
  157. needs: [clang_check]
  158. outputs:
  159. commitHash: ${{ steps.setup.outputs.commitHash }}
  160. defaults:
  161. run:
  162. shell: bash
  163. steps:
  164. - name: Checkout
  165. uses: actions/checkout@v3
  166. with:
  167. path: plugin
  168. submodules: recursive
  169. - name: Checkout obs-studio
  170. uses: actions/checkout@v3
  171. with:
  172. repository: 'obsproject/obs-studio'
  173. path: obs-studio
  174. fetch-depth: 0
  175. submodules: recursive
  176. - name: Setup Environment
  177. working-directory: ${{ github.workspace }}/plugin
  178. id: setup
  179. run: |
  180. ## SETUP ENVIRONMENT SCRIPT
  181. echo "::set-output name=ccacheDate::$(date +"%Y-%m-%d")"
  182. echo "::set-output name=commitHash::$(git rev-parse HEAD | cut -c1-9)"
  183. - name: Restore Compilation Cache
  184. id: ccache-cache
  185. uses: actions/cache@v2.1.7
  186. with:
  187. path: ${{ github.workspace }}/.ccache
  188. key: linux-${{ matrix.arch }}-ccache-plugin-${{ steps.setup.outputs.ccacheDate }}
  189. restore-keys: |
  190. linux-${{ matrix.arch }}-ccache-plugin-
  191. - name: Check for GitHub Labels
  192. id: seekingTesters
  193. if: ${{ github.event_name == 'pull_request' }}
  194. run: |
  195. ## GITHUB LABEL SCRIPT
  196. if [[ -n "$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s "${{ github.event.pull_request.url }}" | jq -e '.labels[] | select(.name == "Seeking Testers")')" ]]; then
  197. echo '::set-output name=found::true'
  198. else
  199. echo '::set-output name=found::false'
  200. fi
  201. - name: Build Plugin
  202. uses: ./plugin/.github/actions/build-plugin
  203. with:
  204. workingDirectory: ${{ github.workspace }}/plugin
  205. target: ${{ matrix.arch }}
  206. config: RelWithDebInfo
  207. - name: Package Plugin
  208. uses: ./plugin/.github/actions/package-plugin
  209. with:
  210. workingDirectory: ${{ github.workspace }}/plugin
  211. target: ${{ matrix.arch }}
  212. config: RelWithDebInfo
  213. - name: Upload Build Artifact
  214. if: ${{ success() && (github.event_name != 'pull_request' || steps.seekingTesters.outputs.found == 'true') }}
  215. uses: actions/upload-artifact@v3
  216. with:
  217. name: ${{ env.PLUGIN_NAME }}-linux-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}
  218. path: ${{ github.workspace }}/plugin/release/${{ env.PLUGIN_NAME }}-*-linux-${{ matrix.arch }}.*
  219. windows_build:
  220. name: 02 - Windows
  221. runs-on: windows-2022
  222. strategy:
  223. fail-fast: true
  224. matrix:
  225. arch: [x86, x64]
  226. if: always()
  227. needs: [clang_check]
  228. outputs:
  229. commitHash: ${{ steps.setup.outputs.commitHash }}
  230. defaults:
  231. run:
  232. shell: pwsh
  233. steps:
  234. - name: Checkout
  235. uses: actions/checkout@v3
  236. with:
  237. path: plugin
  238. submodules: recursive
  239. - name: Checkout obs-studio
  240. uses: actions/checkout@v3
  241. with:
  242. repository: 'obsproject/obs-studio'
  243. path: obs-studio
  244. fetch-depth: 0
  245. submodules: recursive
  246. - name: Setup Environment
  247. working-directory: ${{ github.workspace }}/plugin
  248. id: setup
  249. run: |
  250. ## SETUP ENVIRONMENT SCRIPT
  251. $CommitHash = (git rev-parse HEAD)[0..8] -join ''
  252. Write-Output "::set-output name=commitHash::${CommitHash}"
  253. - name: Check for GitHub Labels
  254. id: seekingTesters
  255. working-directory: ${{ github.workspace }}/plugin
  256. if: ${{ github.event_name == 'pull_request' }}
  257. run: |
  258. ## GITHUB LABEL SCRIPT
  259. $LabelFound = try {
  260. $Params = @{
  261. Authentication = 'Bearer'
  262. Token = (ConvertTo-SecureString '${{ secrets.GITHUB_TOKEN }}' -AsPlainText)
  263. Uri = '${{ github.event.pull_request.url }}'
  264. UseBasicParsing = $true
  265. }
  266. (Invoke-RestMethod @Params).labels.name.contains('Seeking Testers')
  267. } catch {
  268. $false
  269. }
  270. Write-Output "::set-output name=found::$(([string]${LabelFound}).ToLower())"
  271. - name: Build Plugin
  272. uses: ./plugin/.github/actions/build-plugin
  273. with:
  274. workingDirectory: ${{ github.workspace }}/plugin
  275. target: ${{ matrix.arch }}
  276. config: RelWithDebInfo
  277. visualStudio: 'Visual Studio 17 2022'
  278. - name: Package Plugin
  279. uses: ./plugin/.github/actions/package-plugin
  280. with:
  281. workingDirectory: ${{ github.workspace }}/plugin
  282. target: ${{ matrix.arch }}
  283. config: RelWithDebInfo
  284. - name: Upload Build Artifact
  285. if: ${{ success() && (github.event_name != 'pull_request' || steps.seekingTesters.outputs.found == 'true') }}
  286. uses: actions/upload-artifact@v3
  287. with:
  288. name: ${{ env.PLUGIN_NAME }}-windows-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}
  289. path: ${{ github.workspace }}/plugin/release/${{ env.PLUGIN_NAME }}-*.zip
  290. - name: Package Plugin Installer
  291. if: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' }}
  292. uses: ./plugin/.github/actions/package-plugin
  293. with:
  294. workingDirectory: ${{ github.workspace }}/plugin
  295. target: ${{ matrix.arch }}
  296. config: RelWithDebInfo
  297. createInstaller: true
  298. - name: Upload Installer Artifact
  299. if: ${{ startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request' }}
  300. uses: actions/upload-artifact@v3
  301. with:
  302. name: ${{ env.PLUGIN_NAME }}-windows-${{ matrix.arch }}-${{ steps.setup.outputs.commitHash }}-installer
  303. path: ${{ github.workspace }}/plugin/release/${{ env.PLUGIN_NAME }}-*.exe
  304. make-release:
  305. name: 03 - Create and upload release
  306. runs-on: ubuntu-22.04
  307. if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
  308. needs: [macos_build, linux_build, windows_build]
  309. defaults:
  310. run:
  311. shell: bash
  312. steps:
  313. - name: Get Metadata
  314. id: metadata
  315. run: |
  316. ## METADATA SCRIPT
  317. echo "::set-output name=version::${GITHUB_REF/refs\/tags\//}"
  318. echo "::set-output name=date::$(date +"%Y-%m-%d")"
  319. echo '::set-output name=commitHash::${{ needs.macos_build.outputs.commitHash }}'
  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: false
  336. tag_name: ${{ steps.metadata.outputs.version }}
  337. name: "${{ env.PLUGIN_NAME }} Build ${{ steps.metadata.outputs.version }}"
  338. body_path: ${{ github.workspace }}/CHECKSUMS.txt
  339. files: |
  340. ${{ github.workspace }}/${{ env.PLUGIN_NAME }}-windows-x64-${{ steps.metadata.outputs.commitHash }}/*.zip
  341. ${{ github.workspace }}/${{ env.PLUGIN_NAME }}-windows-x64-${{ steps.metadata.outputs.commitHash }}-installer/*.exe
  342. ${{ github.workspace }}/${{ env.PLUGIN_NAME }}-windows-x86-${{ steps.metadata.outputs.commitHash }}/*.zip
  343. ${{ github.workspace }}/${{ env.PLUGIN_NAME }}-windows-x86-${{ steps.metadata.outputs.commitHash }}-installer/*.exe
  344. ${{ github.workspace }}/${{ env.PLUGIN_NAME }}-linux-x86_64-${{ steps.metadata.outputs.commitHash }}/*.deb
  345. ${{ github.workspace }}/${{ env.PLUGIN_NAME }}-macos-x86_64-${{ steps.metadata.outputs.commitHash }}/*.pkg
  346. ${{ github.workspace }}/${{ env.PLUGIN_NAME }}-macos-arm64-${{ steps.metadata.outputs.commitHash }}/*.pkg
  347. ${{ github.workspace }}/${{ env.PLUGIN_NAME }}-macos-universal-${{ steps.metadata.outputs.commitHash }}/*.pkg