build-project.yaml 12 KB

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