Skip to content

Commit b6b62ef

Browse files
committed
Release CI: extract the newest bit of CHANGELOG as release text
1 parent 585df51 commit b6b62ef

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
type: boolean
1010
required: false
1111
default: false
12+
force:
13+
description: "Allow overwriting an existing release, or making a release with an incorrect date"
14+
type: boolean
15+
required: false
16+
default: false
1217

1318
permissions: write-all
1419

@@ -30,9 +35,40 @@ jobs:
3035
run: |
3136
rm -f .covignore .mailmap .codespellrc Dockerfile
3237
rm -rf etc scripts
38+
- name: Extract the latest CHANGELOG entry to use as the GitHub release text
39+
run: |
40+
# Extract the part of CHANGELOG that is relevant to this release
41+
LINES=`grep -n "## Version " CHANGELOG.md | head -2 | cut -d':' -f1`
42+
43+
# Find the line number where the relevant section starts
44+
# (Increment by 1 if that first line is empty)
45+
START=`echo $LINES | cut -d' ' -f1`;
46+
START=$((START + 1))
47+
if [ "`sed \"${START}q;d\" CHANGELOG.md`" == "" ]; then
48+
START=$(( START + 1 ));
49+
fi
50+
51+
# Find the line number where the relevant section ends
52+
# (Decrement by 1 if that last line is empty)
53+
STOP=`echo $LINES | cut -d' ' -f2`;
54+
STOP=$((STOP - 1))
55+
if [ "`sed \"${STOP}q;d\" CHANGELOG.md`" == "" ]; then
56+
STOP=$(( STOP - 1 ));
57+
fi
58+
59+
# Store the potentially multi-line text in the BODY environment so
60+
# that we can pass it to the release-pkg action as an input
61+
{
62+
echo 'BODY<<EOF'
63+
sed -n "${START},${STOP}p" CHANGELOG.md
64+
echo EOF
65+
} >> "$GITHUB_ENV"
66+
3367
- uses: gap-actions/release-pkg@v1
3468
with:
3569
dry-run: ${{ inputs.dry-run }}
70+
force: ${{ inputs.force }}
71+
body-text: ${{ env.BODY }}
3672
- uses: gap-actions/update-gh-pages@v1
3773
if: ${{ !inputs.dry-run }}
3874
with:

0 commit comments

Comments
 (0)