Skip to content

Commit 0e62b7d

Browse files
jeremyd2019dscho
andcommitted
pacman-helper.sh: compose release body/notes
Do some trivial sed escaping of characters that might cause issues in JSON. This is not comprehensive, but the text in question is controlled by this script and package names and versions being published, so we can reasonably be assured of a limited set of characters being used. (In fact, it's probably unnecessary to escape quotes and backslashes).   Co-authored-by: Johannes Schindelin <[email protected]> Signed-off-by: Jeremy Drake <[email protected]>
1 parent 5afa258 commit 0e62b7d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pacman-helper.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ quick_action () { # <action> <file>...
349349
test -z "$GPGKEY" || sign_option=--sign
350350
dbs=
351351
to_push=
352+
>release_notes.txt
352353
for arch in $architectures
353354
do
354355
eval "msys=\$${arch}_msys"
@@ -454,11 +455,16 @@ quick_action () { # <action> <file>...
454455
$(printf '%s\n' $msys $mingw | wc -l) \
455456
"$(printf '%s\n' $msys $mingw |
456457
sed 's/^\(.*\)-\([^-]*-[^-]*\)-[^-]*\.pkg\.tar\.\(xz\|zst\)$/\1 -> \2/')")"
458+
printf '%s\n' $msys $mingw |
459+
sed 's/^\(.*\)-\([^-]*-[^-]*\)-[^-]*\.pkg\.tar\.\(xz\|zst\)$/* \1 -> \2/' >>release-notes.txt
457460
;;
458461
remove)
459462
msg="$(printf 'Remove %s package(s)\n\n%s\n' \
460463
$(printf '%s\n' $msys $mingw | wc -l) \
461464
"$(printf '%s\n' $msys $mingw)")"
465+
printf '%s\n' $msys $mingw |
466+
sed 's/^/* dropped /' >>release-notes.txt
467+
;;
462468
esac &&
463469
git commit -asm "$msg") ||
464470
die "Could not ${label} $msys $mingw to/from db in $arch"
@@ -545,8 +551,9 @@ quick_action () { # <action> <file>...
545551
then
546552
echo "Would create a GitHub Release '$tagname' at git-for-windows/pacman-repo" >&2
547553
else
554+
body="$(sed -z 's/[\"]/\\&/g;s/\n/\\n/g' release-notes.txt)"
548555
id="$(curl -H "Authorization: Bearer $GITHUB_TOKEN" -sfL --show-error -XPOST -d \
549-
'{"tag_name":"'"$tagname"'","name":"'"$tagname"'","draft":true,"prerelease":true}' \
556+
'{"tag_name":"'"$tagname"'","name":"'"$tagname"'","body":"'"$body"'","draft":true,"prerelease":true}' \
550557
"https://api.github.com/repos/git-for-windows/pacman-repo/releases" |
551558
sed -n 's/^ "id": *\([0-9]*\).*/\1/p')"
552559
fi ||

0 commit comments

Comments
 (0)