Skip to content

Commit dc2b75d

Browse files
committed
Refactors release workflow
Streamlines the release workflow by: - Generating changelog directly using git commands for better flexibility and accuracy. - Updates the release creation action. This change enhances the automation and reliability of the release process.
1 parent 973c694 commit dc2b75d

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,33 @@ jobs:
3434

3535
- name: Generate changelog
3636
id: changelog
37-
uses: metcalfc/changelog-generator@v4.6.2
38-
with:
39-
myToken: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
# Get all commit messages since last tag or a reasonable limit if this is the first tag
39+
if git describe --tags --abbrev=0 HEAD^ 2>/dev/null; then
40+
# If this is not the first tag, compare with the previous one
41+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null)
42+
echo "Getting changes between $PREVIOUS_TAG and ${{ github.ref_name }}"
43+
CHANGELOG=$(git log --pretty=format:"* %s (%h)" $PREVIOUS_TAG..${{ github.ref_name }})
44+
else
45+
# If this is the first tag, just get the recent commits
46+
echo "This appears to be the first tag, getting the last 20 commits"
47+
CHANGELOG=$(git log -20 --pretty=format:"* %s (%h)")
48+
fi
49+
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
50+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
51+
echo "EOF" >> $GITHUB_OUTPUT
4052
4153
- name: Create Release
4254
id: create_release
43-
uses: actions/create-release@v1
44-
env:
45-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
uses: softprops/action-gh-release@v1
4656
with:
47-
tag_name: ${{ github.ref }}
48-
release_name: Release ${{ steps.get_version.outputs.VERSION }}
57+
token: ${{ secrets.GITHUB_TOKEN }}
58+
name: Release ${{ steps.get_version.outputs.VERSION }}
4959
body: |
5060
# VConSharp ${{ steps.get_version.outputs.VERSION }}
5161
5262
## Changes
53-
${{ steps.changelog.outputs.changelog }}
63+
${{ steps.changelog.outputs.CHANGELOG }}
5464
5565
## Installation
5666
```

0 commit comments

Comments
 (0)