pipeline-segment-electron-build.yml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. name: Pipeline Segment - Electron Build
  2. on:
  3. workflow_call:
  4. inputs:
  5. environment:
  6. description: using the production or testing environment
  7. required: false
  8. type: string
  9. target-platform:
  10. type: string
  11. description: 'Platform to run on, can be macos, win or linux'
  12. required: true
  13. target-arch:
  14. type: string
  15. description: 'Arch to build for, can be x64, arm64, ia32 or arm'
  16. required: true
  17. target-variant:
  18. type: string
  19. description: 'Variant to build for, no effect on non-macOS target platforms. Can be darwin, mas or all.'
  20. default: all
  21. build-runs-on:
  22. type: string
  23. description: 'What host to run the build'
  24. required: true
  25. build-container:
  26. type: string
  27. description: 'JSON container information for aks runs-on'
  28. required: false
  29. default: '{"image":null}'
  30. is-release:
  31. description: 'Whether this build job is a release job'
  32. required: true
  33. type: boolean
  34. default: false
  35. gn-build-type:
  36. description: 'The gn build type - testing or release'
  37. required: true
  38. type: string
  39. default: testing
  40. generate-symbols:
  41. description: 'Whether or not to generate symbols'
  42. required: true
  43. type: boolean
  44. default: false
  45. upload-to-storage:
  46. description: 'Whether or not to upload build artifacts to external storage'
  47. required: true
  48. type: string
  49. default: '0'
  50. strip-binaries:
  51. description: 'Strip the binaries before release (Linux only)'
  52. required: false
  53. type: boolean
  54. default: false
  55. is-asan:
  56. description: 'Building the Address Sanitizer (ASan) Linux build'
  57. required: false
  58. type: boolean
  59. default: false
  60. concurrency:
  61. group: electron-build-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ inputs.target-variant }}-${{ inputs.is-asan }}-${{ github.ref_protected == true && github.run_id || github.ref }}
  62. cancel-in-progress: ${{ github.ref_protected != true }}
  63. env:
  64. CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
  65. CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
  66. ELECTRON_ARTIFACTS_BLOB_STORAGE: ${{ secrets.ELECTRON_ARTIFACTS_BLOB_STORAGE }}
  67. ELECTRON_RBE_JWT: ${{ secrets.ELECTRON_RBE_JWT }}
  68. SUDOWOODO_EXCHANGE_URL: ${{ secrets.SUDOWOODO_EXCHANGE_URL }}
  69. SUDOWOODO_EXCHANGE_TOKEN: ${{ secrets.SUDOWOODO_EXCHANGE_TOKEN }}
  70. GCLIENT_EXTRA_ARGS: ${{ inputs.target-platform == 'macos' && '--custom-var=checkout_mac=True --custom-var=host_os=mac' || inputs.target-platform == 'win' && '--custom-var=checkout_win=True' || '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True' }}
  71. ELECTRON_OUT_DIR: Default
  72. jobs:
  73. build:
  74. defaults:
  75. run:
  76. shell: bash
  77. runs-on: ${{ inputs.build-runs-on }}
  78. container: ${{ fromJSON(inputs.build-container) }}
  79. environment: ${{ inputs.environment }}
  80. env:
  81. TARGET_ARCH: ${{ inputs.target-arch }}
  82. steps:
  83. - name: Create src dir
  84. run: |
  85. mkdir src
  86. - name: Checkout Electron
  87. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
  88. with:
  89. path: src/electron
  90. fetch-depth: 0
  91. ref: ${{ github.event.pull_request.head.sha }}
  92. - name: Free up space (macOS)
  93. if: ${{ inputs.target-platform == 'macos' }}
  94. uses: ./src/electron/.github/actions/free-space-macos
  95. - name: Check disk space after freeing up space
  96. if: ${{ inputs.target-platform == 'macos' }}
  97. run: df -h
  98. - name: Setup Node.js/npm
  99. if: ${{ inputs.target-platform == 'macos' }}
  100. uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
  101. with:
  102. node-version: 20.11.x
  103. cache: yarn
  104. cache-dependency-path: src/electron/yarn.lock
  105. - name: Install Dependencies
  106. uses: ./src/electron/.github/actions/install-dependencies
  107. - name: Install AZCopy
  108. if: ${{ inputs.target-platform == 'macos' }}
  109. run: brew install azcopy
  110. - name: Set GN_EXTRA_ARGS for Linux
  111. if: ${{ inputs.target-platform == 'linux' }}
  112. run: |
  113. if [ "${{ inputs.target-arch }}" = "arm" ]; then
  114. if [ "${{ inputs.is-release }}" = true ]; then
  115. GN_EXTRA_ARGS='target_cpu="arm" build_tflite_with_xnnpack=false symbol_level=1'
  116. else
  117. GN_EXTRA_ARGS='target_cpu="arm" build_tflite_with_xnnpack=false'
  118. fi
  119. elif [ "${{ inputs.target-arch }}" = "arm64" ]; then
  120. GN_EXTRA_ARGS='target_cpu="arm64" fatal_linker_warnings=false enable_linux_installer=false'
  121. elif [ "${{ inputs.is-asan }}" = true ]; then
  122. GN_EXTRA_ARGS='is_asan=true'
  123. fi
  124. echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
  125. - name: Set Chromium Git Cookie
  126. uses: ./src/electron/.github/actions/set-chromium-cookie
  127. - name: Install Build Tools
  128. uses: ./src/electron/.github/actions/install-build-tools
  129. - name: Generate DEPS Hash
  130. run: |
  131. node src/electron/script/generate-deps-hash.js
  132. DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)
  133. echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
  134. echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
  135. - name: Restore src cache via AZCopy
  136. if: ${{ inputs.target-platform != 'linux' }}
  137. uses: ./src/electron/.github/actions/restore-cache-azcopy
  138. with:
  139. target-platform: ${{ inputs.target-platform }}
  140. - name: Restore src cache via AKS
  141. if: ${{ inputs.target-platform == 'linux' }}
  142. uses: ./src/electron/.github/actions/restore-cache-aks
  143. - name: Checkout Electron
  144. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
  145. with:
  146. path: src/electron
  147. fetch-depth: 0
  148. ref: ${{ github.event.pull_request.head.sha }}
  149. - name: Fix Sync
  150. if: ${{ inputs.target-platform != 'linux' }}
  151. uses: ./src/electron/.github/actions/fix-sync
  152. with:
  153. target-platform: ${{ inputs.target-platform }}
  154. env:
  155. ELECTRON_DEPOT_TOOLS_DISABLE_LOG: true
  156. - name: Init Build Tools
  157. run: |
  158. e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
  159. - name: Run Electron Only Hooks
  160. run: |
  161. e d gclient runhooks --spec="solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]"
  162. - name: Regenerate DEPS Hash
  163. run: |
  164. (cd src/electron && git checkout .) && node src/electron/script/generate-deps-hash.js
  165. echo "DEPSHASH=$(cat src/electron/.depshash)" >> $GITHUB_ENV
  166. - name: Add CHROMIUM_BUILDTOOLS_PATH to env
  167. run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
  168. - name: Setup Number of Ninja Processes
  169. run: |
  170. echo "NUMBER_OF_NINJA_PROCESSES=${{ inputs.target-platform != 'macos' && '300' || '200' }}" >> $GITHUB_ENV
  171. - name: Free up space (macOS)
  172. if: ${{ inputs.target-platform == 'macos' }}
  173. uses: ./src/electron/.github/actions/free-space-macos
  174. - name: Build Electron
  175. if: ${{ inputs.target-platform != 'macos' || (inputs.target-variant == 'all' || inputs.target-variant == 'darwin') }}
  176. uses: ./src/electron/.github/actions/build-electron
  177. with:
  178. target-arch: ${{ inputs.target-arch }}
  179. target-platform: ${{ inputs.target-platform }}
  180. artifact-platform: ${{ inputs.target-platform == 'macos' && 'darwin' || inputs.target-platform }}
  181. is-release: '${{ inputs.is-release }}'
  182. generate-symbols: '${{ inputs.generate-symbols }}'
  183. strip-binaries: '${{ inputs.strip-binaries }}'
  184. upload-to-storage: '${{ inputs.upload-to-storage }}'
  185. is-asan: '${{ inputs.is-asan }}'
  186. - name: Set GN_EXTRA_ARGS for MAS Build
  187. if: ${{ inputs.target-platform == 'macos' && (inputs.target-variant == 'all' || inputs.target-variant == 'mas') }}
  188. run: |
  189. echo "MAS_BUILD=true" >> $GITHUB_ENV
  190. GN_EXTRA_ARGS='is_mas_build=true'
  191. echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
  192. - name: Build Electron (MAS)
  193. if: ${{ inputs.target-platform == 'macos' && (inputs.target-variant == 'all' || inputs.target-variant == 'mas') }}
  194. uses: ./src/electron/.github/actions/build-electron
  195. with:
  196. target-arch: ${{ inputs.target-arch }}
  197. target-platform: ${{ inputs.target-platform }}
  198. artifact-platform: 'mas'
  199. is-release: '${{ inputs.is-release }}'
  200. generate-symbols: '${{ inputs.generate-symbols }}'
  201. upload-to-storage: '${{ inputs.upload-to-storage }}'
  202. step-suffix: '(mas)'