@@ -147,45 +147,138 @@ jobs:
147147 shell : pwsh
148148 run : |
149149 Write-Output "DEBUG: Starting parse_commit"
150- $commitMsg = git log -1 --pretty=%B
151- Write-Output "DEBUG: Commit message: $commitMsg"
152150
153- $commitSubject = $commitMsg.Split("`n")[0]
154- $commitBodyLines = $commitMsg.Split("`n") | Select-Object -Skip 1
155- $commitBody = ($commitBodyLines -join "`n").Trim()
156-
157- $releaseNotes = "## Changes`n`n"
158-
159- if ($commitSubject -match '^(fix|feat|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?:\s*(.+)$') {
160- $type = $Matches[1]
161- $description = $Matches[3]
162- $typeLabel = switch ($type) {
163- 'fix' { '🐛 Fix' }
164- 'feat' { '✨ Feature' }
165- 'refactor' { '♻️ Refactor' }
166- 'test' { '✅ Test' }
167- 'chore' { '🔧 Chore' }
168- 'perf' { '⚡ Performance' }
169- 'build' { '📦 Build' }
170- 'revert' { '⏪ Revert' }
171- default { '📝 Update' }
151+ # Get all commits from the PR (base to head)
152+ $baseSha = "${{ github.event.pull_request.base.sha }}"
153+ $headSha = "${{ github.event.pull_request.head.sha }}"
154+
155+ Write-Output "DEBUG: Base SHA: $baseSha"
156+ Write-Output "DEBUG: Head SHA: $headSha"
157+
158+ # Get all commit messages in the PR
159+ $commits = @(git log --pretty=format:"%h|%s|%b" "$baseSha..$headSha")
160+ Write-Output "DEBUG: Found $($commits.Count) commits in PR"
161+
162+ # Initialize categorized lists
163+ $features = @()
164+ $fixes = @()
165+ $performance = @()
166+ $refactors = @()
167+ $docs = @()
168+ $tests = @()
169+ $chores = @()
170+ $builds = @()
171+ $ci = @()
172+ $style = @()
173+ $reverts = @()
174+ $others = @()
175+
176+ # Parse each commit
177+ foreach ($line in $commits) {
178+ if ([string]::IsNullOrWhiteSpace($line)) { continue }
179+
180+ $parts = $line -split '\|', 3
181+ if ($parts.Count -lt 2) { continue }
182+
183+ $commitHash = $parts[0]
184+ $subject = $parts[1]
185+ $body = if ($parts.Count -eq 3) { $parts[2] } else { "" }
186+
187+ Write-Output "DEBUG: Processing commit $commitHash : $subject"
188+
189+ # Parse conventional commit format
190+ if ($subject -match '^(fix|feat|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?:\s*(.+)$') {
191+ $type = $Matches[1]
192+ $scope = if ($Matches[2]) { $Matches[2] } else { "" }
193+ $description = $Matches[3]
194+
195+ $entry = "- $description ($commitHash)"
196+
197+ switch ($type) {
198+ 'feat' { $features += $entry }
199+ 'fix' { $fixes += $entry }
200+ 'perf' { $performance += $entry }
201+ 'refactor' { $refactors += $entry }
202+ 'docs' { $docs += $entry }
203+ 'test' { $tests += $entry }
204+ 'chore' { $chores += $entry }
205+ 'build' { $builds += $entry }
206+ 'ci' { $ci += $entry }
207+ 'style' { $style += $entry }
208+ 'revert' { $reverts += $entry }
209+ default { $others += "- $subject ($commitHash)" }
210+ }
211+ } else {
212+ # Non-conventional commit
213+ $others += "- $subject ($commitHash)"
172214 }
173- $releaseNotes += "**$typeLabel**: $description`n"
174- } else {
175- $releaseNotes += "$commitSubject`n"
176215 }
177-
178- if ($commitBody -ne "") {
179- $maxBodyLength = 1000
180- if ($commitBody.Length -gt $maxBodyLength) {
181- $commitBody = $commitBody.Substring(0, $maxBodyLength) + "..."
182- }
183- $releaseNotes += "`n$commitBody `n"
216+
217+ # Build release notes
218+ $releaseNotes = "## Changes`n`n"
219+
220+ if ($features.Count -gt 0) {
221+ $releaseNotes += "### ✨ Features`n"
222+ $releaseNotes += ($features -join "`n") + "`n `n"
184223 }
185-
224+
225+ if ($fixes.Count -gt 0) {
226+ $releaseNotes += "### 🐛 Fixes`n"
227+ $releaseNotes += ($fixes -join "`n") + "`n`n"
228+ }
229+
230+ if ($performance.Count -gt 0) {
231+ $releaseNotes += "### ⚡ Performance`n"
232+ $releaseNotes += ($performance -join "`n") + "`n`n"
233+ }
234+
235+ if ($refactors.Count -gt 0) {
236+ $releaseNotes += "### ♻️ Refactoring`n"
237+ $releaseNotes += ($refactors -join "`n") + "`n`n"
238+ }
239+
240+ if ($docs.Count -gt 0) {
241+ $releaseNotes += "### 📝 Documentation`n"
242+ $releaseNotes += ($docs -join "`n") + "`n`n"
243+ }
244+
245+ if ($tests.Count -gt 0) {
246+ $releaseNotes += "### ✅ Tests`n"
247+ $releaseNotes += ($tests -join "`n") + "`n`n"
248+ }
249+
250+ if ($builds.Count -gt 0) {
251+ $releaseNotes += "### 📦 Build`n"
252+ $releaseNotes += ($builds -join "`n") + "`n`n"
253+ }
254+
255+ if ($chores.Count -gt 0) {
256+ $releaseNotes += "### 🔧 Chores`n"
257+ $releaseNotes += ($chores -join "`n") + "`n`n"
258+ }
259+
260+ if ($ci.Count -gt 0) {
261+ $releaseNotes += "### 🔄 CI/CD`n"
262+ $releaseNotes += ($ci -join "`n") + "`n`n"
263+ }
264+
265+ if ($style.Count -gt 0) {
266+ $releaseNotes += "### 💄 Style`n"
267+ $releaseNotes += ($style -join "`n") + "`n`n"
268+ }
269+
270+ if ($reverts.Count -gt 0) {
271+ $releaseNotes += "### ⏪ Reverts`n"
272+ $releaseNotes += ($reverts -join "`n") + "`n`n"
273+ }
274+
275+ if ($others.Count -gt 0) {
276+ $releaseNotes += "### 📋 Other Changes`n"
277+ $releaseNotes += ($others -join "`n") + "`n`n"
278+ }
279+
186280 Write-Output "DEBUG: releaseNotes: $releaseNotes"
187- $commitSha = git rev-parse --short HEAD
188- $releaseNotes += "`n---`n*Commit: $commitSha*"
281+ $releaseNotes += "---`n*Based on commits from $baseSha to $headSha*"
189282
190283 $delimiter = "EOF_$(Get-Random)"
191284 Write-Output "DEBUG: Writing notes to output using delimiter $delimiter"
0 commit comments