Skip to content

Commit

Permalink
Feature: Add and Test Automated Changelog Generation 🚀
Browse files Browse the repository at this point in the history
### 🆕 What's New:
- 🚀 **Feature:** Implement automated changelog generation using GitHub Actions and bash script.
- 🐛 **Fix:** Corrected environment variable export for multiline changelogs.
- 📄 **Docs:** Updated release-windows-dotnet.yml to improve changelog readability.
- 🔧 **Enhancement:** Added user-friendly emojis and section headers in the generated changelog.

---

### 🔗 Notes:
- This commit aims to validate the changelog pipeline and ensure all generated releases display proper markdown formatting.
- Full commit history will be available in the **Compare Changes** section after the release.

---

🔥 Let's test the **automated changelog** generation and see how it performs in action!
  • Loading branch information
louanfontenele committed Dec 29, 2024
1 parent d86b8ea commit f9eeae4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ categories:
- title: "🐛 Bug Fixes"
labels:
- "fix"
- title: "🛠️ Maintenance"
- title: "🧩 Maintenance"
labels:
- "chore"
- "refactor"
Expand Down
35 changes: 19 additions & 16 deletions .github/scripts/generate-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,31 @@ CHANGELOG_FILE="CHANGELOG.md"
LATEST_TAG=${previous_tag:-"N/A"}
NEW_TAG=${current_tag:-"N/A"}

# Fetch GitHub username using GitHub API
GITHUB_USERNAME=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/users/$(git config user.email | cut -d'@' -f1)" | jq -r .login)

# Initialize changelog
if [ "$LATEST_TAG" == "N/A" ]; then
echo "No previous tag found. Initial release."
LATEST_TAG=""
fi

# Create or update the changelog
echo "## Release $NEW_TAG" > $CHANGELOG_FILE
echo "What's Changed" >> $CHANGELOG_FILE
echo "# 🚀 Release $NEW_TAG" > $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE
echo "🎉 **What's New in this Release?**" >> $CHANGELOG_FILE
echo "🔍 Review the full list of changes below." >> $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE
echo "---" >> $CHANGELOG_FILE

# Append commit history
if [ -n "$LATEST_TAG" ]; then
git log --pretty=format:"- %s by @$GITHUB_USERNAME" $LATEST_TAG..HEAD >> $CHANGELOG_FILE
else
git log --pretty=format:"- %s by @$GITHUB_USERNAME" HEAD >> $CHANGELOG_FILE
fi
# Generate sections for features, fixes, and other changes
echo "## 🚀 Features" >> $CHANGELOG_FILE
git log --pretty=format:"- 🚀 **Feature:** %s by @%an" $LATEST_TAG..HEAD --grep "Feature:" >> $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE

echo "## 🐛 Bug Fixes" >> $CHANGELOG_FILE
git log --pretty=format:"- 🐛 **Fix:** %s by @%an" $LATEST_TAG..HEAD --grep "Fix:" >> $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE
REPO_URL="https://github.com/${GITHUB_REPOSITORY}/compare/"
echo "**Full commit history:** [Compare Changes](${REPO_URL}${LATEST_TAG}...${NEW_TAG})" >> $CHANGELOG_FILE

echo "## 🧩 Enhancements" >> $CHANGELOG_FILE
git log --pretty=format:"- 🧩 **Update:** %s by @%an" $LATEST_TAG..HEAD --grep "Update:" >> $CHANGELOG_FILE
echo "" >> $CHANGELOG_FILE

# Full commit history link
echo "## 📦 Full Commit History" >> $CHANGELOG_FILE
echo "**[🔗 Compare Changes](https://github.com/${GITHUB_REPOSITORY}/compare/${LATEST_TAG}...${NEW_TAG})**" >> $CHANGELOG_FILE
12 changes: 9 additions & 3 deletions .github/workflows/release-windows-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ jobs:
- name: Create Zip Archive
run: zip -r release.zip release/

# Set Git Identity for Tagging
- name: Set Git Identity
run: |
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
# Generate Tags Automatically
- name: Generate Version Tag
id: tag
run: |
Expand All @@ -65,34 +67,38 @@ jobs:
echo "::set-output name=previous_tag::$LATEST_TAG"
echo "::set-output name=current_tag::$NEW_TAG"
# Grant Execute Permissions for the Script
- name: Grant execute permissions to the script
run: chmod +x .github/scripts/generate-changelog.sh

# Run Changelog Generation Script
- name: Generate Changelog from Script
run: ./.github/scripts/generate-changelog.sh
env:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.TOKEN }}

# Read Changelog Content into Environment Variable
- name: Read Changelog
run: |
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
cat CHANGELOG.md >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# Draft the Release with Changelog
- name: Draft Release
id: draft_release
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Publish the Release
- name: Publish Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.current_tag }}
name: "Release ${{ env.current_tag }}"
name: "Release ${{ env.current_tag }} 🚀"
body: ${{ env.CHANGELOG }}
artifacts: "release.zip"
draft: false
Expand Down

0 comments on commit f9eeae4

Please sign in to comment.