Skip to content

Commit ca1b955

Browse files
committed
Move release notes generation to release.ps1
1 parent db9b3f2 commit ca1b955

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ install:
55
- ps: .\install.ps1
66
build_script:
77
- ps: .\build.ps1
8+
after_build:
9+
- ps: .\release.ps1
810

911
artifacts:
1012
- path: 'dist\*'

build.ps1

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
Push-Location $PSScriptRoot
22

3-
Get-ChildItem env:
4-
53
# Prepare
64
$build = "$PSScriptRoot\build"
75
$dist = "$PSScriptRoot\dist"
@@ -36,34 +34,3 @@ Get-ChildItem "$dist\*" | ForEach-Object {
3634
$line | Out-File "$dist\$($_.Name).sha256" -Append -Encoding oem
3735
}
3836
Pop-Location
39-
40-
Write-Output 'Generating release notes ...'
41-
#region GitHub release notes
42-
$previousRelease = (Invoke-RestMethod -Uri "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/releases/latest?access_token=$env:GITHUB_ACCESS_TOKEN")
43-
$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")
44-
$releaseNotes = "## Release Notes`n#### Version [$env:APPVEYOR_REPO_TAG_NAME](https://github.com/$env:APPVEYOR_REPO_NAME/tree/$env:APPVEYOR_REPO_TAG_NAME)`n"
45-
46-
if($null -ne $compare.commits -and $compare.commits.Length -gt 0) {
47-
$releaseNotes += "`nCommit | Description`n--- | ---`n"
48-
$contributions = @{}
49-
$compare.commits | Sort-Object -Property @{Expression={$_.commit.author.date};} -Descending | ForEach-Object {
50-
$commitMessage = $_.commit.message.Replace("`r`n"," ").Replace("`n"," ");
51-
if ($commitMessage.ToLower().StartsWith('merge') -or
52-
$commitMessage.ToLower().StartsWith('merging') -or
53-
$commitMessage.ToLower().StartsWith('private')) {
54-
continue
55-
}
56-
$releaseNotes += "[``$($_.sha.Substring(0, 7))``](https://github.com/$env:APPVEYOR_REPO_NAME/tree/$($_.sha)) | $commitMessage`n"
57-
$contributions.$($_.author.login)++
58-
}
59-
$releaseNotes += "`nContributor | Commits`n--- | ---`n"
60-
$contributions.GetEnumerator() | Sort-Object -Property @{Expression={$_.Value}} -Descending | ForEach-Object {
61-
$releaseNotes += "@$($_.Name) | $($_.Value)`n"
62-
}
63-
} else {
64-
$releaseNotes += "There are no new items for this release."
65-
}
66-
67-
$env:GITHUB_RELEASE_NOTES = $releaseNotes
68-
Write-Output $releaseNotes
69-
#endregion

release.ps1

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

0 commit comments

Comments
 (0)