From a98403b2e0a50e8ee9d3ddb38a92221270dee5ed Mon Sep 17 00:00:00 2001 From: fithwum Date: Thu, 10 Jul 2025 06:39:27 -0700 Subject: [PATCH] fix spaceing --- .gitea/workflows/base-build.yml | 318 ++++++++++++++++---------------- 1 file changed, 159 insertions(+), 159 deletions(-) diff --git a/.gitea/workflows/base-build.yml b/.gitea/workflows/base-build.yml index 542aa9a..b2f0ae6 100644 --- a/.gitea/workflows/base-build.yml +++ b/.gitea/workflows/base-build.yml @@ -115,174 +115,174 @@ jobs: IMAGE="$IMAGE_REGISTRY/$IMAGE_ORG/$IMAGE_REPO_MINECRAFT:${{ matrix.version }}" docker buildx build --platform linux/amd64 --push -t "$IMAGE" "./${{ matrix.version }}" -generate-changelogs: - needs: poll-debian-base-and-detect-changes - if: needs.poll-debian-base-and-detect-changes.outputs.digest_changed == 'true' || needs.poll-debian-base-and-detect-changes.outputs.versions_changed != '' - runs-on: doc-docker-build2 - strategy: - matrix: - version: [vanilla, testing, fabric] + generate-changelogs: + needs: poll-debian-base-and-detect-changes + if: needs.poll-debian-base-and-detect-changes.outputs.digest_changed == 'true' || needs.poll-debian-base-and-detect-changes.outputs.versions_changed != '' + runs-on: doc-docker-build2 + strategy: + matrix: + version: [vanilla, testing, fabric] - steps: - - name: Checkout repo - uses: actions/checkout@v3 + steps: + - name: Checkout repo + uses: actions/checkout@v3 - - name: Clone Minecraft repo (with retries) - 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 - - - name: Generate changelog - run: | - cd upload-repo - changelog="${{ matrix.version }}/CHANGES.md" - mkdir -p "$(dirname "$changelog")" - touch "$changelog" - - 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 - 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 push - else - echo "[INFO] No changelog changes to commit." - fi - -generate-build-info: - 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) - 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 - - - name: Generate build-info.json - run: | - human_size() { - local b=$1 d='' s=0 S=(B KB MB GB TB) - while ((b >= 1024 && s < ${#S[@]}-1)); do - d=$((b % 1024)); b=$((b / 1024)); s=$((s + 1)) + - name: Clone Minecraft repo (with retries) + 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 - printf "%s%s\n" "$b" "${S[$s]}" - } + if [ ! -d upload-repo ]; then + echo "[ERROR] Failed to clone Minecraft repo after retries." + exit 1 + fi - 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 }}" + - name: Generate changelog + run: | + cd upload-repo + changelog="${{ matrix.version }}/CHANGES.md" + mkdir -p "$(dirname "$changelog")" + touch "$changelog" - 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 + infofile="${{ matrix.version }}/build-info.json" + last_commit="" + if [ -f "$infofile" ]; then + last_commit=$(jq -r '.commit' "$infofile") + fi - size_human=$(human_size "$size_bytes") + echo -e "## $(date -u +'%Y-%m-%dT%H:%M:%SZ')\n" >> "$changelog" - 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" + if [ -n "$last_commit" ]; then + COMMITS=$(git log "${last_commit}..HEAD" --pretty=format:"- %s (%an)" || true) + fi - echo "[INFO] Generated $infofile:" - cat "$infofile" + 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 - - name: Git status debug - run: | - cd upload-repo - echo "[DEBUG] Git status before commit:" - git status - echo "[DEBUG] Git diff:" - git diff "${{ matrix.version }}/build-info.json" || true + echo "$COMMITS" >> "$changelog" - - name: Commit and push build-info - run: | - cd upload-repo - git config user.name "${{ secrets.GIT_USERNAME }}" - git config user.email "${{ secrets.GIT_EMAIL }}" + - name: Show git status (debug) + run: | + cd upload-repo + echo "[DEBUG] Git status before commit:" + git status + echo "[DEBUG] Git diff:" + git diff - 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 push + - name: Commit and push changelog + 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 push + else + echo "[INFO] No changelog changes to commit." + fi - TAG="build-${{ matrix.version }}" - git tag -d "$TAG" 2>/dev/null || true - git tag "$TAG" - git push origin "$TAG" --force - else - echo "[INFO] No build-info changes to commit." - fi + generate-build-info: + 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) + 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 + + - name: Generate build-info.json + run: | + human_size() { + local b=$1 d='' s=0 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 + mkdir -p "${{ matrix.version }}" + infofile="${{ matrix.version }}/build-info.json" + image="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_ORG }}/${{ env.IMAGE_REPO_MINECRAFT }}:${{ matrix.version }}" + + 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") + + 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" + + echo "[INFO] Generated $infofile:" + cat "$infofile" + + - name: Git status debug + run: | + cd upload-repo + echo "[DEBUG] Git status before commit:" + git status + echo "[DEBUG] Git diff:" + git diff "${{ matrix.version }}/build-info.json" || true + + - name: Commit and push build-info + 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 }}/build-info.json" + git commit -m "Update build-info for ${{ matrix.version }} on $(date -u +'%Y-%m-%dT%H:%M:%SZ')" || true + git push + + TAG="build-${{ matrix.version }}" + git tag -d "$TAG" 2>/dev/null || true + git tag "$TAG" + git push origin "$TAG" --force + else + echo "[INFO] No build-info changes to commit." + fi