main.yml 14 KB

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