CI: export SOURCE_DATE_EPOCH for ESP32 and normalize DFU zip timestamps
Changelog: -
This commit is contained in:
1 parent
681d38b778
commit
3d66aaf396
1 file changed
+17
-5
@@ -215,6 +215,7 @@ jobs:
|
||||
ccache --version | head -1
|
||||
{
|
||||
[ -f tools/ccache_wrap.py ] && echo "PLATFORMIO_EXTRA_SCRIPTS=pre:tools/ccache_wrap.py"
|
||||
echo "SOURCE_DATE_EPOCH=$(git log -1 --format=%ct HEAD)"
|
||||
echo "CCACHE_DIR=$HOME/.cache/ccache"
|
||||
echo "CCACHE_MAXSIZE=2G"
|
||||
echo "CCACHE_COMPILERCHECK=content"
|
||||
@@ -341,11 +342,10 @@ jobs:
|
||||
echo "::error::$title failed: ${failed[*]}"
|
||||
exit 1
|
||||
}
|
||||
# 1) install the platforms. Nothing is cached here (reproducible),
|
||||
# so each run downloads platforms, toolchains and libraries: 8 min
|
||||
# env by env up front. One env per distinct platform (+
|
||||
# 1) install the platforms. One env per distinct platform (+
|
||||
# platform_packages) installs those first, one at a time -- they
|
||||
# are shared in ~/.platformio, concurrent installs would race.
|
||||
# are shared in ~/.platformio (restored by actions/cache above),
|
||||
# concurrent installs would race.
|
||||
envs=$(printf '%s\n' "${arts[@]}" | while read -r a; do echo "${spec[$a]%%|*}"; done | sort -u)
|
||||
mapfile -t first < <(pio project config --json-output | python3 -c '
|
||||
import json, sys
|
||||
@@ -399,8 +399,20 @@ jobs:
|
||||
echo "::group::package $env$suffix"
|
||||
if [ -f "$b/firmware.zip" ]; then # nRF52
|
||||
python3 bin/uf2conv/uf2conv.py "$b/firmware.hex" -c -o "$b/firmware.uf2" -f 0xADA52840
|
||||
# Normalize ZIP entry timestamps to SOURCE_DATE_EPOCH so the DFU
|
||||
# zip (and SHA256SUMS) is byte-for-byte reproducible across runs.
|
||||
python3 -c '
|
||||
import datetime, os, sys, zipfile
|
||||
ts = datetime.datetime.fromtimestamp(int(os.environ["SOURCE_DATE_EPOCH"]), datetime.timezone.utc)
|
||||
dt = (ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second - (ts.second % 2))
|
||||
src, dst = sys.argv[1], sys.argv[2]
|
||||
with zipfile.ZipFile(src, "r") as zin, zipfile.ZipFile(dst, "w", compression=zipfile.ZIP_STORED) as zout:
|
||||
for info in zin.infolist():
|
||||
data = zin.read(info.filename)
|
||||
info.date_time = dt
|
||||
zout.writestr(info, data)
|
||||
' "$b/firmware.zip" "$dist/$env$suffix-$TAG.zip"
|
||||
cp "$b/firmware.uf2" "$dist/$env$suffix-$TAG.uf2"
|
||||
cp "$b/firmware.zip" "$dist/$env$suffix-$TAG.zip"
|
||||
v=$(grep -m1 -aoE 'v[0-9]+\.[0-9]+\.[0-9]+-tth[0-9a-f]+\+?' "$b/firmware.elf" || true)
|
||||
case "$v" in *+) echo "::error::$env is dirty ($v)"; exit 1 ;; esac
|
||||
[ -n "$version" ] || version="$v"
|
||||
|
||||
Reference in new issue
Block a user