Skip to content

Commit 54fb39c

Browse files
committed
Discord announcement fixed (?)
1 parent fa0b755 commit 54fb39c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

.github/workflows/announce.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@ on:
88
jobs:
99
announce:
1010
runs-on: ubuntu-latest
11+
1112
steps:
12-
- uses: actions/checkout@v3
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
1315

14-
- name: Post to Discord
16+
- name: Post release to Discord
1517
run: |
16-
TAG=${GITHUB_REF#refs/tags/} # e.g., v4.0.8
17-
VERSION=${TAG#v} # remove 'v' to match CHANGELOG.md headers
18+
TAG=${GITHUB_REF#refs/tags/} # e.g., v4.0.8
19+
VERSION=${TAG#v} # remove 'v' to match changelog headers
1820
19-
# extract lines under version header until next '##'
21+
# Extract changelog block for this version
2022
NOTES=$(sed -n "/^## $VERSION$/,/^## /{ /^## /!p }" CHANGELOG.md | sed '/^[[:space:]]*$/d')
2123
22-
# fallback if nothing found
2324
if [ -z "$NOTES" ]; then
2425
NOTES="(no changelog entry found for $VERSION)"
2526
fi
2627
27-
# construct JSON safely with jq
28-
PAYLOAD=$(jq -n --arg content "📦 **New fetch-kit Release: $TAG**\nRepository: $GITHUB_REPOSITORY\n\`\`\`\n$NOTES\n\`\`\`" \
29-
'{content: $content}')
28+
# Construct JSON with jq, preserving literal line breaks
29+
PAYLOAD=$(jq -Rn --arg tag "$TAG" --arg repo "$GITHUB_REPOSITORY" --arg notes "$NOTES" \
30+
'{content: ("📦 **New fetch-kit Release: \($tag)**\nRepository: \($repo)\n```\n\($notes)\n```")}')
3031
32+
# Send to Discord webhook
3133
curl -sS -H "Content-Type: application/json" -X POST -d "$PAYLOAD" ${{ secrets.DISCORD_WEBHOOK }}

0 commit comments

Comments
 (0)