-
Notifications
You must be signed in to change notification settings - Fork 20
56 lines (54 loc) · 1.8 KB
/
release.yml
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
name: Create Release
on:
workflow_call:
jobs:
release:
runs-on: ubuntu-latest
env:
TAG_NAME: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v3
- name: Generate Body File
id: notes
run: |
if [ -f "CHANGELOG.md" ]; then
rm -rf release-body.md
release=
next=
while read -r version; do
if [[ "$version" =~ "$TAG_NAME" ]]; then
release="$version"
else
if [[ "$next" == "" ]]; then
next="$version"
fi
fi
done < <(grep -n "## \[v\?" CHANGELOG.md)
l1=$(echo "$release" | cut -d: -f1)
l2=$(echo "$next" | cut -d: -f1)
tail -n +$l1 CHANGELOG.md | head -n $((l2-l1)) > release-body.md
if grep -q "tail: invalid" release-body.md; then
rm release-body.md
echo "status=error" >> $GITHUB_OUTPUT
elif [ $(wc -l release-body.md | awk '{print $1}') -eq 0 ]; then
rm release-body.md
echo "status=error" >> $GITHUB_OUTPUT
else
echo "status=created" >> $GITHUB_OUTPUT
fi
else
echo "status=error" >> $GITHUB_OUTPUT
fi
- name: Create Release with CHANGELOG
uses: ncipollo/[email protected]
if: ${{ steps.notes.outputs.status == 'created' }}
with:
skipIfReleaseExists: false
generateReleaseNotes: false
bodyFile: "release-body.md"
- name: Create Release with Autogenerated Notes
uses: ncipollo/[email protected]
if: ${{ steps.notes.outputs.status == 'error' }}
with:
skipIfReleaseExists: false
generateReleaseNotes: true