forked from ungoogled-software/ungoogled-chromium-windows
-
Notifications
You must be signed in to change notification settings - Fork 0
225 lines (193 loc) · 6.66 KB
/
cross-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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
---
name: Cross-build ungoogled-chromium
on:
workflow_dispatch:
inputs:
container_image:
description: Container image for build
default: chromium-win-cross:latest
target-cpu:
description: Target CPU
type: choice
options: [x64, x86, arm64]
default: x64
env:
ZSTD_NBTHREADS: 0
jobs:
stage-1:
runs-on: ubuntu-24.04
container:
image: ghcr.io/${{github.repository_owner}}/${{inputs.container_image}}
options: -v /:/HOST
steps:
- name: Free up disk space
run: cd /HOST && sudo /usr/local/sbin/gh-unburden
- name: Clone u-c-w Git repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 50
fetch-tags: true
- name: Get Chromium version info
id: chromium
run: |
version=$(cat ungoogled-chromium/chromium_version.txt)
echo "Chromium version: $version"
echo "version=$version" >> $GITHUB_OUTPUT
- name: Restore Chromium source tarball download cache
id: restore-cache
uses: actions/cache/restore@v4
with:
key: chromium-source-${{steps.chromium.outputs.version}}
path: cross-build/build/download_cache
- name: Download and/or verify Chromium source tarball
run: |
cache=cross-build/build/download_cache
mkdir -p $cache
ungoogled-chromium/utils/downloads.py retrieve \
--ini ungoogled-chromium/downloads.ini \
--cache $cache \
--hide-progress-bar
ls -l $cache
- name: Save Chromium source tarball download cache
if: ${{!steps.restore-cache.outputs.cache-hit}}
uses: actions/cache/save@v4
with:
key: chromium-source-${{steps.chromium.outputs.version}}
path: cross-build/build/download_cache
- name: Prepare the build
run: cd cross-build && ./build.sh --ci --${{inputs.target-cpu}}
- name: Prepare GHCI build strategy
run: |
cd cross-build/build/src/out/Default*
targets=$(cat build.targets)
$GITHUB_WORKSPACE/skunk-tmp/ghci-strategy.sh 8 $targets
- name: Delete the download cache
run: rm -r cross-build/build/download_cache
- name: Stage 1 build (${{inputs.target-cpu}})
run: |
cd cross-build/build/src
ninja -C out/Default* -f ghci-stage1.ninja ghci-stage1
- name: Tar up the workspace
# The "touch" prevents a "tar: .: file changed as we read it" error
run: |
touch stage1.tar.zstd
tar cf stage1.tar.zstd --zstd --exclude=stage1.tar.zstd .
ls -lh stage1.tar.zstd
- name: Save the workspace for stage 2
uses: actions/upload-artifact@v4
with:
name: stage1
compression-level: 0
path: stage1.tar.zstd
if-no-files-found: error
retention-days: 1
stage-2:
needs: [stage-1]
runs-on: ubuntu-24.04
strategy:
matrix:
part: [part1, part2, part3, part4, part5, part6, part7, part8]
container:
image: ghcr.io/${{github.repository_owner}}/${{inputs.container_image}}
options: -v /:/HOST
env:
PART: ${{matrix.part}}
steps:
- name: Free up disk space
run: cd /HOST && sudo /usr/local/sbin/gh-unburden
- name: Download workspace tarball from stage 1
uses: actions/download-artifact@v4
with:
name: stage1
# The find/truncate gets rid of the bulk of redundant files under
# obj/, while keeping them as placeholders to avoid recompilation
- name: Unpack workspace tarball
run: |
tar xf stage1.tar.zstd --zstd
rm stage1.tar.zstd
find cross-build/build/src/out/Default*/obj \
-type f -exec truncate -s 0 {} +
- name: Stage 2 build (${{matrix.part}}, ${{inputs.target-cpu}})
run: |
cd cross-build/build/src
ninja -C out/Default* -f ghci-stage2.ninja $PART
- name: Tar up the partial build tree
run: |
tar cf stage2-$PART.tar.zstd --zstd cross-build/build/src/out/Default*/obj
ls -lh stage2-$PART.tar.zstd
- name: Save the partial tree for stage 3
uses: actions/upload-artifact@v4
with:
name: stage2-${{matrix.part}}
compression-level: 0
path: stage2-${{matrix.part}}.tar.zstd
if-no-files-found: error
retention-days: 1
stage-3:
needs: [stage-2]
runs-on: ubuntu-24.04
container:
image: ghcr.io/${{github.repository_owner}}/${{inputs.container_image}}
options: -v /:/HOST
steps:
- name: Free up disk space
run: cd /HOST && sudo /usr/local/sbin/gh-unburden
- name: Download the workspace and partial build tree tarballs
uses: actions/download-artifact@v4
- name: Unpack the tarballs
run: |
for tarball in \
stage1/stage1.tar.zstd \
stage2-part*/stage2-part*.tar.zstd
do
echo "Unpacking $tarball ..."
tar xf $tarball --zstd --skip-old-files
rm $tarball
done
rmdir stage1 stage2-part*
- name: Stage 3 build (${{inputs.target-cpu}})
run: cd cross-build && ./build.sh --${{inputs.target-cpu}}
- name: Archive build outputs
uses: actions/upload-artifact@v4
with:
name: packages
compression-level: 0
path: cross-build/build/ungoogled-chromium_*
if-no-files-found: error
- name: Archive reproducibility info
uses: actions/upload-artifact@v4
with:
name: reproduce
compression-level: 9
path: cross-build/build/MD5SUMS.repro
if-no-files-found: error
cleanup:
if: always()
needs: [stage-3]
runs-on: ubuntu-24.04
permissions:
actions: write
steps:
- name: Delete temporary artifacts
env:
GH_TOKEN: ${{github.token}}
run: |
gh_api_call()
{
gh api $2 $3 \
-H 'Accept: application/vnd.github+json' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
"/repos/$GITHUB_REPOSITORY/actions/$1"
}
gh_api_call "runs/$GITHUB_RUN_ID/artifacts" \
| jq -r '.artifacts[] | (.id|tostring)+"\t"+.name' \
| grep stage \
> artifacts.txt || true
echo "Found $(wc -l < artifacts.txt) artifact(s) to delete."
while read id name
do
echo "Deleting artifact \"$name\" (id=$id)"
gh_api_call "artifacts/$id" --method DELETE
done < artifacts.txt
# EOF