-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (44 loc) · 1.55 KB
/
Copy pathrelease.yml
File metadata and controls
54 lines (44 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: "\U0001F4E5 Checkout code"
uses: actions/checkout@v6
- name: "\U0001F4CB Extract release notes"
id: notes
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if echo "$GITHUB_REF_NAME" | grep -qiE '\-(alpha|beta|rc)'; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
NOTES=$(awk -v ver="$VERSION" '
BEGIN { found=0 }
/^## \[/ {
if (found) exit
if (index($0, "## [" ver "]") == 1) { found=1; next }
}
found { print }
' CHANGELOG.md | sed -e '/^---$/d' | sed -e :a -e '/^[[:space:]]*$/{ $d; N; ba; }')
if [ -z "$NOTES" ]; then
NOTES="Release $GITHUB_REF_NAME"
echo "::warning::Version $VERSION not found in CHANGELOG.md. Using fallback release body."
fi
echo "$NOTES" > "$RUNNER_TEMP/release_notes.md"
echo "notes_file=$RUNNER_TEMP/release_notes.md" >> "$GITHUB_OUTPUT"
- name: "\U0001F680 Create GitHub Release"
uses: softprops/action-gh-release@v2
with:
name: v${{ steps.notes.outputs.version }}
body_path: ${{ steps.notes.outputs.notes_file }}
prerelease: ${{ steps.notes.outputs.prerelease }}
generate_release_notes: false