-
Notifications
You must be signed in to change notification settings - Fork 744
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
67 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 "") | ||
|
@@ -159,6 +159,7 @@ jobs: | |
currentTag=$tag | ||
done | ||
- name: Get Branch | ||
run: | | ||
branch=$(git branch --contains ${{ github.ref_name }} | grep -v "detached" | sed 's/* //') | ||
|
@@ -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 | ||
|
This file was deleted.
Oops, something went wrong.