Skip to content

Commit 198c62d

Browse files
authored
Merge pull request #30 from taj54/main
ci: add major/minor release heading in GitHub release notes
2 parents 24f24a9 + 171a6b9 commit 198c62d

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

.github/workflows/tag-after-merge.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
name: Tag After Merge
1+
name: Tag and Release After Merge
2+
3+
permissions:
4+
contents: write
25

36
on:
47
push:
58
branches:
69
- main
710

811
jobs:
9-
create-tag:
12+
create-tag-and-release:
1013
runs-on: ubuntu-latest
1114
steps:
1215
- name: Checkout code
@@ -22,7 +25,6 @@ jobs:
2225
- name: Get last tag (if exists)
2326
run: |
2427
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
25-
# strip leading "v" if present
2628
LAST_TAG_STRIPPED=${LAST_TAG#v}
2729
echo "last_tag=$LAST_TAG_STRIPPED" >> $GITHUB_ENV
2830
@@ -49,7 +51,7 @@ jobs:
4951
5052
- name: Skip if patch
5153
if: env.release_type == 'patch'
52-
run: echo "Patch release detected → no tag will be created."
54+
run: echo "Patch release detected → no tag or release will be created."
5355

5456
- name: Create and push git tag
5557
if: env.release_type != 'patch'
@@ -58,3 +60,30 @@ jobs:
5860
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
5961
git tag v${{ env.version }}
6062
git push origin v${{ env.version }}
63+
64+
- name: Extract release notes from CHANGELOG
65+
if: env.release_type != 'patch'
66+
id: changelog
67+
run: |
68+
# Match lines starting with "## vX.Y.Z " until the next "## "
69+
awk "/^## v${{ env.version }}[[:space:]]/{flag=1; next} /^## /{flag=0} flag" CHANGELOG.md > RELEASE_NOTES.md
70+
71+
echo "notes<<EOF" >> $GITHUB_ENV
72+
if [ "${{ env.release_type }}" = "major" ]; then
73+
echo "## 🚀 Major Release" >> $GITHUB_ENV
74+
elif [ "${{ env.release_type }}" = "minor" ]; then
75+
echo "## ✨ Minor Release" >> $GITHUB_ENV
76+
fi
77+
echo "" >> $GITHUB_ENV
78+
cat RELEASE_NOTES.md >> $GITHUB_ENV
79+
echo "EOF" >> $GITHUB_ENV
80+
81+
- name: Create GitHub Release
82+
if: env.release_type != 'patch'
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: v${{ env.version }}
86+
name: "Release v${{ env.version }}"
87+
body: ${{ env.notes }}
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)