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