-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (90 loc) · 5.09 KB
/
build.yml
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
name: Build
on:
push:
branches: [ main ]
schedule:
- cron: '0 0 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build
shell: bash
run: |
# Configure git to be more predictable and deterministic
git config core.autocrlf false
git config core.ignorecase false
git config core.fscache true
git config core.longpaths true
git config diff.renameLimit 0
git config status.renameLimit 0
git config merge.renameLimit 0
git config http.lowSpeedLimit 0
git config http.lowSpeedTime 300
git config http.postBuffer 1048576000
git config pack.threads 1
git config index.threads 0
# Check Electron version on npm
export electron_version=$(curl -sS 'https://registry.npmjs.org/electron' | python -c "import sys, json; print(json.load(sys.stdin)['dist-tags']['latest'])")
if [ -f "package.json" ] && [ $electron_version == $(cat package.json | python -c "import sys, json; print(json.load(sys.stdin)['version'])") ]; then
exit 0
fi
# Roll back the repository
git reset --hard $(git rev-list --max-parents=0 HEAD)
git clean -dffx
# Install using npm 6
# Later versions fail to create a sane dependency tree in some situations
export npm_version=$(curl -sS 'https://registry.npmjs.org/npm' | python -c "import sys, json; print(json.load(sys.stdin)['dist-tags']['latest-6'])")
wget -nv -O "npm-$npm_version.tgz" "https://registry.npmjs.org/npm/-/npm-$npm_version.tgz"
mkdir -p "bin/npm"
tar -xzf "npm-$npm_version.tgz" --strip-components=1 -C "bin/npm"
rm "npm-$npm_version.tgz"
# Initialize dummy package
node bin/npm/bin/npm-cli.js init -y
sed -i 's/"name": "electron"/"name": "npm"/' -- 'package.json'
# Install Electron as a dependency
node bin/npm/bin/npm-cli.js install --no-audit --no-bin-links --no-fund --ignore-scripts --no-optional "electron@$electron_version"
# Remove npm
rm -r bin/
rm package.json
rm package-lock.json
# Delete install script since it doesn't function without dependencies
rm node_modules/electron/install.js
# Modify package.json to match the Electron tarball from npm
sed -i -z 's|\n "_phantomChildren": {\n "[a-zA-Z0-9\n -"'\''-*,./:@_~-]*\n },\n|\n|' -- 'node_modules/electron/package.json'
sed -i '/"_requested": {/,/}/d' -- 'node_modules/electron/package.json'
sed -i '/"_requiredBy": \[/,/\]/d' -- 'node_modules/electron/package.json'
sed -i '/"bugs": {/,/}/d' -- 'node_modules/electron/package.json'
sed -i '/"scripts": {/,/}/d' -- 'node_modules/electron/package.json'
sed -i '/"dependencies": {/,/}/d' -- 'node_modules/electron/package.json'
sed -i '/"engines": {/,/}/d' -- 'node_modules/electron/package.json'
sed -i '/"_from":/d' -- 'node_modules/electron/package.json'
sed -i '/"_id":/d' -- 'node_modules/electron/package.json'
sed -i '/"_inBundle":/d' -- 'node_modules/electron/package.json'
sed -i '/"_integrity":/d' -- 'node_modules/electron/package.json'
sed -i '/"_location":/d' -- 'node_modules/electron/package.json'
sed -i '/"_phantomChildren":/d' -- 'node_modules/electron/package.json'
sed -i '/"_resolved":/d' -- 'node_modules/electron/package.json'
sed -i '/"_shasum":/d' -- 'node_modules/electron/package.json'
sed -i '/"_spec":/d' -- 'node_modules/electron/package.json'
sed -i '/"_where":/d' -- 'node_modules/electron/package.json'
sed -i '/"bundleDependencies":/d' -- 'node_modules/electron/package.json'
sed -i '/"deprecated":/d' -- 'node_modules/electron/package.json'
sed -i '/"homepage":/d' -- 'node_modules/electron/package.json'
sed -i -z 's/ "author": {\n "name": "Electron Community"\n },/ "author": "Electron Community",/' -- 'node_modules/electron/package.json'
sed -i -z 's| "repository": {\n "type": "git",\n "url": "git+https://github.com/electron/electron.git"\n },| "repository": "https://github.com/electron/electron",|' -- 'node_modules/electron/package.json'
# Pretend we ran the install script
echo -n "electron" > "node_modules/electron/path.txt"
# Add Electron to the repository
rsync -avv --exclude='node_modules/' node_modules/electron/ .
rm -r node_modules/
git add -f .
# Push to GitHub
git -c user.name="GitHub" -c user.email="[email protected]" commit --author="github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" -m"$electron_version" | sed -n 1p
git tag -f "$electron_version"
git push --force
git push -f origin "refs/tags/$electron_version:refs/tags/$electron_version"