-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.33 KB
/
github-release.yml
File metadata and controls
53 lines (45 loc) · 1.33 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
name: Create GitHub Release
on:
push:
tags:
- "v*"
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract release notes from changelog
env:
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
version="${TAG_NAME#v}"
start_pattern="^## ${version}( - .*)?$"
if ! awk -v start="$start_pattern" '
BEGIN { in_section = 0; found = 0 }
$0 ~ start { in_section = 1; found = 1; next }
/^## / && in_section { exit }
in_section { print }
END {
if (!found) {
exit 1
}
}
' CHANGELOG.md > RELEASE_NOTES.raw.md; then
echo "No changelog section found for version ${version}."
exit 1
fi
sed -e '/./,$!d' RELEASE_NOTES.raw.md > RELEASE_NOTES.md
if [ ! -s RELEASE_NOTES.md ]; then
echo "Changelog section for version ${version} is empty."
exit 1
fi
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: RELEASE_NOTES.md