Put the tag message on the release page
The release page has been empty since the first release: the workflow attached the binaries and created the release with no body, so the changelog lived only in the annotated tag, where nobody reads it. The tag message, minus its subject line, is now set as the release notes. Only an annotated tag has a message worth copying, and only a release with no notes is filled, so re-running a failed release repairs an empty one without overwriting notes somebody edited by hand afterwards. The image has no jq, so the JSON string is escaped with sed and awk. Checked locally against the real v0.10.0 tag text and a string with quotes, backslashes, tabs, CRLF, backticks and $; each round-trips through a JSON parser unchanged. Not run in the pipeline: the PATCH call and the shallow tag clone's git commands are first exercised by the next tag push, and a failure there fails the step rather than leaving the notes silently empty.
This commit is contained in:
@@ -126,6 +126,28 @@ jobs:
|
||||
[ -n "$release_id" ] || { echo "::error::could not determine release id"; exit 1; }
|
||||
echo "release id $release_id"
|
||||
|
||||
# The release notes are the tag's own message, minus its subject line: the
|
||||
# tag body is the changelog for this project, and without this the release
|
||||
# page stays empty. Only an annotated tag has one, and only a release with
|
||||
# no notes is filled, so a re-run repairs a release created empty without
|
||||
# overwriting notes somebody has since edited by hand.
|
||||
#
|
||||
# There is no jq in this image, so the JSON string is escaped by hand:
|
||||
# backslashes first (or the ones added next would double), then quotes and
|
||||
# tabs, then each line end becomes a literal \n.
|
||||
if [ "$(git cat-file -t "$REF_NAME")" = tag ] \
|
||||
&& printf '%s' "$body" | grep -q '"body":""'; then
|
||||
notes=$(git tag -l --format='%(contents)' "$REF_NAME" | sed '1,2d')
|
||||
if [ -n "$notes" ]; then
|
||||
notes_json=$(printf '%s\n' "$notes" \
|
||||
| sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/\t/\\t/g' -e 's/\r$//' \
|
||||
| awk 'BEGIN { ORS = "\\n" } { print }')
|
||||
echo "setting release notes from the tag message"
|
||||
curl -sf -X PATCH -H "$auth" -H 'Content-Type: application/json' \
|
||||
-d "{\"body\":\"$notes_json\"}" "$API/releases/$release_id" > /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
for f in dist/*; do
|
||||
name=$(basename "$f")
|
||||
# Drop an existing asset of the same name first: Gitea happily stores two
|
||||
|
||||
Reference in New Issue
Block a user