Skip to content

Commit

Permalink
improve: Just improve release.yml changelog step
Browse files Browse the repository at this point in the history
  • Loading branch information
eloravpn committed Nov 6, 2024
1 parent c4d634a commit eee7b4c
Showing 1 changed file with 28 additions and 33 deletions.
61 changes: 28 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,52 +18,47 @@ jobs:
id: changelog
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
echo "Previous tag: $PREVIOUS_TAG"
if [ -z "$PREVIOUS_TAG" ]; then
# If this is the first tag, get all commits
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges)
CHANGELOG=$(git log --pretty=format:"* %s (%h)" --no-merges)
else
# Get commits between previous tag and current
COMMITS=$(git log --pretty=format:"- %s (%h)" ${PREVIOUS_TAG}..HEAD --no-merges)
CHANGELOG=$(git log --pretty=format:"* %s (%h)" ${PREVIOUS_TAG}..HEAD --no-merges)
fi
# Create changelog content with sections
## For features
# git commit -m "feat: Add new feature"
# git commit -m "add: New component"
#
## For bug fixes
# git commit -m "fix: Resolve issue"
# git commit -m "hotfix: Critical fix"
#
## For improvements
# git commit -m "improve: Better performance"
# git commit -m "update: Enhanced feature"
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "### Changelog" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
# Save changelog to file
echo "### What's Changed" > changelog.md
echo "" >> changelog.md
# Features
echo "#### 🚀 Features" >> $GITHUB_ENV
echo "$COMMITS" | grep -i '^- feat\|^- add\|^- new' || true
echo "" >> $GITHUB_ENV
echo "#### Features" >> changelog.md
echo "$CHANGELOG" | grep -i "^* \(feat\|add\|new\)" >> changelog.md || true
echo "" >> changelog.md
# Bug Fixes
echo "#### 🐛 Bug Fixes" >> $GITHUB_ENV
echo "$COMMITS" | grep -i '^- fix\|^- bug\|^- hotfix' || true
echo "" >> $GITHUB_ENV
echo "#### 🐛 Bug Fixes" >> changelog.md
echo "$CHANGELOG" | grep -i "^* \(fix\|bug\|patch\)" >> changelog.md || true
echo "" >> changelog.md
# Improvements
echo "#### 📈 Improvements" >> $GITHUB_ENV
echo "$COMMITS" | grep -i '^- improve\|^- update\|^- enhance' || true
echo "" >> $GITHUB_ENV
echo "#### 📈 Improvements" >> changelog.md
echo "$CHANGELOG" | grep -i "^* \(improve\|update\|enhance\|refactor\)" >> changelog.md || true
echo "" >> changelog.md
# Documentation
echo "#### 📚 Documentation" >> changelog.md
echo "$CHANGELOG" | grep -i "^* \(doc\|docs\)" >> changelog.md || true
echo "" >> changelog.md
# Other Changes
echo "#### 🔄 Other Changes" >> $GITHUB_ENV
echo "$COMMITS" | grep -v -i '^- feat\|^- add\|^- new\|^- fix\|^- bug\|^- hotfix\|^- improve\|^- update\|^- enhance' || true
echo "" >> $GITHUB_ENV
echo "#### 🔄 Other Changes" >> changelog.md
echo "$CHANGELOG" | grep -v -i "^* \(feat\|add\|new\|fix\|bug\|patch\|improve\|update\|enhance\|refactor\|doc\|docs\)" >> changelog.md || true
# Escape special characters for GitHub Actions
CHANGELOG_CONTENT=$(cat changelog.md)
echo "changelog<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG_CONTENT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# Download Latest Frontend Build
- name: Download frontend release
run: |
Expand Down

0 comments on commit eee7b4c

Please sign in to comment.