File tree Expand file tree Collapse file tree 5 files changed +100
-0
lines changed
actions/generate-build-checksums Expand file tree Collapse file tree 5 files changed +100
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2026 Alexandre Gomes Gaigalas <alganet@gmail.com>
2+ # SPDX-License-Identifier: ISC
3+
4+ name : Generate and upload build checksums
5+ description : Extracts /opt from the built image, generates build checksums into checksums/build/, ensures correct ownership and uploads the artifact
6+ runs :
7+ using : composite
8+ steps :
9+ - name : Extract image /opt
10+ shell : bash
11+ run : |
12+ set -ex
13+ container=$(docker create "${{ inputs.image }}")
14+ docker cp $container:/opt ./image_out
15+ docker rm $container
16+
17+ - name : Generate build checksums
18+ shell : bash
19+ env :
20+ SHVR_DIR_OUT : ${{ github.workspace }}/image_out
21+ SHVR_CHECKSUMS_DIR : ${{ github.workspace }}/checksums
22+ run : |
23+ set -ex
24+ sh shvr.sh generate_build_checksums
25+
26+ - name : Ensure ownership of checksums
27+ shell : bash
28+ run : |
29+ set -ex
30+ # Some runners may create files as root when using docker, ensure runner can upload
31+ sudo chown -R $(id -u):$(id -g) checksums/build || true
32+
33+ - name : Upload build checksums
34+ uses : actions/upload-artifact@v6
35+ with :
36+ name : ${{ inputs.artifact_name }}
37+ path : checksums/build
38+
39+ inputs :
40+ image :
41+ description : Docker image tag to extract (required)
42+ required : true
43+ artifact_name :
44+ description : Artifact name to upload
45+ required : false
46+ default : shvr-build-checksums
Original file line number Diff line number Diff line change 4444 build-args : |
4545 TARGETS=${{ matrix.targets }}
4646
47+ - name : Generate and upload build checksums
48+ uses : ./.github/actions/generate-build-checksums
49+ with :
50+ image : ${{ matrix.tags }}
51+ artifact_name : shvr-build-checksums
52+
4753 strategy :
4854 fail-fast : true
4955 matrix :
Original file line number Diff line number Diff line change 4444 build-args : |
4545 TARGETS=${{ matrix.targets }}
4646
47+ - name : Generate and upload build checksums
48+ uses : ./.github/actions/generate-build-checksums
49+ with :
50+ image : ${{ matrix.tags }}
51+ artifact_name : shvr-build-checksums
52+
4753 strategy :
4854 fail-fast : true
4955 matrix :
Original file line number Diff line number Diff line change 4444 build-args : |
4545 TARGETS=${{ matrix.targets }}
4646
47+ - name : Generate and upload build checksums
48+ uses : ./.github/actions/generate-build-checksums
49+ with :
50+ image : ${{ matrix.tags }}
51+ artifact_name : shvr-build-checksums
52+
4753 strategy :
4854 fail-fast : false
4955 matrix :
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ shvr_build ()
3232 set -x
3333
3434 shvr_each build " ${@:- } "
35+ shvr_generate_build_checksums " ${@:- } "
3536}
3637
3738
@@ -196,6 +197,41 @@ shvr_generate_checksums()
196197 done
197198}
198199
200+
201+ # Generate checksums for build outputs under ${SHVR_DIR_OUT} and write them
202+ # to ${SHVR_CHECKSUMS_DIR}/build/<rel>.sha256sums mirroring the out layout.
203+ # Usage: shvr_generate_build_checksums [<shell>_<version> ...]
204+ shvr_generate_build_checksums ()
205+ {
206+ if test -z " $* "
207+ then
208+ start_dir=" ${SHVR_DIR_OUT} "
209+ find " $start_dir " -type f | while read -r f
210+ do
211+ rel=" ${f# ${SHVR_DIR_OUT} / } "
212+ dest_dir=" $( dirname " ${SHVR_CHECKSUMS_DIR} /build/${rel} .sha256sums" ) "
213+ mkdir -p " $dest_dir "
214+ sha256sum " $f " | sed " s/ .*/ $( basename " $f " ) /" > " ${SHVR_CHECKSUMS_DIR} /build/${rel} .sha256sums"
215+ done
216+ else
217+ # Only generate checksums for specific targets (e.g., bash_5.3.9)
218+ for t in " $@ "
219+ do
220+ dir=" $SHVR_DIR_OUT /${t} "
221+ if test -d " $dir "
222+ then
223+ find " $dir " -type f | while read -r f
224+ do
225+ rel=" ${f# ${SHVR_DIR_OUT} / } "
226+ dest_dir=" $( dirname " ${SHVR_CHECKSUMS_DIR} /build/${rel} .sha256sums" ) "
227+ mkdir -p " $dest_dir "
228+ sha256sum " $f " | sed " s/ .*/ $( basename " $f " ) /" > " ${SHVR_CHECKSUMS_DIR} /build/${rel} .sha256sums"
229+ done
230+ fi
231+ done
232+ fi
233+ }
234+
199235shvr_github_regen_downloads ()
200236{
201237 set -- $( printf ' %s ' $( shvr_targets | sort -t' _' -k1,1 -k2Vr) )
You can’t perform that action at this time.
0 commit comments