Skip to content

Commit 1c250f6

Browse files
committed
Discord announcement fixed again
1 parent 618dd88 commit 1c250f6

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

.github/workflows/announce.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1-
name: Announce Release on Discord
1+
name: Announce fetch-kit Release
22

33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- 'v*.*.*'
77

88
jobs:
99
announce:
1010
runs-on: ubuntu-latest
1111
steps:
12+
- uses: actions/checkout@v3
13+
1214
- name: Post to Discord
1315
run: |
14-
payload=$(jq -n \
15-
--arg content "New fetch-kit Release: $GITHUB_REF_NAME" \
16-
'{content: $content}')
17-
curl -X POST \
18-
-H "Content-Type: application/json" \
19-
-d "$payload" \
20-
"${{ secrets.DISCORD_WEBHOOK }}"
16+
TAG=${GITHUB_REF#refs/tags/} # e.g., v4.0.8
17+
VERSION=${TAG#v} # remove 'v' to match CHANGELOG.md headers
18+
19+
# extract lines under version header until next '##'
20+
NOTES=$(sed -n "/^## $VERSION$/,/^## /{ /^## /!p }" CHANGELOG.md | sed '/^[[:space:]]*$/d')
21+
22+
# fallback if nothing found
23+
if [ -z "$NOTES" ]; then
24+
NOTES="(no changelog entry found for $VERSION)"
25+
fi
26+
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}')
30+
31+
curl -sS -H "Content-Type: application/json" -X POST -d "$PAYLOAD" ${{ secrets.DISCORD_WEBHOOK }}

0 commit comments

Comments
 (0)