Skip to content

Commit c60f34c

Browse files
authored
fix: correct GitHub username tagging in release changelog (#112)
- Add GH_TOKEN environment variable for gh api calls - Try both author.login and committer.login from GitHub API - Add fallback mapping for known git authors (Gray Zhang -> @graycreate) - This ensures releases show @graycreate instead of @gray
1 parent 6fc0554 commit c60f34c

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ jobs:
346346
347347
- name: Generate changelog
348348
id: changelog
349+
env:
350+
GH_TOKEN: ${{ github.token }}
349351
run: |
350352
echo "## What's Changed" > CHANGELOG.md
351353
echo "" >> CHANGELOG.md
@@ -361,8 +363,26 @@ jobs:
361363
if [ -n "$username" ]; then
362364
echo "@$username"
363365
else
364-
# Fallback to git author name if API fails
365-
echo "@$(git show -s --format='%an' $commit_sha)"
366+
# Fallback: try to get committer login if author login is not available
367+
local committer=$(gh api "repos/${{ github.repository }}/commits/${commit_sha}" --jq '.committer.login // empty' 2>/dev/null || echo "")
368+
if [ -n "$committer" ]; then
369+
echo "@$committer"
370+
else
371+
# Last resort: use hardcoded mapping for known authors
372+
local git_author=$(git show -s --format='%an' $commit_sha)
373+
case "$git_author" in
374+
"Gray Zhang" | "gray" | "Gray")
375+
echo "@graycreate"
376+
;;
377+
"github-actions[bot]")
378+
echo "@github-actions[bot]"
379+
;;
380+
*)
381+
# If no mapping found, use git author name without @
382+
echo "$git_author"
383+
;;
384+
esac
385+
fi
366386
fi
367387
}
368388

0 commit comments

Comments
 (0)