Skip to content

Build Electron

Build Electron #21

Workflow file for this run

name: Build Electron
on:
workflow_dispatch:
inputs:
stage:
type: choice
description: 'Stage to run through'
required: true
default: 'full'
options:
- full
- build
- package
builderImageTag:
type: string
required: true
default: "electron-v32"
description: Builder image tag
electronVersion:
type: string
required: true
default: "33.2.1"
description: Version of electron to build
env:
ROOT_PATH: /home/builduser/buildroot
DEPOT_PATH: /home/builduser/.electron_build_tools/third_party/depot_tools
SRC_PATH: /home/builduser/buildroot/src
OUT_PATH: /home/builduser/buildroot/src/out/Release
RELEASE_PATH: /home/builduser/buildroot/release/${{ inputs.electronVersion }}
jobs:
prepare:
runs-on: [self-hosted, ryustation]
container:
image: ghcr.io/darkyzhou/electron-buildtools:latest
volumes:
- /mnt/data/build/electron-loong64:/home/builduser
steps:
- uses: actions/checkout@v4
- name: Patch Sources
if: ${{ inputs.stage == 'full' }}
run: |
set -ex
REPO_PATH=`pwd`
cd "$ROOT_PATH"
if [ ! -d "src/electron" ]; then
npx e init -i release -r "$ROOT_PATH" electron-loong64
git clone https://github.com/electron/electron.git src/electron
fi
git -C src clean -fd || true; git -C src am --abort || true; git -C src reset --hard HEAD;
git -C src submodule foreach 'git clean -fd || true; git am --abort || true; git reset --hard HEAD';
git -C src/electron clean -fd || true; git -C src/electron reset --hard HEAD;
git -C src/electron remote set-url origin https://github.com/electron/electron.git
git -C src/electron fetch origin --tags
git -C src/electron switch --detach v${{ inputs.electronVersion }}
git -C src/electron apply "$REPO_PATH"/electron.patch
# Workaround for a strange Python error: "Cannot call rmtree on a symbolic link"
git -C "$DEPOT_PATH" reset --hard HEAD
git -C "$DEPOT_PATH" apply "$REPO_PATH"/gclient.patch
- name: Sync Dependencies
if: ${{ inputs.stage == 'full' }}
run: |
set -ex
cd /home/builduser/buildroot
npx e sync
build:
needs: prepare
runs-on: [self-hosted, ryustation]
permissions:
contents: read
packages: write
container:
image: ghcr.io/darkyzhou/electron-builder:${{ inputs.builderImageTag }}
volumes:
- /mnt/data/build/electron-loong64:/home/builduser
steps:
- name: Replace Binaries
if: ${{ inputs.stage != 'package' }}
run: |
set -ex
cp /usr/local/bin/node /home/builduser/buildroot/src/third_party/node/linux/node-linux-x64/bin/node
chmod +w /home/builduser/buildroot/src/third_party/devtools-frontend/src/third_party/esbuild/esbuild
cp /usr/local/lib/node_modules/@esbuild/linux-loong64/bin/esbuild /home/builduser/buildroot/src/third_party/devtools-frontend/src/third_party/esbuild/esbuild
- name: Build Electron
if: ${{ inputs.stage != 'package' }}
run: |
set -ex
cd "$SRC_PATH"
rm -f "$OUT_PATH"/electron
gn gen "$OUT_PATH" --args="import(\"//electron/build/args/release.gn\")" --script-executable=/usr/bin/python3
ninja -C "$OUT_PATH" electron
env:
CC: clang
CXX: clang++
AR: ar
NM: nm
RUSTC_BOOTSTRAP: 1
- name: Package Debug Symbols and Strip Binaries
run: |
set -ex
cd "$SRC_PATH"
rm -rf "$OUT_PATH"/breakpad_symbols
ninja -C "$OUT_PATH" electron:electron_symbols
electron/script/copy-debug-symbols.py -d "$OUT_PATH" --out-dir="$OUT_PATH"/debug --compress
electron/script/strip-binaries.py -d "$OUT_PATH" --verbose
electron/script/add-debug-link.py -d "$OUT_PATH" --debug-dir="$OUT_PATH"/debug
ninja -C "$OUT_PATH" electron:licenses
ninja -C "$OUT_PATH" electron:electron_version_file
DELETE_DSYMS_AFTER_ZIP=1 electron/script/zip-symbols.py -b "$OUT_PATH"
rm -rf "$RELEASE_PATH"
mkdir -p "$RELEASE_PATH"
mv "$OUT_PATH"/debug.zip "$RELEASE_PATH"/electron-v${{ inputs.electronVersion }}-linux-loong64-debug.zip
mv "$OUT_PATH"/symbols.zip "$RELEASE_PATH"/electron-v${{ inputs.electronVersion }}-linux-loong64-symbols.zip
- name: Package Electron
run: |
set -ex
cd "$SRC_PATH"
ninja -C "$OUT_PATH" electron:electron_dist_zip
mv "$OUT_PATH"/dist.zip "$RELEASE_PATH"/electron-v${{ inputs.electronVersion }}-linux-loong64.zip
- name: Build Mksnapshot
run: |
set -ex
cd "$SRC_PATH"
ninja -C "$OUT_PATH" electron:electron_mksnapshot
gn desc "$OUT_PATH" v8:run_mksnapshot_default args > "$OUT_PATH"/mksnapshot_args
# Remove unused args from mksnapshot_args
sed -i '/.*builtins-pgo/d' "$OUT_PATH"/mksnapshot_args
sed -i '/--turbo-profiling-input/d' "$OUT_PATH"/mksnapshot_args
electron/script/strip-binaries.py --file "$OUT_PATH"/mksnapshot --verbose
electron/script/strip-binaries.py --file "$OUT_PATH"/v8_context_snapshot_generator --verbose
ninja -C "$OUT_PATH" electron:electron_mksnapshot_zip
cd "$OUT_PATH"
zip mksnapshot.zip mksnapshot_args gen/v8/embedded.S
mv "$OUT_PATH"/mksnapshot.zip "$RELEASE_PATH"/mksnapshot-v${{ inputs.electronVersion }}-linux-loong64.zip
- name: Build Chromedriver
run: |
set -ex
cd "$SRC_PATH"
EU_STRIP_PATH="$SRC_PATH"/buildtools/third_party/eu-strip/bin/eu-strip
rm -rf "$EU_STRIP_PATH"
ln -sv `which eu-strip` "$EU_STRIP_PATH"
ninja -C "$OUT_PATH" electron:electron_chromedriver
ninja -C "$OUT_PATH" electron:electron_chromedriver_zip
mv "$OUT_PATH"/chromedriver.zip "$RELEASE_PATH"/chromedriver-v${{ inputs.electronVersion }}-linux-loong64.zip
- name: Build Node.js headers
run: |
set -ex
cd "$SRC_PATH"
ninja -C "$OUT_PATH" electron:node_headers
mv "$OUT_PATH"/gen/node_headers.tar.gz "$RELEASE_PATH"/node-v${{ inputs.electronVersion }}-headers.tar.gz
- name: Build ffmpeg
run: |
set -ex
cd "$SRC_PATH"
gn gen "$OUT_PATH"/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\")" --script-executable=/usr/bin/python3
ninja -C "$OUT_PATH"/ffmpeg electron:electron_ffmpeg_zip
mv "$OUT_PATH"/ffmpeg/ffmpeg.zip "$RELEASE_PATH"/ffmpeg-v${{ inputs.electronVersion }}-linux-loong64.zip
env:
CC: clang
CXX: clang++
AR: ar
NM: nm
RUSTC_BOOTSTRAP: 1
- name: Build hunspell
run: |
set -ex
cd "$SRC_PATH"
ninja -C "$OUT_PATH" electron:hunspell_dictionaries_zip
mv "$OUT_PATH"/hunspell_dictionaries.zip "$RELEASE_PATH"/hunspell-dictionaries.zip
- name: Build libcxx
run: |
set -ex
cd "$SRC_PATH"
ninja -C "$OUT_PATH" electron:libcxx_headers_zip
ninja -C "$OUT_PATH" electron:libcxxabi_headers_zip
ninja -C "$OUT_PATH" electron:libcxx_objects_zip
mv "$OUT_PATH"/libcxx_headers.zip "$RELEASE_PATH"/libcxx-headers.zip
mv "$OUT_PATH"/libcxxabi_headers.zip "$RELEASE_PATH"/libcxxabi-headers.zip
mv "$OUT_PATH"/libcxx_objects.zip "$RELEASE_PATH"/libcxx-objects-v${{ inputs.electronVersion }}-linux-loong64.zip
- name: Calculate Checksums
run: |
set -ex
cd "$RELEASE_PATH"
rm -f SHASUMS256.txt
for file in *; do
checksum=$(sha256sum "$file" | cut -d ' ' -f 1)
echo "$checksum *$file" >> SHASUMS256.txt
done
- name: Upload Artifact
uses: svenstaro/upload-release-action@v2
with:
file: ${{ env.RELEASE_PATH }}/*
file_glob: true
overwrite: true
release_name: Electron v${{ inputs.electronVersion }} port for Loong64
tag: v${{ inputs.electronVersion }}