diff --git a/.github/genReleaseNote.sh b/.github/genReleaseNote.sh new file mode 100755 index 00000000..0425061d --- /dev/null +++ b/.github/genReleaseNote.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +while getopts "v:" opt; do + case $opt in + v) + version_range=$OPTARG + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + esac +done + +if [ -z "$version_range" ]; then + echo "Please provide the version range using -v option. Example: ./genReleashNote.sh -v v1.14.1...v1.14.2" + exit 1 +fi + +echo "## What's Changed" > release.md +git log --pretty=format:"* %s by @%an" --grep="^feat" -i $version_range | sort -f | uniq >> release.md +echo "" >> release.md + +echo "## BUG & Fix" >> release.md +git log --pretty=format:"* %s by @%an" --grep="^fix" -i $version_range | sort -f | uniq >> release.md +echo "" >> release.md + +echo "## Maintenance" >> release.md +git log --pretty=format:"* %s by @%an" --grep="^chore\|^docs\|^refactor" -i $version_range | sort -f | uniq >> release.md +echo "" >> release.md + +echo "**Full Changelog**: https://github.com/MetaCubeX/Clash.Meta/compare/$version_range" >> release.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f9e04574..57c40a4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -288,6 +288,23 @@ jobs: needs: [Build] runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get tags + run: | + echo "CURRENTVERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + git fetch --tags + echo "PREVERSION=$(git describe --tags --abbrev=0 HEAD^)" >> $GITHUB_ENV + + - name: Generate release notes + run: | + cp ./.github/genReleaseNote.sh ./ + bash ./genReleaseNote.sh -v ${PREVERSION}...${CURRENTVERSION} + rm ./genReleaseNote.sh + - uses: actions/download-artifact@v3 with: name: artifact @@ -304,6 +321,7 @@ jobs: tag_name: ${{ github.ref_name }} files: bin/* generate_release_notes: true + body_path: release.md Docker: if: ${{ !startsWith(github.event_name, 'pull_request') }}