Skip to content

Commit 98a8e47

Browse files
committed
added release workflow
1 parent ce12fad commit 98a8e47

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/release.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
if: github.ref == 'refs/heads/master'
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v5
17+
18+
- name: Extract version and notes from CHANGELOG
19+
id: changelog
20+
run: |
21+
# Extract version from first ## [x.x.x] header
22+
VERSION=$(grep -m1 -oP '## \[\K[0-9]+\.[0-9]+\.[0-9]+' CHANGELOG.md)
23+
echo "version=$VERSION" >> $GITHUB_OUTPUT
24+
25+
# Extract release notes (content between first and second ## headers)
26+
NOTES=$(awk '/^## \['"$VERSION"'\]/{flag=1; next} /^## \[/{flag=0} flag' CHANGELOG.md)
27+
28+
# Handle multiline output
29+
{
30+
echo "notes<<EOF"
31+
echo "$NOTES"
32+
echo "EOF"
33+
} >> $GITHUB_OUTPUT
34+
35+
- name: Check if tag already exists
36+
id: check_tag
37+
run: |
38+
if git rev-parse "v${{ steps.changelog.outputs.version }}" >/dev/null 2>&1; then
39+
echo "exists=true" >> $GITHUB_OUTPUT
40+
else
41+
echo "exists=false" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Create Release
45+
if: steps.check_tag.outputs.exists == 'false'
46+
uses: softprops/action-gh-release@v2
47+
with:
48+
tag_name: ${{ steps.changelog.outputs.version }}
49+
name: v${{ steps.changelog.outputs.version }}
50+
body: ${{ steps.changelog.outputs.notes }}
51+
draft: false
52+
prerelease: false
53+
54+
- name: Skip release (tag exists)
55+
if: steps.check_tag.outputs.exists == 'true'
56+
run: |
57+
echo "⚠️ Tag v${{ steps.changelog.outputs.version }} already exists. Skipping release creation."
58+
exit 1

0 commit comments

Comments
 (0)