build-project.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. name: Build Project
  2. on:
  3. workflow_call:
  4. jobs:
  5. check-event:
  6. name: Check GitHub Event Data 📡
  7. runs-on: ubuntu-22.04
  8. defaults:
  9. run:
  10. shell: bash
  11. outputs:
  12. package: ${{ steps.setup.outputs.package }}
  13. codesign: ${{ steps.setup.outputs.codesign }}
  14. notarize: ${{ steps.setup.outputs.notarize }}
  15. config: ${{ steps.setup.outputs.config }}
  16. commitHash: ${{ steps.setup.outputs.commitHash }}
  17. steps:
  18. - uses: actions/checkout@v3
  19. with:
  20. fetch-depth: 0
  21. - name: Check Event Data ☑️
  22. id: setup
  23. env:
  24. GH_TOKEN: ${{ github.token }}
  25. run: |
  26. : Check Event Data ☑️
  27. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  28. case "${GITHUB_EVENT_NAME}" in
  29. pull_request)
  30. config_data=('codesign:false' 'notarize:false' 'package:false' 'config:RelWithDebInfo')
  31. if gh pr view --json labels \
  32. | jq -e -r '.labels[] | select(.name == "Seeking Testers")' > /dev/null; then
  33. config_data[0]='codesign:true'
  34. config_data[2]='package:true'
  35. fi
  36. ;;
  37. push)
  38. config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo')
  39. if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then
  40. config_data[1]='notarize:true'
  41. config_data[3]='config:Release'
  42. fi
  43. ;;
  44. workflow_dispatch)
  45. config_data=('codesign:true' 'notarize:false' 'package:false' 'config:RelWithDebInfo')
  46. ;;
  47. schedule)
  48. config_data=('codesign:true' 'notarize:false' 'package:true' 'config:RelWithDebInfo')
  49. ;;
  50. *) ;;
  51. esac
  52. for config in "${config_data[@]}"; do
  53. IFS=':' read -r key value <<< "${config}"
  54. echo "${key}=${value}" >> $GITHUB_OUTPUT
  55. done
  56. echo "commitHash=${GITHUB_SHA:0:9}" >> $GITHUB_OUTPUT
  57. macos-build:
  58. name: Build for macOS 🍏
  59. runs-on: macos-13
  60. needs: check-event
  61. defaults:
  62. run:
  63. shell: zsh --no-rcs --errexit --pipefail {0}
  64. steps:
  65. - uses: actions/checkout@v3
  66. with:
  67. submodules: recursive
  68. fetch-depth: 0
  69. - name: Set Up Environment 🔧
  70. id: setup
  71. run: |
  72. : Set Up Environment 🔧
  73. if (( ${+RUNNER_DEBUG} )) setopt XTRACE
  74. print '::group::Clean Homebrew Environment'
  75. typeset -a to_remove=()
  76. if (( #to_remove > 0 )) brew uninstall --ignore-dependencies ${to_remove}
  77. print '::endgroup::'
  78. local product_name
  79. local product_version
  80. read -r product_name product_version <<< \
  81. "$(jq -r '. | {name, version} | join(" ")' buildspec.json)"
  82. print "pluginName=${product_name}" >> $GITHUB_OUTPUT
  83. print "pluginVersion=${product_version}" >> $GITHUB_OUTPUT
  84. - uses: actions/cache@v3
  85. id: ccache-cache
  86. with:
  87. path: ${{ github.workspace }}/.ccache
  88. key: ${{ runner.os }}-ccache-${{ needs.check-event.outputs.config }}
  89. restore-keys: |
  90. ${{ runner.os }}-ccache-
  91. - name: Set Up Codesigning 🔑
  92. uses: ./.github/actions/setup-macos-codesigning
  93. if: ${{ fromJSON(needs.check-event.outputs.codesign) }}
  94. id: codesign
  95. with:
  96. codesignIdentity: ${{ secrets.MACOS_SIGNING_APPLICATION_IDENTITY }}
  97. installerIdentity: ${{ secrets.MACOS_SIGNING_INSTALLER_IDENTITY }}
  98. codesignCertificate: ${{ secrets.MACOS_SIGNING_CERT }}
  99. certificatePassword: ${{ secrets.MACOS_SIGNING_CERT_PASSWORD }}
  100. keychainPassword: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  101. provisioningProfile: ${{ secrets.MACOS_SIGNING_PROVISIONING_PROFILE }}
  102. notarizationUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
  103. notarizationPassword: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
  104. - name: Build Plugin 🧱
  105. uses: ./.github/actions/build-plugin
  106. with:
  107. target: macos-universal
  108. config: ${{ needs.check-event.outputs.config }}
  109. codesign: ${{ fromJSON(needs.check-event.outputs.codesign) }}
  110. codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
  111. - name: Package Plugin 📀
  112. uses: ./.github/actions/package-plugin
  113. with:
  114. target: macos-universal
  115. config: ${{ needs.check-event.outputs.config }}
  116. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  117. codesign: ${{ fromJSON(needs.check-event.outputs.codesign) && fromJSON(steps.codesign.outputs.haveCodesignIdent) }}
  118. codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
  119. installerIdent: ${{ steps.codesign.outputs.installerIdent }}
  120. notarize: ${{ fromJSON(needs.check-event.outputs.notarize) && fromJSON(steps.codesign.outputs.haveNotarizationUser) }}
  121. codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
  122. codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
  123. - name: Upload Artifacts 📡
  124. uses: actions/upload-artifact@v3
  125. with:
  126. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}
  127. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal.*
  128. - name: Upload Debug Symbol Artifacts 🪲
  129. uses: actions/upload-artifact@v3
  130. if: ${{ needs.check-event.outputs.config == 'Release' }}
  131. with:
  132. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-dSYMs
  133. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-dSYMs.*
  134. ubuntu-build:
  135. name: Build for Ubuntu 🐧
  136. runs-on: ubuntu-22.04
  137. needs: check-event
  138. defaults:
  139. run:
  140. shell: bash
  141. steps:
  142. - uses: actions/checkout@v3
  143. with:
  144. submodules: recursive
  145. fetch-depth: 0
  146. - name: Set Up Environment 🔧
  147. id: setup
  148. run: |
  149. : Set Up Environment 🔧
  150. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  151. read -r product_name product_version <<< \
  152. "$(jq -r '. | {name, version} | join(" ")' buildspec.json)"
  153. echo "pluginName=${product_name}" >> $GITHUB_OUTPUT
  154. echo "pluginVersion=${product_version}" >> $GITHUB_OUTPUT
  155. - uses: actions/cache@v3
  156. id: ccache-cache
  157. with:
  158. path: ${{ github.workspace }}/.ccache
  159. key: ${{ runner.os }}-ccache-x86_64-${{ needs.check-event.outputs.config }}
  160. restore-keys: |
  161. ${{ runner.os }}-ccache-x86_64-
  162. - name: Set up Homebrew 🍺
  163. uses: Homebrew/actions/setup-homebrew@master
  164. - name: Build Plugin 🧱
  165. uses: ./.github/actions/build-plugin
  166. with:
  167. target: x86_64
  168. config: ${{ needs.check-event.outputs.config }}
  169. - name: Package Plugin 📀
  170. uses: ./.github/actions/package-plugin
  171. with:
  172. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  173. target: x86_64
  174. config: ${{ needs.check-event.outputs.config }}
  175. - name: Upload Source Tarball 🗜️
  176. uses: actions/upload-artifact@v3
  177. with:
  178. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }}
  179. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-source.*
  180. - name: Upload Artifacts 📡
  181. uses: actions/upload-artifact@v3
  182. with:
  183. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}
  184. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-x86_64*.*
  185. - name: Upload debug symbol artifacts 🪲
  186. uses: actions/upload-artifact@v3
  187. if: ${{ fromJSON(needs.check-event.outputs.package) }}
  188. with:
  189. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym
  190. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-x86_64*-dbgsym.ddeb
  191. windows-build:
  192. name: Build for Windows 🪟
  193. runs-on: windows-2022
  194. needs: check-event
  195. defaults:
  196. run:
  197. shell: pwsh
  198. steps:
  199. - uses: actions/checkout@v3
  200. with:
  201. submodules: recursive
  202. fetch-depth: 0
  203. - name: Set Up Environment 🔧
  204. id: setup
  205. run: |
  206. # Set Up Environment 🔧
  207. if ( $Env:RUNNER_DEBUG -ne $null ) {
  208. Set-PSDebug -Trace 1
  209. }
  210. $BuildSpec = Get-Content -Path buildspec.json -Raw | ConvertFrom-Json
  211. $ProductName = $BuildSpec.name
  212. $ProductVersion = $BuildSpec.version
  213. "pluginName=${ProductName}" >> $env:GITHUB_OUTPUT
  214. "pluginVersion=${ProductVersion}" >> $env:GITHUB_OUTPUT
  215. - name: Build Plugin 🧱
  216. uses: ./.github/actions/build-plugin
  217. with:
  218. target: x64
  219. config: ${{ needs.check-event.outputs.config }}
  220. - name: Package Plugin 📀
  221. uses: ./.github/actions/package-plugin
  222. with:
  223. target: x64
  224. config: ${{ needs.check-event.outputs.config }}
  225. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  226. - name: Upload Artifacts 📡
  227. uses: actions/upload-artifact@v3
  228. with:
  229. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ needs.check-event.outputs.commitHash }}
  230. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64*.*