-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (48 loc) · 1.55 KB
/
release.yml
File metadata and controls
54 lines (48 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:
branches: [master]
paths:
- 'CHANGELOG.md'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from CHANGELOG
id: version
run: |
VERSION=$(grep -m1 '^### ' CHANGELOG.md | sed 's/### \([0-9.]*\).*/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Found version: $VERSION"
- name: Check if release exists
id: check
run: |
if gh release view "v${{ steps.version.outputs.version }}" > /dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Extract release notes
if: steps.check.outputs.exists == 'false'
id: notes
run: |
# Extract notes for this version (between first and second ### headers)
NOTES=$(awk '/^### [0-9]/{if(p) exit; p=1; next} p' CHANGELOG.md)
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create release
if: steps.check.outputs.exists == 'false'
run: |
gh release create "v${{ steps.version.outputs.version }}" \
--title "v${{ steps.version.outputs.version }}" \
--notes "${{ steps.notes.outputs.notes }}"
env:
GH_TOKEN: ${{ github.token }}