build-project.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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 ${{ github.event.number }} --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. local -a to_remove=()
  76. if (( #to_remove )) 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. codesignTeam: ${{ steps.codesign.outputs.codesignTeam }}
  121. notarize: ${{ fromJSON(needs.check-event.outputs.notarize) && fromJSON(steps.codesign.outputs.haveNotarizationUser) }}
  122. codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
  123. codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
  124. - name: Upload Artifacts 📡
  125. uses: actions/upload-artifact@v3
  126. with:
  127. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}
  128. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal.*
  129. - name: Upload Debug Symbol Artifacts 🪲
  130. uses: actions/upload-artifact@v3
  131. if: ${{ needs.check-event.outputs.config == 'Release' }}
  132. with:
  133. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-dSYMs
  134. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-dSYMs.*
  135. ubuntu-build:
  136. name: Build for Ubuntu 🐧
  137. runs-on: ubuntu-22.04
  138. needs: check-event
  139. defaults:
  140. run:
  141. shell: bash
  142. steps:
  143. - uses: actions/checkout@v3
  144. with:
  145. submodules: recursive
  146. fetch-depth: 0
  147. - name: Set Up Environment 🔧
  148. id: setup
  149. run: |
  150. : Set Up Environment 🔧
  151. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  152. read -r product_name product_version <<< \
  153. "$(jq -r '. | {name, version} | join(" ")' buildspec.json)"
  154. echo "pluginName=${product_name}" >> $GITHUB_OUTPUT
  155. echo "pluginVersion=${product_version}" >> $GITHUB_OUTPUT
  156. - uses: actions/cache@v3
  157. id: ccache-cache
  158. with:
  159. path: ${{ github.workspace }}/.ccache
  160. key: ${{ runner.os }}-ccache-x86_64-${{ needs.check-event.outputs.config }}
  161. restore-keys: |
  162. ${{ runner.os }}-ccache-x86_64-
  163. - name: Set up Homebrew 🍺
  164. uses: Homebrew/actions/setup-homebrew@master
  165. - name: Build Plugin 🧱
  166. uses: ./.github/actions/build-plugin
  167. with:
  168. target: x86_64
  169. config: ${{ needs.check-event.outputs.config }}
  170. - name: Package Plugin 📀
  171. uses: ./.github/actions/package-plugin
  172. with:
  173. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  174. target: x86_64
  175. config: ${{ needs.check-event.outputs.config }}
  176. - name: Upload Source Tarball 🗜️
  177. uses: actions/upload-artifact@v3
  178. with:
  179. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }}
  180. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-source.*
  181. - name: Upload Artifacts 📡
  182. uses: actions/upload-artifact@v3
  183. with:
  184. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}
  185. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-x86_64*.*
  186. - name: Upload debug symbol artifacts 🪲
  187. uses: actions/upload-artifact@v3
  188. if: ${{ fromJSON(needs.check-event.outputs.package) }}
  189. with:
  190. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym
  191. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-x86_64*-dbgsym.ddeb
  192. windows-build:
  193. name: Build for Windows 🪟
  194. runs-on: windows-2022
  195. needs: check-event
  196. defaults:
  197. run:
  198. shell: pwsh
  199. steps:
  200. - uses: actions/checkout@v3
  201. with:
  202. submodules: recursive
  203. fetch-depth: 0
  204. - name: Set Up Environment 🔧
  205. id: setup
  206. run: |
  207. # Set Up Environment 🔧
  208. if ( $Env:RUNNER_DEBUG -ne $null ) {
  209. Set-PSDebug -Trace 1
  210. }
  211. $BuildSpec = Get-Content -Path buildspec.json -Raw | ConvertFrom-Json
  212. $ProductName = $BuildSpec.name
  213. $ProductVersion = $BuildSpec.version
  214. "pluginName=${ProductName}" >> $env:GITHUB_OUTPUT
  215. "pluginVersion=${ProductVersion}" >> $env:GITHUB_OUTPUT
  216. - name: Build Plugin 🧱
  217. uses: ./.github/actions/build-plugin
  218. with:
  219. target: x64
  220. config: ${{ needs.check-event.outputs.config }}
  221. - name: Package Plugin 📀
  222. uses: ./.github/actions/package-plugin
  223. with:
  224. target: x64
  225. config: ${{ needs.check-event.outputs.config }}
  226. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  227. - name: Upload Artifacts 📡
  228. uses: actions/upload-artifact@v3
  229. with:
  230. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ needs.check-event.outputs.commitHash }}
  231. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64*.*