build-project.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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-14
  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::Enable Xcode 15.2'
  87. sudo xcode-select --switch /Applications/Xcode_15.2.app/Contents/Developer
  88. print '::endgroup::'
  89. print '::group::Clean Homebrew Environment'
  90. local -a to_remove=()
  91. if (( #to_remove )) brew uninstall --ignore-dependencies ${to_remove}
  92. print '::endgroup::'
  93. local product_name
  94. local product_version
  95. read -r product_name product_version <<< \
  96. "$(jq -r '. | {name, version} | join(" ")' buildspec.json)"
  97. print "pluginName=${product_name}" >> $GITHUB_OUTPUT
  98. print "pluginVersion=${product_version}" >> $GITHUB_OUTPUT
  99. - uses: actions/cache@v4
  100. id: ccache-cache
  101. with:
  102. path: ${{ github.workspace }}/.ccache
  103. key: ${{ runner.os }}-ccache-${{ needs.check-event.outputs.config }}
  104. restore-keys: |
  105. ${{ runner.os }}-ccache-
  106. - name: Set Up Codesigning 🔑
  107. uses: ./.github/actions/setup-macos-codesigning
  108. if: fromJSON(needs.check-event.outputs.codesign)
  109. id: codesign
  110. with:
  111. codesignIdentity: ${{ secrets.MACOS_SIGNING_APPLICATION_IDENTITY }}
  112. installerIdentity: ${{ secrets.MACOS_SIGNING_INSTALLER_IDENTITY }}
  113. codesignCertificate: ${{ secrets.MACOS_SIGNING_CERT }}
  114. certificatePassword: ${{ secrets.MACOS_SIGNING_CERT_PASSWORD }}
  115. keychainPassword: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
  116. provisioningProfile: ${{ secrets.MACOS_SIGNING_PROVISIONING_PROFILE }}
  117. notarizationUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
  118. notarizationPassword: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
  119. - name: Build Plugin 🧱
  120. uses: ./.github/actions/build-plugin
  121. with:
  122. target: macos-universal
  123. config: ${{ needs.check-event.outputs.config }}
  124. codesign: ${{ fromJSON(needs.check-event.outputs.codesign) }}
  125. codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
  126. - name: Package Plugin 📀
  127. uses: ./.github/actions/package-plugin
  128. with:
  129. target: macos-universal
  130. config: ${{ needs.check-event.outputs.config }}
  131. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  132. codesign: ${{ fromJSON(needs.check-event.outputs.codesign) && fromJSON(steps.codesign.outputs.haveCodesignIdent) }}
  133. codesignIdent: ${{ steps.codesign.outputs.codesignIdent }}
  134. installerIdent: ${{ steps.codesign.outputs.installerIdent }}
  135. codesignTeam: ${{ steps.codesign.outputs.codesignTeam }}
  136. notarize: ${{ fromJSON(needs.check-event.outputs.notarize) && fromJSON(steps.codesign.outputs.haveNotarizationUser) }}
  137. codesignUser: ${{ secrets.MACOS_NOTARIZATION_USERNAME }}
  138. codesignPass: ${{ secrets.MACOS_NOTARIZATION_PASSWORD }}
  139. - name: Upload Artifacts 📡
  140. uses: actions/upload-artifact@v4
  141. with:
  142. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}
  143. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal.*
  144. - name: Upload Debug Symbol Artifacts 🪲
  145. uses: actions/upload-artifact@v4
  146. if: ${{ needs.check-event.outputs.config == 'Release' }}
  147. with:
  148. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-${{ needs.check-event.outputs.commitHash }}-dSYMs
  149. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-macos-universal-dSYMs.*
  150. ubuntu-build:
  151. name: Build for Ubuntu 🐧
  152. runs-on: ubuntu-22.04
  153. needs: check-event
  154. defaults:
  155. run:
  156. shell: bash
  157. steps:
  158. - uses: actions/checkout@v4
  159. with:
  160. submodules: recursive
  161. fetch-depth: 0
  162. - name: Set Up Environment 🔧
  163. id: setup
  164. run: |
  165. : Set Up Environment 🔧
  166. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  167. read -r product_name product_version <<< \
  168. "$(jq -r '. | {name, version} | join(" ")' buildspec.json)"
  169. echo "pluginName=${product_name}" >> $GITHUB_OUTPUT
  170. echo "pluginVersion=${product_version}" >> $GITHUB_OUTPUT
  171. - uses: actions/cache@v4
  172. id: ccache-cache
  173. with:
  174. path: ${{ github.workspace }}/.ccache
  175. key: ${{ runner.os }}-ccache-x86_64-${{ needs.check-event.outputs.config }}
  176. restore-keys: |
  177. ${{ runner.os }}-ccache-x86_64-
  178. - name: Set up Homebrew 🍺
  179. uses: Homebrew/actions/setup-homebrew@master
  180. - name: Build Plugin 🧱
  181. uses: ./.github/actions/build-plugin
  182. with:
  183. target: x86_64
  184. config: ${{ needs.check-event.outputs.config }}
  185. - name: Package Plugin 📀
  186. uses: ./.github/actions/package-plugin
  187. with:
  188. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  189. target: x86_64
  190. config: ${{ needs.check-event.outputs.config }}
  191. - name: Upload Source Tarball 🗜️
  192. uses: actions/upload-artifact@v4
  193. with:
  194. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }}
  195. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-source.*
  196. - name: Upload Artifacts 📡
  197. uses: actions/upload-artifact@v4
  198. with:
  199. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}
  200. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-x86_64*.*
  201. - name: Upload debug symbol artifacts 🪲
  202. uses: actions/upload-artifact@v4
  203. if: ${{ fromJSON(needs.check-event.outputs.package) }}
  204. with:
  205. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-ubuntu-22.04-x86_64-${{ needs.check-event.outputs.commitHash }}-dbgsym
  206. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-x86_64*-dbgsym.ddeb
  207. windows-build:
  208. name: Build for Windows 🪟
  209. runs-on: windows-2022
  210. needs: check-event
  211. defaults:
  212. run:
  213. shell: pwsh
  214. steps:
  215. - uses: actions/checkout@v4
  216. with:
  217. submodules: recursive
  218. fetch-depth: 0
  219. - name: Set Up Environment 🔧
  220. id: setup
  221. run: |
  222. # Set Up Environment 🔧
  223. if ( $Env:RUNNER_DEBUG -ne $null ) {
  224. Set-PSDebug -Trace 1
  225. }
  226. $BuildSpec = Get-Content -Path buildspec.json -Raw | ConvertFrom-Json
  227. $ProductName = $BuildSpec.name
  228. $ProductVersion = $BuildSpec.version
  229. "pluginName=${ProductName}" >> $env:GITHUB_OUTPUT
  230. "pluginVersion=${ProductVersion}" >> $env:GITHUB_OUTPUT
  231. - name: Build Plugin 🧱
  232. uses: ./.github/actions/build-plugin
  233. with:
  234. target: x64
  235. config: ${{ needs.check-event.outputs.config }}
  236. - name: Package Plugin 📀
  237. uses: ./.github/actions/package-plugin
  238. with:
  239. target: x64
  240. config: ${{ needs.check-event.outputs.config }}
  241. package: ${{ fromJSON(needs.check-event.outputs.package) }}
  242. - name: Upload Artifacts 📡
  243. uses: actions/upload-artifact@v4
  244. with:
  245. name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64-${{ needs.check-event.outputs.commitHash }}
  246. path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-windows-x64*.*