main.yml 14 KB

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