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,6 +180,19 @@ jobs:
- name: Generate build-info.json per version - name: Generate build-info.json per version
run: | run: |
human_size() {
local b=$1
local d=''
local s=0
local S=(B KB MB GB TB)
while ((b >= 1024 && s < ${#S[@]}-1)); do
d=$((b % 1024))
b=$((b / 1024))
s=$((s + 1))
done
printf "%s%s\n" "$b" "${S[$s]}"
}
cd upload-repo cd upload-repo
for version in buster bullseye bookworm docker-build; do for version in buster bullseye bookworm docker-build; do
echo "[INFO] Generating build-info.json for $version" echo "[INFO] Generating build-info.json for $version"
@@ -188,21 +201,13 @@ jobs:
image="gitea.fithwum.tech/fithwum/debian-base:$version" image="gitea.fithwum.tech/fithwum/debian-base:$version"
human_size() { digest=$(docker inspect --format='{{if .RepoDigests}}{{index .RepoDigests 0}}{{else}}unknown{{end}}' "$image" 2>/dev/null || echo "unknown")
b=$1 size_bytes=$(docker image inspect "$image" --format='{{.Size}}' 2>/dev/null || echo "0")
d=''
s=0 # Remove any non-digit characters and fallback if empty
S=(B KB MB GB TB) size_bytes=${size_bytes//[^0-9]/}
while ((b >= 1024 && s < ${#S[@]}-1)); do if [[ -z "$size_bytes" ]]; then size_bytes=0; fi
d=$((b % 1024))
b=$((b / 1024))
s=$((s + 1))
done
printf "%s%s\n" "$b" "${S[$s]}"
}
digest=$(docker inspect --format='{{index .RepoDigests 0}}' "$image" || echo "unknown")
size_bytes=$(docker image inspect "$image" --format='{{.Size}}' || echo "0")
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