97
97
ca-certificates \
98
98
curl \
99
99
git \
100
+ git-lfs \
100
101
jq \
101
102
sudo \
102
103
tzdata \
@@ -129,37 +130,40 @@ jobs:
129
130
COREBOOT_HASH="$( git rev-parse --short HEAD )"
130
131
echo "${COREBOOT_HASH}"
131
132
echo "COREBOOT_HASH=${COREBOOT_HASH}" >> "${GITHUB_OUTPUT}"
132
- - name : Artefact and cache key
133
+
134
+ - name : Check if toolchain is stored in firmware-action-toolchains repo
135
+ continue-on-error : true
136
+ run : |
137
+ # Check if the toolchain exists without downloading it
138
+ wget --spider "https://raw.githubusercontent.com/9elements/firmware-action-toolchains/refs/heads/main/coreboot/${{ steps.version.outputs.COREBOOT_VERSION }}/${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${{ matrix.arch }}-xgcc.tar"
139
+ touch .firmware-action-toolchains-exist
140
+ - name : Check if toolchain exist
141
+ id : toolchains-exist
142
+ run : |
143
+ if [ -f ".firmware-action-toolchains-exist" ]; then
144
+ echo "toolchain is stored in firmware-action-toolchains repository, skipping rest of the job"
145
+ echo "EXIST=true" >> "${GITHUB_OUTPUT}"
146
+ else
147
+ echo "toolchain is NOT stored in firmware-action-toolchains repository, will build it"
148
+ echo "EXIST=false" >> "${GITHUB_OUTPUT}"
149
+ fi
150
+
151
+ - name : Cache key
133
152
id : cache-key
134
153
run : |
135
154
CACHE_KEY="coreboot-${{ steps.version.outputs.COREBOOT_VERSION }}-${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${{ matrix.arch }}"
136
155
echo "${CACHE_KEY}"
137
156
echo "CACHE_KEY=${CACHE_KEY}" >> "${GITHUB_OUTPUT}"
138
-
139
157
- name : Restore cached toolchains
140
158
id : cache-toolchains
141
159
uses : actions/cache/restore@v4
142
160
with :
143
161
path : coreboot/util/crossgcc/xgcc
144
162
key : ${{ steps.cache-key.outputs.CACHE_KEY }}-xgcc
145
- - name : Restore cached utils
146
- id : cache-utils
147
- uses : actions/cache/restore@v4
148
- with :
149
- path : /usr/local/bin
150
- key : ${{ steps.cache-key.outputs.CACHE_KEY }}-utils
151
-
152
- - name : Debug list crossgcc
153
- if : steps.cache-toolchains.outputs.cache-hit == 'true'
154
- run : |
155
- ls -a1lh coreboot/util/crossgcc/xgcc
156
- - name : Debug list utils
157
- if : steps.cache-utils.outputs.cache-hit == 'true'
158
- run : |
159
- ls -a1lh /usr/local/bin
160
163
161
164
- name : Install dependencies if needed
162
- if : steps.cache-toolchains.outputs.cache-hit != 'true'
165
+ # != 'true' because on miss the cache-hit is empty
166
+ if : steps.toolchains-exist.outputs.EXIST == 'false' && steps.cache-toolchains.outputs.cache-hit != 'true'
163
167
run : |
164
168
apt-get install -y --no-install-recommends \
165
169
acpica-tools \
@@ -185,69 +189,57 @@ jobs:
185
189
uuid-dev \
186
190
zlib1g-dev
187
191
- name : Install dependencies if needed (amd64)
188
- if : matrix.arch == 'amd64' && steps.cache-toolchains.outputs.cache-hit != 'true'
192
+ if : matrix.arch == 'amd64' && steps.toolchains-exist.outputs.EXIST == 'false' && steps. cache-toolchains.outputs.cache-hit != 'true'
189
193
run : |
190
194
apt-get install -y --no-install-recommends \
191
195
iucode-tool
192
196
193
197
- name : Build coreboot toolchains
194
- if : steps.cache-toolchains.outputs.cache-hit != 'true'
198
+ if : steps.toolchains-exist.outputs.EXIST == 'false' && steps. cache-toolchains.outputs.cache-hit != 'true'
195
199
run : |
196
200
cd coreboot
197
201
make crossgcc CPUS="$(nproc)"
198
- - name : Build coreboot utils
199
- if : steps.cache-utils.outputs.cache-hit != 'true'
200
- run : |
201
- cd coreboot
202
- make -C util/ifdtool install
203
- make -C util/cbfstool install
204
202
- name : Compress toolchain binaries
205
203
# This step should shrink the size of single toolchain from 1.5 GB down to around 700 MB
206
204
# I think it is save to compress all binaries except libraries, hence the '-wholename'
207
- if : steps.cache-toolchains.outputs.cache-hit != 'true'
205
+ if : steps.toolchains-exist.outputs.EXIST == 'false' && steps. cache-toolchains.outputs.cache-hit != 'true'
208
206
run : |
207
+ PWD=$( pwd )
209
208
cd coreboot/util/crossgcc/xgcc
210
209
# shellcheck disable=SC2016
211
210
find . -type f -wholename '*/bin/*' -exec bash -c 'upx-ucl -9 "$1"' shell {} \; || true
212
211
212
+ cd "${PWD}"
213
+ # Tar toolchain to prevent permission loss
214
+ # Docs: https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
215
+ mv "coreboot/util/crossgcc/xgcc" "coreboot/util/crossgcc/${{ matrix.arch }}-xgcc"
216
+ tar -cf "${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${{ matrix.arch }}-xgcc.tar" "coreboot/util/crossgcc/${{ matrix.arch }}-xgcc"
217
+ sha256sum "${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${{ matrix.arch }}-xgcc.tar" > "${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${{ matrix.arch }}-xgcc.tar.sha256"
218
+
213
219
# Store toolchains and utils in cache
214
220
- name : Cache toolchains
215
221
uses : actions/cache/save@v4
216
- if : steps.cache-toolchains.outputs.cache-hit != 'true'
222
+ if : steps.toolchains-exist.outputs.EXIST == 'false' && steps. cache-toolchains.outputs.cache-hit != 'true'
217
223
with :
218
224
path : coreboot/util/crossgcc/xgcc
219
225
key : ${{ steps.cache-key.outputs.CACHE_KEY }}-xgcc
220
- - name : Cache utils
221
- uses : actions/cache/save@v4
222
- if : steps.cache-utils.outputs.cache-hit != 'true'
223
- with :
224
- path : /usr/local/bin
225
- key : ${{ steps.cache-key.outputs.CACHE_KEY }}-utils
226
226
227
- # Upload toolchains and utils as artifacts
228
- - name : Tar toolchain to prevent permission loss
229
- # Docs: https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
227
+ - name : Commit the toolchain into firmware-action-toolchains repository
228
+ if : steps.toolchains-exist.outputs.EXIST == 'false'
230
229
run : |
231
- if [ ! -f "coreboot/util/crossgcc/xgcc-tar/${{ steps.cache-key.outputs.CACHE_KEY }}-xgcc.tar" ]; then
232
- mv coreboot/util/crossgcc/xgcc coreboot/util/crossgcc/${{ matrix.arch }}-xgcc
233
- tar -cf ${{ steps.cache-key.outputs.CACHE_KEY }}-xgcc.tar coreboot/util/crossgcc/${{ matrix.arch }}-xgcc
234
- fi
235
- - name : Upload toolchain
236
-
237
- with :
238
- name : ${{ steps.cache-key.outputs.CACHE_KEY }}-xgcc
239
- path : ${{ steps.cache-key.outputs.CACHE_KEY }}-xgcc.tar
240
- retention-days : 30
241
- include-hidden-files : true
242
- compression-level : 9
243
- - name : Upload utils
244
-
245
- with :
246
- name : ${{ steps.cache-key.outputs.CACHE_KEY }}-utils
247
- path : /usr/local/bin
248
- retention-days : 30
249
- include-hidden-files : true
250
- compression-level : 9
230
+ # Clone repo without downloading LFS items
231
+ GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/9elements/firmware-action-toolchains.git
232
+ cd firmware-action-toolchains
233
+ git branch "feat/${{ steps.version.outputs.COREBOOT_VERSION }}-${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${{ matrix.arch }}"
234
+ mkdir -p "coreboot/${{ steps.version.outputs.COREBOOT_VERSION }}/"
235
+ mv "../${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${{ matrix.arch }}-xgcc.tar" "coreboot/${{ steps.version.outputs.COREBOOT_VERSION }}/"
236
+ mv "../${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${{ matrix.arch }}-xgcc.tar.sha256" "coreboot/${{ steps.version.outputs.COREBOOT_VERSION }}/"
237
+ git lfs install
238
+ git add .
239
+ git commit -m "feat: add toolchain for coreboot ${{ steps.version.outputs.COREBOOT_VERSION }}"
240
+ git push --set-upstream "feat/${{ steps.version.outputs.COREBOOT_VERSION }}-${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${{ matrix.arch }}"
241
+
242
+
251
243
252
244
# =========================
253
245
# Build Docker containers
@@ -319,56 +311,33 @@ jobs:
319
311
COREBOOT_HASH="$( git rev-parse --short HEAD )"
320
312
echo "${COREBOOT_HASH}"
321
313
echo "COREBOOT_HASH=${COREBOOT_HASH}" >> "${GITHUB_OUTPUT}"
322
- - name : Artefact and cache key
323
- id : cache-key
324
- if : startsWith(matrix.dockerfile, 'coreboot')
325
- run : |
326
- CACHE_KEY="coreboot-${{ steps.version.outputs.COREBOOT_VERSION }}-${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}"
327
- echo "CACHE_KEY=${CACHE_KEY}"
328
- echo "CACHE_KEY=${CACHE_KEY}" >> "${GITHUB_OUTPUT}"
329
314
330
315
# =================================
331
316
# Download artifacts for coreboot
332
317
# =================================
333
318
334
- - name : Download coreboot toolchains from current run (if possible)
335
- id : artifacts-toolchains-current
319
+ - name : Download coreboot toolchains from firmware-action-toolchains repository
320
+ id : firmware-action-toolchains
336
321
if : startsWith(matrix.dockerfile, 'coreboot')
337
- uses : dawidd6/action-download-artifact@v6
338
- with :
339
- name : ${{ steps.cache-key.outputs.CACHE_KEY }}-.*
340
- name_is_regexp : true
341
- if_no_artifact_found : warn
342
- run_id : ${{ github.event.workflow_run.id }}
343
- # It is possible that current run did not produce any artifacts (to save bandwidth on self-hosted runners)
344
- # In which case we have to look for artifacts in older runs
345
- - name : Download coreboot toolchains from older run
346
- if : startsWith(matrix.dockerfile, 'coreboot') && steps.artifacts-toolchains-current.outputs.found_artifact != 'true'
347
- uses : dawidd6/action-download-artifact@v6
348
- with :
349
- name : ${{ steps.cache-key.outputs.CACHE_KEY }}-.*
350
- name_is_regexp : true
351
- search_artifacts : true
322
+ continue-on-error : true
323
+ run : |
324
+ for arch in "amd64" "arm64"; do
325
+ wget --continue --tries=3 "https://raw.githubusercontent.com/9elements/firmware-action-toolchains/refs/heads/main/coreboot/${{ steps.version.outputs.COREBOOT_VERSION }}/${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${arch}-xgcc.tar";
326
+ wget --continue --tries=3 "https://raw.githubusercontent.com/9elements/firmware-action-toolchains/refs/heads/main/coreboot/${{ steps.version.outputs.COREBOOT_VERSION }}/${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${arch}-xgcc.tar.sha256";
327
+ sha256sum -c "${{ steps.coreboot-hash.outputs.COREBOOT_HASH }}-${arch}-xgcc.tar.sha256";
328
+ done
352
329
353
330
- name : Prepare toolchains
354
331
if : startsWith(matrix.dockerfile, 'coreboot')
355
332
run : |
356
333
mkdir -p docker/coreboot/coreboot-${{ steps.version.outputs.COREBOOT_VERSION }}
357
- for f in ${{ steps.cache-key .outputs.CACHE_KEY }}-*-xgcc/*.tar; do
334
+ for f in ${{ steps.coreboot-hash .outputs.COREBOOT_HASH }}-*-xgcc/*.tar; do
358
335
ARCH=$( basename "${f}" | sed -E 's/coreboot\-[0-9\.]+\-[a-z0-9]+\-([a-z0-9]+)\-.*/\1/g' )
359
336
echo "extracting ${f} -> ${{ steps.version.outputs.COREBOOT_VERSION }} / ${ARCH}"
360
337
mkdir -p "${f}.dir/"
361
338
tar -xf "${f}" -C "${f}.dir/"
362
339
mv "${f}.dir/coreboot/util/crossgcc/${ARCH}-xgcc" "docker/coreboot/coreboot-${{ steps.version.outputs.COREBOOT_VERSION }}/xgcc-${ARCH}"
363
- done
364
- - name : Prepare utils
365
- if : startsWith(matrix.dockerfile, 'coreboot')
366
- run : |
367
- for f in ${{ steps.cache-key.outputs.CACHE_KEY }}-*-utils; do
368
- ARCH=$( basename "${f}" | sed -E 's/coreboot\-[0-9\.]+\-[a-z0-9]+\-([a-z0-9]+)\-.*/\1/g' )
369
- echo "${f} -> ${{ steps.version.outputs.COREBOOT_VERSION }} / ${ARCH}"
370
- chmod +rx "${f}"/*
371
- mv "${f}" "docker/coreboot/coreboot-${{ steps.version.outputs.COREBOOT_VERSION }}/utils-${ARCH}"
340
+ rm -rf "${f}"
372
341
done
373
342
374
343
- name : Debug list artifacts
@@ -383,10 +352,6 @@ jobs:
383
352
if : startsWith(matrix.dockerfile, 'coreboot')
384
353
run : |
385
354
ls -a1lh docker/coreboot/coreboot-${{ steps.version.outputs.COREBOOT_VERSION }}/xgcc-*/bin
386
- - name : Debug list utils (amd64)
387
- if : startsWith(matrix.dockerfile, 'coreboot')
388
- run : |
389
- ls -a1lh docker/coreboot/coreboot-${{ steps.version.outputs.COREBOOT_VERSION }}/utils-*
390
355
391
356
# ============================
392
357
# Build the docker container
0 commit comments