Skip to content

Commit

Permalink
Update release message
Browse files Browse the repository at this point in the history
  • Loading branch information
chen08209 committed Oct 12, 2024
1 parent 16e2ea8 commit c3fc43b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 67 deletions.
55 changes: 54 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
pattern: artifact-*
merge-multiple: true

- name: Generate release.md
- name: Generate release
run: |
tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate))
preTag=$(curl --silent "https://api.github.com/repos/chen08209/FlClash/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' || echo "")
Expand Down Expand Up @@ -159,6 +159,7 @@ jobs:
currentTag=$tag
done
- name: Get Branch
run: |
branch=$(git branch --contains ${{ github.ref_name }} | grep -v "detached" | sed 's/* //')
Expand All @@ -174,6 +175,58 @@ jobs:
retention-days: 7
overwrite: true

- name: Generate changelog
if: env.BRANCH == 'main'
run: |
tags=($(git tag --merged $(git rev-parse HEAD) --sort=-creatordate))
preTag=""
currentTag=""
if [ -f CHANGELOG.md ]; then
preTag=$(grep -oP '^## \K.*' CHANGELOG.md | head -n 1)
fi
for ((i = 0; i <= ${#tags[@]}; i++)); do
if (( i < ${#tags[@]} )); then
tag=${tags[$i]}
else
tag=""
fi
if [ -n "$currentTag" ]; then
if [ "$(echo -e "$currentTag\n$preTag" | sort -V | head -n 1)" == "$currentTag" ]; then
break
fi
fi
if [ -n "$currentTag" ]; then
echo "## $currentTag" >> NEW_CHANGELOG.md
echo "" >> NEW_CHANGELOG.md
if [ -n "$tag" ]; then
git log --pretty=format:"%B" "$tag..$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> NEW_CHANGELOG.md
else
git log --pretty=format:"%B" "$currentTag" | awk 'NF {print "- " $0} !NF {print ""}' >> NEW_CHANGELOG.md
fi
echo "" >> NEW_CHANGELOG.md
fi
currentTag=$tag
done
if [ -f CHANGELOG.md ]; then
cat CHANGELOG.md >> NEW_CHANGELOG.md
fi
mv NEW_CHANGELOG.md CHANGELOG.md
- name: Commit
run: |
git config --local user.email "[email protected]"
git config --local user.name "chen08209"
git add CHANGELOG.md
if ! git diff --cached --quiet; then
git commit -m "Update changelog"
git push
else
echo "CHANGELOG.md not changed"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release
if: env.BRANCH == 'main'
uses: softprops/action-gh-release@v2
Expand Down
66 changes: 0 additions & 66 deletions .github/workflows/change.yml

This file was deleted.

0 comments on commit c3fc43b

Please sign in to comment.