From 6abc278449535976460fd0ac2d4ea9ebf254f556 Mon Sep 17 00:00:00 2001 From: fithwum Date: Sun, 13 Jul 2025 06:01:33 -0700 Subject: [PATCH] update workflow --- .gitea/workflows/base-build.yml | 130 ++++++++++++++++---------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/.gitea/workflows/base-build.yml b/.gitea/workflows/base-build.yml index cdfbd57..214804e 100644 --- a/.gitea/workflows/base-build.yml +++ b/.gitea/workflows/base-build.yml @@ -156,71 +156,6 @@ jobs: echo "[INFO] Building $IMAGE" docker buildx build --platform linux/amd64 --push -t "$IMAGE" --metadata-file "$METAFILE2" ./basic - generate-changelogs: - needs: check-for-changes - if: | - needs.check-for-changes.outputs.should_build_alpine == 'true' || - needs.check-for-changes.outputs.should_build_debian == 'true' || - needs.check-for-changes.outputs.should_build_basic == 'true' - runs-on: vm-docker-build2 - steps: - - name: Checkout source - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Generate changelogs only for updated variants - run: | - versions=() - if [[ "${{ needs.check-for-changes.outputs.should_build_alpine }}" == "true" ]]; then - versions+=("alpine") - fi - if [[ "${{ needs.check-for-changes.outputs.should_build_debian }}" == "true" ]]; then - versions+=("debian") - fi - if [[ "${{ needs.check-for-changes.outputs.should_build_basic }}" == "true" ]]; then - versions+=("basic") - fi - - for version in "${versions[@]}"; do - echo "[INFO] Updating changelog for $version" - changelog="$version/CHANGES.md" - mkdir -p "$(dirname "$changelog")" - touch "$changelog" - - infofile="$version/build-info.json" - last_commit="" - if [ -f "$infofile" ]; then - last_commit=$(jq -r '.commit' "$infofile") - fi - - # Check if last_commit exists in history, fallback to last 10 commits if not - if ! git cat-file -e "${last_commit}^{commit}" 2>/dev/null; then - echo "[WARN] Last commit from build-info.json not found, using last 10 commits" - last_commit="" - fi - - echo -e "\n## $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$changelog" - - if [ -n "$last_commit" ]; then - git log "${last_commit}..HEAD" --pretty=format:"- %s (%an)" --no-merges --invert-grep --grep="Update changelogs on" | head -n 10 >> "$changelog" - else - git log -n 10 --pretty=format:"- %s (%an)" --no-merges --invert-grep --grep="Update changelogs on" >> "$changelog" - fi - done - - - name: Commit and push changelogs - run: | - git config user.name "${{ secrets.GIT_USERNAME }}" - git config user.email "${{ secrets.GIT_EMAIL }}" - if git status --porcelain | grep .; then - 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-alpine @@ -347,3 +282,68 @@ jobs: ls -l basic/build-info.json || echo "❌ build-info not written" cat basic/build-info.json || echo "❌ empty build-info" + +generate-changelogs: + needs: generate-build-info + if: | + needs.check-for-changes.outputs.should_build_alpine == 'true' || + needs.check-for-changes.outputs.should_build_debian == 'true' || + needs.check-for-changes.outputs.should_build_basic == 'true' + runs-on: vm-docker-build2 + steps: + - name: Checkout source + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Generate changelogs only for updated variants + run: | + versions=() + if [[ "${{ needs.check-for-changes.outputs.should_build_alpine }}" == "true" ]]; then + versions+=("alpine") + fi + if [[ "${{ needs.check-for-changes.outputs.should_build_debian }}" == "true" ]]; then + versions+=("debian") + fi + if [[ "${{ needs.check-for-changes.outputs.should_build_basic }}" == "true" ]]; then + versions+=("basic") + fi + + for version in "${versions[@]}"; do + echo "[INFO] Updating changelog for $version" + changelog="$version/CHANGES.md" + mkdir -p "$(dirname "$changelog")" + touch "$changelog" + + infofile="$version/build-info.json" + last_commit="" + if [ -f "$infofile" ]; then + last_commit=$(jq -r '.commit' "$infofile") + fi + + # Check if last_commit exists in history, fallback to last 10 commits if not + if ! git cat-file -e "${last_commit}^{commit}" 2>/dev/null; then + echo "[WARN] Last commit from build-info.json not found, using last 10 commits" + last_commit="" + fi + + echo -e "\n## $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$changelog" + + if [ -n "$last_commit" ]; then + git log "${last_commit}..HEAD" --pretty=format:"- %s (%an)" --no-merges --invert-grep --grep="Update changelogs on" | head -n 10 >> "$changelog" + else + git log -n 10 --pretty=format:"- %s (%an)" --no-merges --invert-grep --grep="Update changelogs on" >> "$changelog" + fi + done + + - name: Commit and push changelogs + run: | + git config user.name "${{ secrets.GIT_USERNAME }}" + git config user.email "${{ secrets.GIT_EMAIL }}" + if git status --porcelain | grep .; then + 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 \ No newline at end of file