1919 env :
2020 VERSION : ${{ github.event.inputs.version }}
2121 BRANCH : rel/${{ github.event.inputs.version }}
22-
22+ GH_REPO : ${{ github.repository }}
23+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2324 steps :
2425 - name : Checkout repository
2526 uses : actions/checkout@v4
@@ -70,13 +71,12 @@ jobs:
7071 echo "✅ Found last release tag: $LAST_TAG"
7172 echo "range=$LAST_TAG..HEAD" >> $GITHUB_OUTPUT
7273
73- - name : Generate Release Notes from Commit Titles
74+ - name : Generate Release Notes from PR Titles
7475 id : generate_notes
7576 run : |
7677 echo "## 🔖 Auto-Generated Release Notes" > pr_body.md
7778 echo "" >> pr_body.md
7879
79- # Detect release channel
8080 if [[ "$VERSION" == *"alpha"* ]]; then
8181 CHANNEL="alpha"
8282 elif [[ "$VERSION" == *"beta"* ]]; then
@@ -88,34 +88,54 @@ jobs:
8888 echo "**Channels:** $CHANNEL" >> pr_body.md
8989 echo "" >> pr_body.md
9090
91- # Use commit range from previous release tag
9291 RANGE="${{ steps.fetch_last_release.outputs.range }}"
93- echo "Using commit range: $RANGE"
92+ echo "📦 Commit range: $RANGE"
9493
95- # Get all commit subjects in the range
96- COMMIT_MESSAGES=$(git log "$RANGE" --pretty=format:"%s" || true)
94+ COMMITS=$(git log "$RANGE" --pretty=format:"%H" | sort -u)
9795
98- if [[ -z "$COMMIT_MESSAGES " ]]; then
99- echo "❌ No commits found in range $RANGE . Exiting safely ."
96+ if [[ -z "$COMMITS " ]]; then
97+ echo "❌ No commits found. Exiting."
10098 exit 0
10199 fi
102100
103- echo "$COMMIT_MESSAGES" > commit_titles.txt
101+ > raw_titles.txt
102+ for SHA in $COMMITS; do
103+ PR_INFO=$(gh api "repos/${{ github.repository }}/commits/$SHA/pulls" \
104+ -H "Accept: application/vnd.github.groot-preview+json" 2>/dev/null)
105+
106+ TITLE=$(echo "$PR_INFO" | jq -r '.[0].title // empty')
107+ NUMBER=$(echo "$PR_INFO" | jq -r '.[0].number // empty')
108+
109+ if [[ -n "$TITLE" && -n "$NUMBER" ]]; then
110+ echo "$TITLE ([#$NUMBER](https://github.com/${{ github.repository }}/pull/$NUMBER))" >> raw_titles.txt
111+ echo "✅ $SHA → $TITLE (#$NUMBER)"
112+ else
113+ echo "⚠️ $SHA → No PR found"
114+ fi
115+ done
116+
117+ sort -fu raw_titles.txt > pr_titles.txt
104118
119+ if [[ ! -s pr_titles.txt ]]; then
120+ echo "❌ No PR titles found from commits. Exiting."
121+ exit 0
122+ fi
123+
124+ echo "" >> pr_body.md
105125 echo "### 🚀 New Features" >> pr_body.md
106- grep -i '^feat' commit_titles .txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
126+ grep -i '^feat' pr_titles .txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
107127
108128 echo "" >> pr_body.md
109129 echo "### 🐛 Bug Fixes" >> pr_body.md
110- grep -i '^bug' commit_titles .txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
130+ grep -i '^bug' pr_titles .txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
111131
112132 echo "" >> pr_body.md
113133 echo "### 🔧 Improvements" >> pr_body.md
114- grep -i -E '^(perf|refactor)' commit_titles .txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
134+ grep -i -E '^(perf|refactor)' pr_titles .txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
115135
116136 echo "" >> pr_body.md
117- echo "### 📝 Uncategorized Commits " >> pr_body.md
118- grep -v -i -E '^(feat|bug|perf|refactor)' commit_titles .txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
137+ echo "### 📝 Uncategorized PRs " >> pr_body.md
138+ grep -v -i -E '^(feat|bug|perf|refactor)' pr_titles .txt | sed 's/^/- /' >> pr_body.md || echo "- _None_" >> pr_body.md
119139
120140 echo "" >> pr_body.md
121141 echo "### 📦 Version" >> pr_body.md
0 commit comments