-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (50 loc) · 1.48 KB
/
Copy pathrelease.yml
File metadata and controls
59 lines (50 loc) · 1.48 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
55
56
57
58
59
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get release notes from RELEASES.md
id: release_notes
run: |
# Extract the section for this tag from RELEASES.md
TAG="${GITHUB_REF#refs/tags/}"
# Use awk to extract the section between this version and the next
NOTES=$(awk -v tag="$TAG" '
/^## / {
if (found) exit
if ($2 == tag) found=1
next
}
found && /^---$/ { exit }
found { print }
' RELEASES.md)
# Write to file for gh release
echo "$NOTES" > release_notes.md
echo "Release notes for $TAG:"
cat release_notes.md
- name: Create or Update GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF#refs/tags/}"
# Check if release already exists
if gh release view "$TAG" &>/dev/null; then
echo "Release $TAG exists, updating notes..."
gh release edit "$TAG" --notes-file release_notes.md
else
echo "Creating release $TAG..."
gh release create "$TAG" \
--title "$TAG" \
--notes-file release_notes.md \
--latest
fi