@@ -17,15 +17,17 @@ jobs:
1717 fetch-depth : 0
1818
1919 - name : Generate changelog
20+ env :
21+ GH_TOKEN : ${{ github.token }}
2022 run : |
21- # Get all commits with email in descending order (newest first), excluding changelog bot commits
22- git log --pretty=format:'%ad|%s|%an|%ae' --date=short | grep -v '\[skip ci\]' > /tmp/commits.txt
23+ # Get all commits with email and hash in descending order (newest first), excluding changelog bot commits
24+ git log --pretty=format:'%ad|%s|%an|%ae|%H ' --date=short | grep -v '\[skip ci\]' > /tmp/commits.txt
2325
2426 # Generate changelog content grouped by date
2527 echo "" > /tmp/changelog_content.md
2628 current_date=""
2729
28- while IFS='|' read -r date message author email; do
30+ while IFS='|' read -r date message author email commit_hash ; do
2931 if [ "$date" != "$current_date" ]; then
3032 if [ -n "$current_date" ]; then
3133 echo "" >> /tmp/changelog_content.md
@@ -35,19 +37,21 @@ jobs:
3537 current_date="$date"
3638 fi
3739
38- # Extract GitHub username from email if it's a GitHub email
39- if [[ "$email" == *"@users.noreply.github.com" ]]; then
40- github_user=$(echo "$email" | sed 's/@users.noreply.github.com//' | sed 's/^[0-9]*+//')
40+ # Get GitHub username from commit using gh CLI (has higher rate limits)
41+ github_user=$(gh api "/repos/kaic/win-post-install/commits/${commit_hash}" --jq '.author.login' 2>/dev/null || echo "")
42+
43+ if [ -n "$github_user" ] && [ "$github_user" != "null" ]; then
4144 author_link="[@${author}](https://github.com/${github_user})"
4245 else
4346 author_link="@${author}"
4447 fi
4548
4649 # Check if message is a merge commit (contains PR number)
47- if [[ "$message" =~ Merge\ pull\ request\ \#([0-9]+) ]]; then
50+ if [[ "$message" =~ Merge\ pull\ request\ \#([0-9]+) ]] || [[ "$message" =~ \(#([0-9]+)\)$ ]] ; then
4851 pr_number="${BASH_REMATCH[1]}"
4952 pr_link="[#${pr_number}](https://github.com/kaic/win-post-install/pull/${pr_number})"
50- message=$(echo "$message" | sed "s|Merge pull request #${pr_number}|${pr_link}|")
53+ # Replace both formats: "Merge pull request #123" or "(#123)" at end
54+ message=$(echo "$message" | sed "s|Merge pull request #${pr_number}|${pr_link}|" | sed "s|(#${pr_number})$|(${pr_link})|")
5155 fi
5256
5357 echo "- $message (${author_link})" >> /tmp/changelog_content.md
0 commit comments