release: include the tag's CHANGELOG section in the Gitea release body
Previously the create-release POST sent only `{tag_name, name, draft,
prerelease}` — Gitea created the release with an empty description, so
users hitting the release page saw the tag name and nothing else.
Extracts the relevant `## [<version>]` block from CHANGELOG.md (using
$TAG with the leading `v` stripped) via awk, stopping at the next
`## [<other>]` section header or the trailing `[link-ref]: url` block,
and passes it as the `body` field to the release creation API.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -146,12 +146,20 @@ jobs:
|
||||
set -euo pipefail
|
||||
api="${GITHUB_SERVER_URL}/api/v1"
|
||||
|
||||
# Pull this tag's section out of CHANGELOG.md for the release body.
|
||||
body=$(awk -v ver="${TAG#v}" '
|
||||
$0 ~ "^## \\[" ver "\\]" { in_section=1; next }
|
||||
in_section && /^## \[/ { exit }
|
||||
in_section && /^\[.*\]:[[:space:]]/ { exit }
|
||||
in_section
|
||||
' "$GITHUB_WORKSPACE/CHANGELOG.md")
|
||||
|
||||
# Create the release (or get the existing one for this tag)
|
||||
release_json=$(curl -fsSL -X POST "$api/repos/$REPO/releases" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "$(jq -n --arg tag "$TAG" --arg name "$TAG" \
|
||||
'{tag_name:$tag,name:$name,draft:false,prerelease:false}')" \
|
||||
-d "$(jq -n --arg tag "$TAG" --arg name "$TAG" --arg body "$body" \
|
||||
'{tag_name:$tag,name:$name,body:$body,draft:false,prerelease:false}')" \
|
||||
|| curl -fsSL "$api/repos/$REPO/releases/tags/$TAG" \
|
||||
-H "Authorization: token $GITEA_TOKEN")
|
||||
rid=$(echo "$release_json" | jq -r .id)
|
||||
|
||||
Reference in New Issue
Block a user