Update CHANGELOG.md #18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: change | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate | |
run: | | |
tags=$(git tag --sort=creatordate) | |
previous="" | |
if [ ! -f CHANGELOG.md ]; then | |
echo "" > CHANGELOG.md | |
else | |
previous=$(grep -oP '^## \K.*' CHANGELOG.md | tail -n 1) | |
fi | |
for tag in $tags; do | |
if [ -n "$previous" ]; then | |
echo "## $tag" >> CHANGELOG.md | |
git log --pretty=format:"* %s (%h)" "$previous..$tag" >> CHANGELOG.md | |
echo -e "\n" >> CHANGELOG.md | |
fi | |
previous=$tag | |
done | |
- name: Commit | |
run: | | |
git diff --quiet | |
echo "Exit status: $?" | |
if ! git diff --quiet; then | |
echo "Commit pushing" | |
git add CHANGELOG.md | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -m "Update changelog" | |
git push | |
if [ $? -eq 0 ]; then | |
echo "Push succeeded" | |
else | |
echo "Push failed" | |
exit 1 | |
fi | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |