action.yml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. name: 'Build Electron'
  2. description: 'Builds Electron & Friends'
  3. inputs:
  4. target-arch:
  5. description: 'Target arch'
  6. required: true
  7. target-platform:
  8. description: 'Target platform, should be linux, win, macos'
  9. required: true
  10. artifact-platform:
  11. description: 'Artifact platform, should be linux, win, darwin or mas'
  12. required: true
  13. step-suffix:
  14. description: 'Suffix for build steps'
  15. required: false
  16. default: ''
  17. is-release:
  18. description: 'Is release build'
  19. required: true
  20. strip-binaries:
  21. description: 'Strip binaries (Linux only)'
  22. required: false
  23. generate-symbols:
  24. description: 'Generate symbols'
  25. required: true
  26. upload-to-storage:
  27. description: 'Upload to storage'
  28. required: true
  29. is-asan:
  30. description: 'The ASan Linux build'
  31. required: false
  32. runs:
  33. using: "composite"
  34. steps:
  35. - name: Set GN_EXTRA_ARGS for MacOS x64 Builds
  36. shell: bash
  37. if: ${{ inputs.target-arch == 'x64' && inputs.target-platform == 'macos' }}
  38. run: |
  39. GN_APPENDED_ARGS="$GN_EXTRA_ARGS target_cpu=\"x64\" v8_snapshot_toolchain=\"//build/toolchain/mac:clang_x64\""
  40. echo "GN_EXTRA_ARGS=$GN_APPENDED_ARGS" >> $GITHUB_ENV
  41. - name: Build Electron ${{ inputs.step-suffix }}
  42. shell: bash
  43. run: |
  44. rm -rf "src/out/Default/Electron Framework.framework"
  45. rm -rf src/out/Default/Electron*.app
  46. cd src/electron
  47. # TODO(codebytere): remove this once we figure out why .git/packed-refs is initially missing
  48. git pack-refs
  49. cd ..
  50. if [ "`uname`" = "Darwin" ]; then
  51. ulimit -n 10000
  52. sudo launchctl limit maxfiles 65536 200000
  53. fi
  54. NINJA_SUMMARIZE_BUILD=1 e build -j $NUMBER_OF_NINJA_PROCESSES
  55. cp out/Default/.ninja_log out/electron_ninja_log
  56. node electron/script/check-symlinks.js
  57. - name: Strip Electron Binaries ${{ inputs.step-suffix }}
  58. shell: bash
  59. if: ${{ inputs.strip-binaries == 'true' }}
  60. run: |
  61. cd src
  62. electron/script/copy-debug-symbols.py --target-cpu="${{ inputs.target-arch }}" --out-dir=out/Default/debug --compress
  63. electron/script/strip-binaries.py --target-cpu="${{ inputs.target-arch }}" --verbose
  64. electron/script/add-debug-link.py --target-cpu="${{ inputs.target-arch }}" --debug-dir=out/Default/debug
  65. - name: Build Electron dist.zip ${{ inputs.step-suffix }}
  66. shell: bash
  67. run: |
  68. cd src
  69. e build --target electron:electron_dist_zip -j $NUMBER_OF_NINJA_PROCESSES
  70. if [ "${{ inputs.is-asan }}" != "true" ]; then
  71. target_os=${{ inputs.target-platform == 'macos' && 'mac' || inputs.target-platform }}
  72. if [ "${{ inputs.artifact-platform }}" = "mas" ]; then
  73. target_os="${target_os}_mas"
  74. fi
  75. electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.$target_os.${{ inputs.target-arch }}.manifest
  76. fi
  77. - name: Build Mksnapshot ${{ inputs.step-suffix }}
  78. shell: bash
  79. run: |
  80. cd src
  81. e build --target electron:electron_mksnapshot -j $NUMBER_OF_NINJA_PROCESSES
  82. ELECTRON_DEPOT_TOOLS_DISABLE_LOG=1 e d gn desc out/Default v8:run_mksnapshot_default args > out/Default/mksnapshot_args
  83. # Remove unused args from mksnapshot_args
  84. SEDOPTION="-i"
  85. if [ "`uname`" = "Darwin" ]; then
  86. SEDOPTION="-i ''"
  87. fi
  88. sed $SEDOPTION '/.*builtins-pgo/d' out/Default/mksnapshot_args
  89. sed $SEDOPTION '/--turbo-profiling-input/d' out/Default/mksnapshot_args
  90. if [ "${{ inputs.target-platform }}" = "linux" ]; then
  91. if [ "${{ inputs.target-arch }}" = "arm" ]; then
  92. electron/script/strip-binaries.py --file $PWD/out/Default/clang_x86_v8_arm/mksnapshot
  93. electron/script/strip-binaries.py --file $PWD/out/Default/clang_x86_v8_arm/v8_context_snapshot_generator
  94. elif [ "${{ inputs.target-arch }}" = "arm64" ]; then
  95. electron/script/strip-binaries.py --file $PWD/out/Default/clang_x64_v8_arm64/mksnapshot
  96. electron/script/strip-binaries.py --file $PWD/out/Default/clang_x64_v8_arm64/v8_context_snapshot_generator
  97. else
  98. electron/script/strip-binaries.py --file $PWD/out/Default/mksnapshot
  99. electron/script/strip-binaries.py --file $PWD/out/Default/v8_context_snapshot_generator
  100. fi
  101. fi
  102. e build --target electron:electron_mksnapshot_zip -j $NUMBER_OF_NINJA_PROCESSES
  103. if [ "${{ inputs.target-platform }}" = "win" ]; then
  104. cd out/Default
  105. powershell Compress-Archive -update mksnapshot_args mksnapshot.zip
  106. powershell Compress-Archive -update gen/v8/embedded.S mksnapshot.zip
  107. else
  108. (cd out/Default; zip mksnapshot.zip mksnapshot_args gen/v8/embedded.S)
  109. fi
  110. - name: Generate Cross-Arch Snapshot (arm/arm64) ${{ inputs.step-suffix }}
  111. shell: bash
  112. if: ${{ (inputs.target-arch == 'arm' || inputs.target-arch == 'arm64') && inputs.target-platform == 'linux' }}
  113. run: |
  114. cd src
  115. if [ "${{ inputs.target-arch }}" = "arm" ]; then
  116. MKSNAPSHOT_PATH="clang_x86_v8_arm"
  117. elif [ "${{ inputs.target-arch }}" = "arm64" ]; then
  118. MKSNAPSHOT_PATH="clang_x64_v8_arm64"
  119. fi
  120. cp "out/Default/$MKSNAPSHOT_PATH/mksnapshot" out/Default
  121. cp "out/Default/$MKSNAPSHOT_PATH/v8_context_snapshot_generator" out/Default
  122. cp "out/Default/$MKSNAPSHOT_PATH/libffmpeg.so" out/Default
  123. python3 electron/script/verify-mksnapshot.py --source-root "$PWD" --build-dir out/Default --create-snapshot-only
  124. mkdir cross-arch-snapshots
  125. cp out/Default-mksnapshot-test/*.bin cross-arch-snapshots
  126. # Clean up so that ninja does not get confused
  127. rm -f out/Default/libffmpeg.so
  128. - name: Build Chromedriver ${{ inputs.step-suffix }}
  129. shell: bash
  130. run: |
  131. cd src
  132. e build --target electron:electron_chromedriver -j $NUMBER_OF_NINJA_PROCESSES
  133. e build --target electron:electron_chromedriver_zip
  134. - name: Build Node.js headers ${{ inputs.step-suffix }}
  135. shell: bash
  136. run: |
  137. cd src
  138. e build --target electron:node_headers
  139. - name: Generate & Zip Symbols ${{ inputs.step-suffix }}
  140. shell: bash
  141. run: |
  142. # Generate breakpad symbols on release builds
  143. if [ "${{ inputs.generate-symbols }}" = "true" ]; then
  144. e build --target electron:electron_symbols
  145. fi
  146. cd src
  147. export BUILD_PATH="$(pwd)/out/Default"
  148. e build --target electron:licenses
  149. e build --target electron:electron_version_file
  150. if [ "${{ inputs.is-release }}" = "true" ]; then
  151. DELETE_DSYMS_AFTER_ZIP=1 electron/script/zip-symbols.py -b $BUILD_PATH
  152. else
  153. electron/script/zip-symbols.py -b $BUILD_PATH
  154. fi
  155. - name: Generate FFMpeg ${{ inputs.step-suffix }}
  156. shell: bash
  157. if: ${{ inputs.is-release == 'true' }}
  158. run: |
  159. cd src
  160. gn gen out/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true $GN_EXTRA_ARGS"
  161. e build --target electron:electron_ffmpeg_zip -C ../../out/ffmpeg -j $NUMBER_OF_NINJA_PROCESSES
  162. - name: Generate Hunspell Dictionaries ${{ inputs.step-suffix }}
  163. shell: bash
  164. if: ${{ inputs.is-release == 'true' && inputs.target-platform == 'linux' }}
  165. run: |
  166. e build --target electron:hunspell_dictionaries_zip -j $NUMBER_OF_NINJA_PROCESSES
  167. - name: Generate Libcxx ${{ inputs.step-suffix }}
  168. shell: bash
  169. if: ${{ inputs.is-release == 'true' && inputs.target-platform == 'linux' }}
  170. run: |
  171. e build --target electron:libcxx_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
  172. e build --target electron:libcxxabi_headers_zip -j $NUMBER_OF_NINJA_PROCESSES
  173. e build --target electron:libcxx_objects_zip -j $NUMBER_OF_NINJA_PROCESSES
  174. - name: Generate TypeScript Definitions ${{ inputs.step-suffix }}
  175. if: ${{ inputs.is-release == 'true' }}
  176. shell: bash
  177. run: |
  178. cd src/electron
  179. node script/yarn create-typescript-definitions
  180. - name: Publish Electron Dist ${{ inputs.step-suffix }}
  181. if: ${{ inputs.is-release == 'true' }}
  182. shell: bash
  183. run: |
  184. rm -rf src/out/Default/obj
  185. cd src/electron
  186. if [ "${{ inputs.upload-to-storage }}" = "1" ]; then
  187. echo 'Uploading Electron release distribution to Azure'
  188. script/release/uploaders/upload.py --verbose --upload_to_storage
  189. else
  190. echo 'Uploading Electron release distribution to GitHub releases'
  191. script/release/uploaders/upload.py --verbose
  192. fi
  193. - name: Generate Artifact Key
  194. shell: bash
  195. run: |
  196. if [ "${{ inputs.is-asan }}" = "true" ]; then
  197. ARTIFACT_KEY=${{ inputs.artifact-platform }}_${{ inputs.target-arch }}_asan
  198. else
  199. ARTIFACT_KEY=${{ inputs.artifact-platform }}_${{ inputs.target-arch }}
  200. fi
  201. echo "ARTIFACT_KEY=$ARTIFACT_KEY" >> $GITHUB_ENV
  202. # The current generated_artifacts_<< artifact.key >> name was taken from CircleCI
  203. # to ensure we don't break anything, but we may be able to improve that.
  204. - name: Move all Generated Artifacts to Upload Folder ${{ inputs.step-suffix }}
  205. shell: bash
  206. run: ./src/electron/script/actions/move-artifacts.sh
  207. - name: Upload Generated Artifacts ${{ inputs.step-suffix }}
  208. uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
  209. with:
  210. name: generated_artifacts_${{ env.ARTIFACT_KEY }}
  211. path: ./generated_artifacts_${{ inputs.artifact-platform }}_${{ inputs.target-arch }}
  212. - name: Upload Src Artifacts ${{ inputs.step-suffix }}
  213. uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808
  214. with:
  215. name: src_artifacts_${{ env.ARTIFACT_KEY }}
  216. path: ./src_artifacts_${{ inputs.artifact-platform }}_${{ inputs.target-arch }}