Skip to content

Commit 3cd8bc6

Browse files
committed
feat(changelog): improve changelog generation logic
- Added logic to find the latest stable version tag for changelog comparison. - Enhanced handling of cases with no significant changes detected. - Updated the output format of the changelog for better readability.
1 parent d3df1c9 commit 3cd8bc6

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

.github/workflows/build_app.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,20 +587,33 @@ jobs:
587587
- name: Generate changelog
588588
if: steps.check.outputs.ready == 'true'
589589
id: changelog
590+
env:
591+
RELEASE_TAG: ${{ steps.check.outputs.release_tag }}
590592
run: |
591-
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
593+
# Find the latest stable version tag (v0.0.1, v0.0.2, etc.)
594+
latestVersionTag=$(git tag -l --sort=-v:refname | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1 || true)
595+
596+
echo "Latest version tag: $latestVersionTag"
597+
echo "Current release tag: $RELEASE_TAG"
592598
593-
if [ -z "$PREVIOUS_TAG" ]; then
594-
COMMITS=$(git log --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" --no-merges)
599+
if [ -n "$latestVersionTag" ]; then
600+
commits=$(git log "$latestVersionTag..HEAD" --pretty=format:"* %s %h" --no-merges)
595601
else
596-
COMMITS=$(git log "$PREVIOUS_TAG..HEAD" --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" --no-merges)
602+
commits=$(git log -n 20 --pretty=format:"* %s %h" --no-merges)
597603
fi
598604
599-
echo "## What's Changed" > CHANGELOG.md
600-
echo "" >> CHANGELOG.md
601-
echo "$COMMITS" >> CHANGELOG.md
602-
echo "" >> CHANGELOG.md
603-
echo "---" >> CHANGELOG.md
605+
if [ -z "$commits" ]; then
606+
if [ -n "$latestVersionTag" ]; then
607+
commits="* No significant changes detected since $latestVersionTag"
608+
else
609+
commits="* No significant changes detected"
610+
fi
611+
fi
612+
613+
printf '%s\n' "$commits" > CHANGELOG.md
614+
615+
echo "Changelog content:"
616+
cat CHANGELOG.md
604617
605618
- name: Publish release
606619
if: steps.check.outputs.ready == 'true'

0 commit comments

Comments
 (0)