Skip to content

Commit 902951d

Browse files
committed
Release CI: extract the newest bit of CHANGELOG as release text
1 parent f38bfdd commit 902951d

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

.github/workflows/release.yml

Lines changed: 37 additions & 1 deletion
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
33-
- uses: gap-actions/release-pkg@v1
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+
67+
- uses: wilfwilson/release-pkg@add-body-text-option
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)