-
Notifications
You must be signed in to change notification settings - Fork 0
209 lines (196 loc) · 8.32 KB
/
electron.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
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: "deepin-23-glibc-238"
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: write
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 }}/*
release_name: Electron v${{ inputs.electronVersion }} port for Loong64
tag: v${{ inputs.electronVersion }}
file_glob: true
overwrite: true
repo_token: ${{ secrets.GITHUB_TOKEN }}