Skip to content

Commit 96caeea

Browse files
committed
Add automatic release notes to workflow
1 parent 3abc2e2 commit 96caeea

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

.github/workflows/release.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,50 @@ permissions:
99
contents: write
1010

1111
jobs:
12-
release:
12+
create-release:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
upload_url: ${{ steps.create_release.outputs.upload_url }}
16+
steps:
17+
- name: Check out Git repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Generate release notes
23+
id: release_notes
24+
run: |
25+
# Get the previous tag
26+
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -v "$(git describe --tags --abbrev=0)" | head -n 1)
27+
28+
# Generate changelog
29+
if [ -z "$PREVIOUS_TAG" ]; then
30+
CHANGELOG=$(git log --pretty=format:"- %s (%h)" ${{ github.ref_name }})
31+
else
32+
CHANGELOG=$(git log --pretty=format:"- %s (%h)" ${PREVIOUS_TAG}..${{ github.ref_name }})
33+
fi
34+
35+
# Save to output
36+
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
37+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
38+
echo "EOF" >> $GITHUB_OUTPUT
39+
40+
- name: Create Release
41+
id: create_release
42+
uses: actions/create-release@v1
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
with:
46+
tag_name: ${{ github.ref_name }}
47+
release_name: Release ${{ github.ref_name }}
48+
body: |
49+
## Changes
50+
${{ steps.release_notes.outputs.CHANGELOG }}
51+
draft: false
52+
prerelease: ${{ contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }}
53+
54+
build:
55+
needs: create-release
1356
runs-on: ${{ matrix.os }}
1457

1558
strategy:

0 commit comments

Comments
 (0)