-
Notifications
You must be signed in to change notification settings - Fork 3
51 lines (46 loc) · 1.45 KB
/
release.yml
File metadata and controls
51 lines (46 loc) · 1.45 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
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
tag:
description: 'Tag (e.g. v1.0.0)'
required: true
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref_name }}
- name: Get tag
id: tag
run: echo "tag=${{ github.event.inputs.tag || github.ref_name }}" >> $GITHUB_OUTPUT
- name: Extract release notes
id: notes
run: |
VERSION="${{ steps.tag.outputs.tag }}"
VERSION_NUM="${VERSION#v}"
NOTES=""
if [ -f CHANGELOG.md ]; then
NOTES=$(awk -v ver="$VERSION_NUM" '
/^## / { if (found) exit; if ($2 == ver) { found=1; next } }
found { print }
' CHANGELOG.md)
fi
if [ -n "$NOTES" ]; then
echo "has_notes=true" >> $GITHUB_OUTPUT
echo 'notes<<EOF' >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
else
echo "has_notes=false" >> $GITHUB_OUTPUT
fi
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
body: ${{ steps.notes.outputs.has_notes == 'true' && steps.notes.outputs.notes || '' }}
generate_release_notes: ${{ steps.notes.outputs.has_notes != 'true' }}