test
All checks were successful
Build and Push Minecraft Docker Images on Debian-base update / poll-debian-base-and-detect-changes (push) Successful in 9s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push testing (push) Successful in 10s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push fabric (push) Successful in 10s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push vanilla (push) Successful in 10s
Build and Push Minecraft Docker Images on Debian-base update / generate-changelogs (push) Successful in 5s
Build and Push Minecraft Docker Images on Debian-base update / generate-build-info (push) Successful in 7s

This commit is contained in:
2025-07-10 11:58:17 -07:00
parent c15decb4db
commit a79d7d0975

View File

@@ -118,99 +118,82 @@ jobs:
generate-changelogs:
needs: build-minecraft-images
runs-on: doc-docker-build2
strategy:
matrix:
version: [vanilla, testing, fabric]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Clone Minecraft repo (with retries)
- name: Create temporary changelog workspace
run: mkdir -p changelogs
- name: Clone Minecraft repo
run: |
GIT_CREDENTIAL="${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}"
for i in {1..5}; do
git clone "https://${{ secrets.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/minecraft.git" upload-repo && break
echo "[WARN] Clone attempt $i failed. Retrying in 10s..."
sleep 10
git clone --depth=3 "https://${{ secrets.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/minecraft.git" upload-repo
- name: Generate changelogs
run: |
for version in $VERSIONS; do
echo "[INFO] Generating changelog for $version"
changelog="changelogs/$version/CHANGES.md"
mkdir -p "$(dirname "$changelog")"
touch "$changelog"
cd upload-repo
infofile="$version/build-info.json"
last_commit=""
if [ -f "$infofile" ]; then
last_commit=$(jq -r '.commit' "$infofile")
fi
echo -e "## $(date -u +'%Y-%m-%dT%H:%M:%SZ')\n" > "../$changelog"
if [ -n "$last_commit" ]; then
COMMITS=$(git log "${last_commit}..HEAD" --pretty=format:"- %s (%an)" || true)
fi
if [ -z "$COMMITS" ]; then
echo "[INFO] No new commits since last build. Showing latest 5 instead."
COMMITS=$(git log -n 5 --pretty=format:"- %s (%an)" || true)
fi
echo "$COMMITS" >> "../$changelog"
cd ..
done
if [ ! -d upload-repo ]; then
echo "[ERROR] Failed to clone Minecraft repo after retries."
exit 1
fi
- name: Generate changelog
- name: Copy changelogs into repo
run: |
cd upload-repo
changelog="${{ matrix.version }}/CHANGES.md"
mkdir -p "$(dirname "$changelog")"
touch "$changelog"
for version in $VERSIONS; do
mkdir -p upload-repo/$version
cp changelogs/$version/CHANGES.md upload-repo/$version/
done
infofile="${{ matrix.version }}/build-info.json"
last_commit=""
if [ -f "$infofile" ]; then
last_commit=$(jq -r '.commit' "$infofile")
fi
echo -e "## $(date -u +'%Y-%m-%dT%H:%M:%SZ')\n" >> "$changelog"
if [ -n "$last_commit" ]; then
COMMITS=$(git log "${last_commit}..HEAD" --pretty=format:"- %s (%an)" || true)
fi
if [ -z "$COMMITS" ]; then
echo "[INFO] No new commits since last build. Showing latest 5 instead."
COMMITS=$(git log -n 5 --pretty=format:"- %s (%an)" || true)
fi
echo "$COMMITS" >> "$changelog"
- name: Show git status (debug)
run: |
cd upload-repo
echo "[DEBUG] Git status before commit:"
git status
echo "[DEBUG] Git diff:"
git diff
- name: Commit and push changelog
- name: Commit and push changelogs
run: |
cd upload-repo
git config user.name "${{ secrets.GIT_USERNAME }}"
git config user.email "${{ secrets.GIT_EMAIL }}"
if git status --porcelain | grep .; then
git add "${{ matrix.version }}/CHANGES.md"
git commit -m "Update changelog for ${{ matrix.version }}" || true
git add */CHANGES.md
git commit -m "Update changelogs on $(date -u +'%Y-%m-%dT%H:%M:%SZ')" --no-verify
git push
else
echo "[INFO] No changelog changes to commit."
fi
generate-build-info:
needs: build-minecraft-images
needs: generate-changelogs
runs-on: doc-docker-build2
strategy:
matrix:
version: [vanilla, testing, fabric]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Clone Minecraft repo (with retries)
- name: Prepare temporary build-info workspace
run: mkdir -p buildinfo
- name: Clone Minecraft repo
run: |
GIT_CREDENTIAL="${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}"
for i in {1..5}; do
git clone "https://${{ secrets.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/minecraft.git" upload-repo && break
echo "[WARN] Clone attempt $i failed. Retrying in 10s..."
sleep 10
done
if [ ! -d upload-repo ]; then
echo "[ERROR] Failed to clone Minecraft repo after retries."
exit 1
fi
git clone --depth=1 "https://${{ secrets.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/minecraft.git" upload-repo
- name: Generate build-info.json
- name: Generate build-info files
run: |
human_size() {
local b=$1 d='' s=0 S=(B KB MB GB TB)
@@ -220,52 +203,54 @@ jobs:
printf "%s%s\n" "$b" "${S[$s]}"
}
cd upload-repo
mkdir -p "${{ matrix.version }}"
infofile="${{ matrix.version }}/build-info.json"
image="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_ORG }}/${{ env.IMAGE_REPO_MINECRAFT }}:${{ matrix.version }}"
for version in $VERSIONS; do
echo "[INFO] Generating build-info.json for $version"
image="${IMAGE_REGISTRY}/${IMAGE_ORG}/${IMAGE_REPO_MINECRAFT}:$version"
infofile="buildinfo/$version/build-info.json"
mkdir -p "$(dirname "$infofile")"
if ! docker pull "$image"; then
echo "[WARN] Failed to pull $image — setting fields to unknown/0"
digest="unknown"
size_bytes=0
else
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
fi
if ! docker pull "$image"; then
echo "[WARN] Failed to pull $image — setting fields to unknown/0"
digest="unknown"
size_bytes=0
else
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
fi
size_human=$(human_size "$size_bytes")
size_human=$(human_size "$size_bytes")
jq -n \
--arg version "${{ matrix.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" \
'{
version: $version,
commit: $commit,
build_time: $build_time,
image_tag: $image_tag,
digest: $digest,
image_size: $image_size,
image_size_bytes: $image_size_bytes
}' > "$infofile"
cd upload-repo
commit=$(git rev-parse HEAD)
cd ..
echo "[INFO] Generated $infofile:"
cat "$infofile"
jq -n \
--arg version "$version" \
--arg commit "$commit" \
--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" \
'{
version: $version,
commit: $commit,
build_time: $build_time,
image_tag: $image_tag,
digest: $digest,
image_size: $image_size,
image_size_bytes: $image_size_bytes
}' > "$infofile"
done
- name: Git status debug
- name: Copy build-info.json into repo
run: |
cd upload-repo
echo "[DEBUG] Git status before commit:"
git status
echo "[DEBUG] Git diff:"
git diff "${{ matrix.version }}/build-info.json" || true
for version in $VERSIONS; do
mkdir -p upload-repo/$version
cp "buildinfo/$version/build-info.json" "upload-repo/$version/"
done
- name: Commit and push build-info
run: |
@@ -274,14 +259,16 @@ jobs:
git config user.email "${{ secrets.GIT_EMAIL }}"
if git status --porcelain | grep .; then
git add "${{ matrix.version }}/build-info.json"
git commit -m "Update build-info for ${{ matrix.version }} on $(date -u +'%Y-%m-%dT%H:%M:%SZ')" || true
git add */build-info.json
git commit -m "Update build-info on $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
git push
TAG="build-${{ matrix.version }}"
git tag -d "$TAG" 2>/dev/null || true
git tag "$TAG"
git push origin "$TAG" --force
for version in $VERSIONS; do
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