Skip to content

Commit 0be0af2

Browse files
committed
Add changelog generation for rel eases and pre-rel eases
1 parent b6b0bd7 commit 0be0af2

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,68 @@ jobs:
4747
zip -r github-to-wordpress-sync.zip github-to-wordpress-sync
4848
rm -rf github-to-wordpress-sync
4949
50+
- name: Generate changelog
51+
if: contains(github.event.head_commit.message, 'release')
52+
id: changelog
53+
run: |
54+
# Get the previous release tag
55+
previous_tag=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
56+
57+
if [ -z "$previous_tag" ]; then
58+
# If no previous tag, get all commits
59+
changelog=$(git log --pretty=format:"- %s (%h)" --reverse)
60+
else
61+
# Get commits since previous tag
62+
changelog=$(git log ${previous_tag}..HEAD --pretty=format:"- %s (%h)" --reverse)
63+
fi
64+
65+
# Create the release body
66+
{
67+
echo "## What's Changed"
68+
echo ""
69+
echo "$changelog"
70+
echo ""
71+
if [ -n "$previous_tag" ]; then
72+
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${previous_tag}...v${{ env.new_version }}"
73+
fi
74+
} > release_notes.md
75+
76+
# Set output for use in next step
77+
echo "previous_tag=$previous_tag" >> $GITHUB_ENV
78+
5079
- name: Create GitHub Release
5180
if: contains(github.event.head_commit.message, 'release')
5281
uses: softprops/action-gh-release@v1
5382
with:
5483
files: github-to-wordpress-sync.zip
5584
tag_name: "v${{ env.new_version }}"
5685
name: "Release v${{ env.new_version }}"
57-
body: "Release v${{ env.new_version }} of the plugin."
86+
body_path: release_notes.md
5887
env:
5988
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6089

90+
- name: Generate pre-release changelog
91+
if: contains(github.event.head_commit.message, 'alphatag')
92+
run: |
93+
# Get the previous tag
94+
previous_tag=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
95+
96+
if [ -z "$previous_tag" ]; then
97+
changelog=$(git log --pretty=format:"- %s (%h)" --reverse)
98+
else
99+
changelog=$(git log ${previous_tag}..HEAD --pretty=format:"- %s (%h)" --reverse)
100+
fi
101+
102+
{
103+
echo "## What's Changed (Pre-release)"
104+
echo ""
105+
echo "$changelog"
106+
echo ""
107+
if [ -n "$previous_tag" ]; then
108+
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${previous_tag}...pre-v${{ env.version }}"
109+
fi
110+
} > prerelease_notes.md
111+
61112
- name: Create GitHub Pre-release
62113
if: contains(github.event.head_commit.message, 'alphatag')
63114
uses: softprops/action-gh-release@v1
@@ -66,6 +117,6 @@ jobs:
66117
files: github-to-wordpress-sync.zip
67118
tag_name: "pre-v${{ env.version }}"
68119
name: "Pre-release v${{ env.version }}"
69-
body: "Pre-release v${{ env.version }} of the plugin."
120+
body_path: prerelease_notes.md
70121
env:
71122
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)