From 496e7b6d90bf08bcf597d4fd03c824b56eb67ea9 Mon Sep 17 00:00:00 2001 From: Niklas Ye Date: Wed, 23 Sep 2026 22:15:14 +0200 Subject: [PATCH] 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. --- .gitea/workflows/release.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index c22a24b..cf6ac11 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -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