Skip to content

Commit b71f645

Browse files
committed
feat(workflows): Add release workflow to automate GitHub releases
1 parent eca9b2d commit b71f645

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # This workflow will run when any tag starting with 'v' is pushed
7+
8+
# Add permissions configuration
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
name: Create Release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0 # We need full history to get commit messages
21+
22+
- name: Get previous tag
23+
id: previoustag
24+
run: |
25+
echo "PREVIOUS_TAG=$(git describe --tags --abbrev=0 $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || echo '')" >> $GITHUB_ENV
26+
echo "CURRENT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
27+
28+
- name: Generate release notes
29+
id: generate_notes
30+
run: |
31+
if [ -n "$PREVIOUS_TAG" ]; then
32+
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
33+
echo "## Changes since $PREVIOUS_TAG" >> $GITHUB_ENV
34+
echo "" >> $GITHUB_ENV
35+
git log --pretty=format:"* %s (%an)" $PREVIOUS_TAG..$CURRENT_TAG >> $GITHUB_ENV
36+
echo "" >> $GITHUB_ENV
37+
echo "EOF" >> $GITHUB_ENV
38+
else
39+
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
40+
echo "## Initial Release" >> $GITHUB_ENV
41+
echo "" >> $GITHUB_ENV
42+
git log --pretty=format:"* %s (%an)" >> $GITHUB_ENV
43+
echo "" >> $GITHUB_ENV
44+
echo "EOF" >> $GITHUB_ENV
45+
fi
46+
47+
- name: Create Release
48+
uses: softprops/action-gh-release@v1
49+
with:
50+
name: Release ${{ env.CURRENT_TAG }}
51+
body: ${{ env.RELEASE_NOTES }}
52+
draft: false
53+
prerelease: false
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)