From 778a34d631fe322da82cd0b00979058b62d7160b Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Wed, 20 Aug 2025 09:17:53 +0100 Subject: [PATCH] feat: Implement fallback to commit messages in changelog if empty --- .github/workflows/release.yml | 39 +++++++++++++++++++++++++++- Scripts/Release/ChangelogConfig.json | 2 +- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index acd5ceab14..d036613c0d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1898,12 +1898,49 @@ jobs: configuration: "./Scripts/Release/ChangelogConfig.json" - run: echo "Changelog:" - run: echo "${{steps.build_changelog.outputs.changelog}}" + - name: Fallback to commit messages if changelog empty + id: fallback_changelog + shell: bash + run: | + set -euo pipefail + CHANGELOG_CONTENT="${{steps.build_changelog.outputs.changelog}}" + OLD_PLACEHOLDER="No significant changes were made. We have just fixed minor bugs for this release. You can find the detailed information in the commit history." + NEW_PLACEHOLDER="(auto) No categorized pull requests. Fallback will list raw commit messages." + if echo "$CHANGELOG_CONTENT" | grep -Fq "$OLD_PLACEHOLDER" || echo "$CHANGELOG_CONTENT" | grep -Fq "$NEW_PLACEHOLDER"; then + echo "Detected empty placeholder changelog. Building commit list fallback." + # Find previous tag (skip the most recent tag which might be for an older release). If none, include all commits. + if prev_tag=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null); then + echo "Previous tag: $prev_tag" + commits=$(git log --pretty=format:'- %s (%h)' "$prev_tag"..HEAD) + else + echo "No previous tag found; using full commit history on this branch." + commits=$(git log --pretty=format:'- %s (%h)') + fi + # If still empty (e.g., no commits), keep placeholder to avoid empty body. + if [ -z "$commits" ]; then + commits="(no commits found)" + fi + { + echo "changelog<<'EOF'" + echo "## Commit Messages" + echo "" + echo "$commits" + echo "EOF" + } >> "$GITHUB_OUTPUT" + else + # Pass through original changelog + { + echo "changelog<<'EOF'" + echo "$CHANGELOG_CONTENT" + echo "EOF" + } >> "$GITHUB_OUTPUT" + fi - uses: ncipollo/release-action@v1 with: tag: "7.0.${{needs.generate-build-number.outputs.build_number}}" artifactErrorsFailBuild: true body: | - ${{steps.build_changelog.outputs.changelog}} + ${{steps.fallback_changelog.outputs.changelog}} infrastructure-agent-deploy: diff --git a/Scripts/Release/ChangelogConfig.json b/Scripts/Release/ChangelogConfig.json index 0b163e1a9a..0363792aae 100644 --- a/Scripts/Release/ChangelogConfig.json +++ b/Scripts/Release/ChangelogConfig.json @@ -35,7 +35,7 @@ }, "template": "#{{CHANGELOG}}\n\n
\nChanges\n\n#{{UNCATEGORIZED}}\n
", "pr_template": "- #{{TITLE}}\n - PR: ##{{NUMBER}}", - "empty_template": "No significant changes were made. We have just fixed minor bugs for this release. You can find the detailed information in the commit history.", + "empty_template": "(auto) No categorized pull requests. Fallback will list raw commit messages.", "label_extractor": [ { "pattern": "(.) (.+)",