From e372da6709f71b90ed17750a15a470a6267d4920 Mon Sep 17 00:00:00 2001 From: Gray Zhang Date: Wed, 17 Sep 2025 19:52:30 +0800 Subject: [PATCH] fix: correct GitHub username tagging in release changelog - 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 --- .github/workflows/release.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc7990e9..f9c5592f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -346,6 +346,8 @@ jobs: - name: Generate changelog id: changelog + env: + GH_TOKEN: ${{ github.token }} run: | echo "## What's Changed" > CHANGELOG.md echo "" >> CHANGELOG.md @@ -361,8 +363,26 @@ jobs: if [ -n "$username" ]; then echo "@$username" else - # Fallback to git author name if API fails - echo "@$(git show -s --format='%an' $commit_sha)" + # Fallback: try to get committer login if author login is not available + local committer=$(gh api "repos/${{ github.repository }}/commits/${commit_sha}" --jq '.committer.login // empty' 2>/dev/null || echo "") + if [ -n "$committer" ]; then + echo "@$committer" + else + # Last resort: use hardcoded mapping for known authors + local git_author=$(git show -s --format='%an' $commit_sha) + case "$git_author" in + "Gray Zhang" | "gray" | "Gray") + echo "@graycreate" + ;; + "github-actions[bot]") + echo "@github-actions[bot]" + ;; + *) + # If no mapping found, use git author name without @ + echo "$git_author" + ;; + esac + fi fi }