build-project.yaml 11 KB

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