File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Release
2+
3+ on :
4+ push :
5+ tags : ["v*"]
6+
7+ jobs :
8+ create-release :
9+ name : Create Release
10+ runs-on : ubuntu-latest
11+ permissions :
12+ contents : write
13+ steps :
14+ - uses : actions/checkout@v6
15+
16+ - name : Create Release
17+ env :
18+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
19+ run : |
20+ TAG="${{ github.ref_name }}"
21+
22+ # Extract changelog section for this version
23+ CHANGELOG=$(awk -v tag="$TAG" '
24+ BEGIN { found=0 }
25+ /^# / {
26+ if (found) exit
27+ if ($0 == "# " tag) { found=1; next }
28+ }
29+ found { print }
30+ ' CHANGELOG.md | sed '/./,$!d' | sed -e :a -e '/^\n*$/{$d;N;ba}')
31+
32+ if [ -z "$CHANGELOG" ]; then
33+ echo "::error::No changelog entry found for $TAG in CHANGELOG.md"
34+ exit 1
35+ fi
36+
37+ if gh release view "$TAG" > /dev/null 2>&1; then
38+ echo "Release $TAG already exists. Updating with changelog."
39+ printf '%s\n' "$CHANGELOG" > /tmp/release_body.md
40+ gh release edit "$TAG" --title "$TAG" --notes-file /tmp/release_body.md
41+ else
42+ printf '%s\n' "$CHANGELOG" > /tmp/release_body.md
43+ gh release create "$TAG" --verify-tag --title "$TAG" --notes-file /tmp/release_body.md
44+ fi
You can’t perform that action at this time.
0 commit comments