@@ -350,10 +350,8 @@ jobs:
350350 GH_TOKEN : ${{ github.token }}
351351 GITHUB_REPOSITORY : ${{ github.repository }}
352352 run : |
353- # Get commits since last tag
354- LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
355- CURRENT_TAG="${{ needs.prepare.outputs.version }}"
356-
353+ # Define shared functions that will be used in both changelog generation steps
354+ cat > /tmp/release_functions.sh << 'FUNCTIONS_EOF'
357355 # Function to categorize commit message
358356 categorize_commit() {
359357 local msg="$1"
@@ -395,13 +393,14 @@ jobs:
395393 # Function to get GitHub username from commit
396394 get_github_username() {
397395 local commit_sha="$1"
396+ local github_repo="${GITHUB_REPOSITORY}"
398397 # Try to get the GitHub username from the commit using gh api
399- local username=$(gh api "repos/${{ github.repository } }/commits/${commit_sha}" --jq '.author.login // empty' 2>/dev/null || echo "")
398+ local username=$(gh api "repos/${github_repo }/commits/${commit_sha}" --jq '.author.login // empty' 2>/dev/null || echo "")
400399 if [ -n "$username" ]; then
401400 echo "@$username"
402401 else
403402 # Fallback: try to get committer login if author login is not available
404- local committer=$(gh api "repos/${{ github.repository } }/commits/${commit_sha}" --jq '.committer.login // empty' 2>/dev/null || echo "")
403+ local committer=$(gh api "repos/${github_repo }/commits/${commit_sha}" --jq '.committer.login // empty' 2>/dev/null || echo "")
405404 if [ -n "$committer" ]; then
406405 echo "@$committer"
407406 else
@@ -422,6 +421,14 @@ jobs:
422421 fi
423422 fi
424423 }
424+ FUNCTIONS_EOF
425+
426+ # Source the functions
427+ source /tmp/release_functions.sh
428+
429+ # Get commits since last tag
430+ LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
431+ CURRENT_TAG="${{ needs.prepare.outputs.version }}"
425432
426433 # Collect commits and categorize them
427434 declare -A features
@@ -605,68 +612,12 @@ jobs:
605612 run : |
606613 mkdir -p whatsnew
607614
615+ # Source the shared functions defined earlier
616+ source /tmp/release_functions.sh
617+
608618 # Get commits since last tag for categorization
609619 LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
610620
611- # Function to categorize commit message (same as above)
612- categorize_commit() {
613- local msg="$1"
614- local category=""
615- local cleaned_msg=""
616-
617- if [[ "$msg" =~ ^fix(\(.*\))?:\ (.*)$ ]] || [[ "$msg" =~ ^fix\ (.*)$ ]]; then
618- category="bug"
619- cleaned_msg="${BASH_REMATCH[-1]}"
620- elif [[ "$msg" =~ ^feat(\(.*\))?:\ (.*)$ ]] || [[ "$msg" =~ ^feat\ (.*)$ ]]; then
621- category="feature"
622- cleaned_msg="${BASH_REMATCH[-1]}"
623- elif [[ "$msg" =~ ^perf(\(.*\))?:\ (.*)$ ]]; then
624- category="performance"
625- cleaned_msg="${BASH_REMATCH[2]}"
626- elif [[ "$msg" =~ ^refactor(\(.*\))?:\ (.*)$ ]]; then
627- category="improvement"
628- cleaned_msg="${BASH_REMATCH[2]}"
629- else
630- category="other"
631- cleaned_msg="$msg"
632- fi
633-
634- # Remove PR numbers from the end
635- cleaned_msg=$(echo "$cleaned_msg" | sed 's/ (#[0-9]*)//')
636-
637- # Capitalize first letter
638- cleaned_msg="$(echo "${cleaned_msg:0:1}" | tr '[:lower:]' '[:upper:]')${cleaned_msg:1}"
639-
640- echo "$category:$cleaned_msg"
641- }
642-
643- # Function to get GitHub username from commit (reuse from above)
644- get_github_username() {
645- local commit_sha="$1"
646- local username=$(gh api "repos/${{ github.repository }}/commits/${commit_sha}" --jq '.author.login // empty' 2>/dev/null || echo "")
647- if [ -n "$username" ]; then
648- echo "@$username"
649- else
650- local committer=$(gh api "repos/${{ github.repository }}/commits/${commit_sha}" --jq '.committer.login // empty' 2>/dev/null || echo "")
651- if [ -n "$committer" ]; then
652- echo "@$committer"
653- else
654- local git_author=$(git show -s --format='%an' $commit_sha)
655- case "$git_author" in
656- "Gray Zhang" | "gray" | "Gray")
657- echo "@graycreate"
658- ;;
659- "github-actions[bot]")
660- echo "@github-actions[bot]"
661- ;;
662- *)
663- echo ""
664- ;;
665- esac
666- fi
667- fi
668- }
669-
670621 # Collect and categorize commits
671622 declare -A features
672623 declare -A bugs
0 commit comments