main.yml 14 KB

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