Skip to content

Commit 3ad43e6

Browse files
committed
fix: handle edge cases in discord release notification
- Skip notification when GITHUB_REF is not a tag (e.g. workflow_dispatch) to avoid producing a nonsensical version string - Fall back to last 20 commits when PREV_TAG is empty (first release) to avoid git log failing on an invalid "..HEAD" range Made-with: Cursor
1 parent 3f40bb8 commit 3ad43e6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/release-CI.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,19 @@ jobs:
216216
env:
217217
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
218218
run: |
219+
if [[ "$GITHUB_REF" != refs/tags/v* ]]; then
220+
echo "::warning::GITHUB_REF ($GITHUB_REF) is not a tag push — skipping Discord notification"
221+
exit 0
222+
fi
223+
219224
VERSION="${GITHUB_REF#refs/tags/v}"
220225
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]' | sed -n '2p')
221-
CHANGELOG=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s" --no-merges | grep -v "^- Release ")
226+
227+
if [ -z "$PREV_TAG" ]; then
228+
CHANGELOG=$(git log --pretty=format:"- %s" --no-merges -20 | grep -v "^- Release " || true)
229+
else
230+
CHANGELOG=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s" --no-merges | grep -v "^- Release " || true)
231+
fi
222232
223233
read -r -d '' MESSAGE << EOM || true
224234
Hey @everyone 👋

0 commit comments

Comments
 (0)