size test
All checks were successful
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-rootfs-archives (push) Successful in 6m43s
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-build-info (push) Successful in 58s
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / push-archives-to-repo (push) Successful in 55s
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-and-push-docker-images (push) Has been skipped
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-changelogs (push) Has been skipped

This commit is contained in:
2025-07-06 05:08:08 -07:00
parent c204d9e283
commit 2175f6501c

View File

@@ -180,19 +180,11 @@ jobs:
- name: Generate build-info.json per version - name: Generate build-info.json per version
run: | run: |
cd upload-repo
for version in buster bullseye bookworm docker-build; do
echo "[INFO] Generating build-info.json for $version"
mkdir -p "$version"
infofile="$version/build-info.json"
image="gitea.fithwum.tech/fithwum/debian-base:$version"
human_size() { human_size() {
b=$1 local b=$1
d='' local d=''
s=0 local s=0
S=(B KB MB GB TB) local S=(B KB MB GB TB)
while ((b >= 1024 && s < ${#S[@]}-1)); do while ((b >= 1024 && s < ${#S[@]}-1)); do
d=$((b % 1024)) d=$((b % 1024))
b=$((b / 1024)) b=$((b / 1024))
@@ -201,8 +193,21 @@ jobs:
printf "%s%s\n" "$b" "${S[$s]}" printf "%s%s\n" "$b" "${S[$s]}"
} }
digest=$(docker inspect --format='{{index .RepoDigests 0}}' "$image" || echo "unknown") cd upload-repo
size_bytes=$(docker image inspect "$image" --format='{{.Size}}' || echo "0") for version in buster bullseye bookworm docker-build; do
echo "[INFO] Generating build-info.json for $version"
mkdir -p "$version"
infofile="$version/build-info.json"
image="gitea.fithwum.tech/fithwum/debian-base:$version"
digest=$(docker inspect --format='{{if .RepoDigests}}{{index .RepoDigests 0}}{{else}}unknown{{end}}' "$image" 2>/dev/null || echo "unknown")
size_bytes=$(docker image inspect "$image" --format='{{.Size}}' 2>/dev/null || echo "0")
# Remove any non-digit characters and fallback if empty
size_bytes=${size_bytes//[^0-9]/}
if [[ -z "$size_bytes" ]]; then size_bytes=0; fi
size_human=$(human_size "$size_bytes") size_human=$(human_size "$size_bytes")
jq -n --arg version "$version" \ jq -n --arg version "$version" \
@@ -210,14 +215,14 @@ jobs:
--arg build_time "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ --arg build_time "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--arg image_tag "$image" \ --arg image_tag "$image" \
--arg digest "$digest" \ --arg digest "$digest" \
--argjson size "$size" \ --arg image_size "$size_human" \
'{ '{
version: $version, version: $version,
commit: $commit, commit: $commit,
build_time: $build_time, build_time: $build_time,
image_tag: $image_tag, image_tag: $image_tag,
digest: $digest, digest: $digest,
image_size: $size image_size: $image_size
}' > "$infofile" }' > "$infofile"
done done