-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (49 loc) · 1.51 KB
/
release.yml
File metadata and controls
58 lines (49 loc) · 1.51 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract changelog section
run: |
set -euo pipefail
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
if [ ! -f CHANGELOG.md ]; then
echo "CHANGELOG.md not found at repo root" >&2
exit 1
fi
awk -v ver="$VERSION" '
$0 ~ "^## \\[" ver "\\]" { found=1; next }
found && /^## \[/ { exit }
found && /^# Notes/ { exit }
found { print }
' CHANGELOG.md > release_notes.md
if ! grep -q '[^[:space:]]' release_notes.md; then
echo "No CHANGELOG.md section found for version ${VERSION}" >&2
echo "Expected a heading like: ## [${VERSION}] - YYYY-MM-DD" >&2
exit 1
fi
echo "----- release notes for ${TAG} -----"
cat release_notes.md
echo "------------------------------------"
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
PRERELEASE_FLAG=""
case "${GITHUB_REF_NAME}" in
*-*) PRERELEASE_FLAG="--prerelease" ;;
esac
gh release create "${GITHUB_REF_NAME}" \
--title "${GITHUB_REF_NAME}" \
--notes-file release_notes.md \
${PRERELEASE_FLAG}