test build info update & changelog
Some checks failed
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-and-push-rootfs-archives (push) Successful in 11m52s
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-changelogs (push) Successful in 1m10s
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-and-push-docker-images (push) Successful in 2m33s
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-build-info (push) Failing after 37s

This commit is contained in:
2025-07-09 10:51:02 -07:00
parent 0a58573934
commit 3012dd0304

View File

@@ -231,102 +231,106 @@ jobs:
needs: build-and-push-docker-images
runs-on: doc2-docker-build
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Checkout source
uses: actions/checkout@v3
- name: Clone upload repo
run: |
GIT_CREDENTIAL="${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}"
git clone --depth=1 "https://${{ env.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/debian-base.git" upload-repo
- name: Prepare temporary build-info workspace
run: mkdir -p buildinfo
- name: Copy checksum file into workspace
run: |
- name: Copy sha256sums.txt if available
run: |
if [[ -f ../sha256sums.txt ]]; then
cp ../sha256sums.txt buildinfo/
else
echo "[ERROR] sha256sums.txt missing!"
exit 1
fi
- name: Generate build-info.json files
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 buildinfo
for version in $VERSIONS; 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")
size_bytes=${size_bytes//[^0-9]/}
[[ -z "$size_bytes" ]] && size_bytes=0
size_human=$(human_size "$size_bytes")
sha256="unknown"
if [[ -f ../sha256sums.txt ]]; then
cp ../sha256sums.txt upload-repo/
else
echo "[ERROR] sha256sums.txt missing!"
exit 1
sha256=$(grep "$version/debian-$version.tar.bz2" ../sha256sums.txt | awk '{print $1}')
[[ -z "$sha256" ]] && sha256="unknown"
fi
- name: Generate build-info.json per version
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]}"
}
jq -n \
--arg version "$version" \
--arg commit "$(git rev-parse HEAD)" \
--arg build_time "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--arg image_tag "$image" \
--arg digest "$digest" \
--arg image_size "$size_human" \
--argjson image_size_bytes "$size_bytes" \
--arg sha256 "$sha256" \
'{
version: $version,
commit: $commit,
build_time: $build_time,
image_tag: $image_tag,
digest: $digest,
image_size: $image_size,
image_size_bytes: $image_size_bytes,
rootfs_sha256: $sha256
}' > "$infofile"
done
- name: Clone upload repo
run: |
GIT_CREDENTIAL="${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}"
git clone --depth=1 "https://${{ env.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/debian-base.git" upload-repo
- name: Copy build-info.json into repo
run: |
for version in $VERSIONS; do
mkdir -p "upload-repo/$version"
cp "buildinfo/$version/build-info.json" "upload-repo/$version/build-info.json"
done
- name: Commit and push build-info if changed
run: |
cd upload-repo
git config --global user.name "${{ env.GIT_USERNAME }}"
git config --global user.email "${{ env.GIT_EMAIL }}"
if git status --porcelain | grep .; then
git add */build-info.json
git commit -m "Update build-info on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
git push
cd upload-repo
for version in $VERSIONS; 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")
size_bytes=${size_bytes//[^0-9]/}
if [[ -z "$size_bytes" ]]; then size_bytes=0; fi
size_human=$(human_size "$size_bytes")
# Load SHA256 from file if available
SHA256=$(grep "$version/debian-$version.tar.bz2" ../sha256sums.txt | awk '{print $1}')
if [[ -z "$SHA256" ]]; then
SHA256="unknown"
fi
jq -n \
--arg version "$version" \
--arg commit "$(git rev-parse HEAD)" \
--arg build_time "$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--arg image_tag "$image" \
--arg digest "$digest" \
--arg image_size "$size_human" \
--argjson image_size_bytes "$size_bytes" \
--arg sha256 "$SHA256" \
'{
version: $version,
commit: $commit,
build_time: $build_time,
image_tag: $image_tag,
digest: $digest,
image_size: $image_size,
image_size_bytes: $image_size_bytes,
rootfs_sha256: $sha256
}' > "$infofile"
- name: Commit and push build-info if changed
run: |
cd upload-repo
git config --global user.name "${{ env.GIT_USERNAME }}"
git config --global user.email "${{ env.GIT_EMAIL }}"
if git status --porcelain | grep .; then
git add */build-info.json
git commit -m "Update build-info on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
git push
# Tag the commit for each version
for version in $VERSIONS; do
TAG="build-$version"
# Delete local tag if exists
git tag -d "$TAG" 2>/dev/null || true
# Create tag on current HEAD
git tag "$TAG"
# Push tag to remote (force in case tag exists)
git push origin "$TAG" --force
done
else
echo "[INFO] No build-info changes to commit."
fi
TAG="build-$version"
git tag -d "$TAG" 2>/dev/null || true
git tag "$TAG"
git push origin "$TAG" --force
done
else
echo "[INFO] No build-info changes to commit."
fi