|
| 1 | +if(!$env:APPVEYOR_REPO_TAG) { |
| 2 | + return |
| 3 | +} |
| 4 | + |
| 5 | +Write-Output 'Generating release notes ...' |
| 6 | +#region GitHub release notes |
| 7 | +$previousRelease = (Invoke-RestMethod -Uri "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/releases/latest?access_token=$env:GITHUB_ACCESS_TOKEN" -Verbose) |
| 8 | +Write-Host "Previous Release: $($previousRelease.name) ($($previousRelease.target_commitish))" |
| 9 | +$compare = (Invoke-RestMethod -Uri "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/compare/$($previousRelease.target_commitish)...$env:APPVEYOR_REPO_COMMIT`?access_token=$env:GITHUB_ACCESS_TOKEN" -Verbose) |
| 10 | +$releaseNotes = "## Release Notes`n#### Version [$env:APPVEYOR_REPO_TAG_NAME](https://github.com/$env:APPVEYOR_REPO_NAME/tree/$env:APPVEYOR_REPO_TAG_NAME)`n" |
| 11 | + |
| 12 | +if($null -ne $compare.commits -and $compare.commits.Length -gt 0) { |
| 13 | + $releaseNotes += "`nCommit | Description`n--- | ---`n" |
| 14 | + $contributions = @{} |
| 15 | + $compare.commits | Sort-Object -Property @{Expression={$_.commit.author.date};} -Descending | ForEach-Object { |
| 16 | + $commitMessage = $_.commit.message.Replace("`r`n"," ").Replace("`n"," "); |
| 17 | + if ($commitMessage.ToLower().StartsWith('merge') -or |
| 18 | + $commitMessage.ToLower().StartsWith('merging') -or |
| 19 | + $commitMessage.ToLower().StartsWith('private')) { |
| 20 | + continue |
| 21 | + } |
| 22 | + $releaseNotes += "[``$($_.sha.Substring(0, 7))``](https://github.com/$env:APPVEYOR_REPO_NAME/tree/$($_.sha)) | $commitMessage`n" |
| 23 | + $contributions.$($_.author.login)++ |
| 24 | + } |
| 25 | + $releaseNotes += "`nContributor | Commits`n--- | ---`n" |
| 26 | + $contributions.GetEnumerator() | Sort-Object -Property @{Expression={$_.Value}} -Descending | ForEach-Object { |
| 27 | + $releaseNotes += "@$($_.Name) | $($_.Value)`n" |
| 28 | + } |
| 29 | +} else { |
| 30 | + $releaseNotes += "There are no new items for this release." |
| 31 | +} |
| 32 | + |
| 33 | +$env:GITHUB_RELEASE_NOTES = $releaseNotes |
| 34 | +Write-Output $releaseNotes |
| 35 | +#endregion |
0 commit comments