Skip to content

Commit

Permalink
Added CreateReleaseNotes script
Browse files Browse the repository at this point in the history
  • Loading branch information
jonthysell committed Jun 13, 2022
1 parent 91381b4 commit 4979dad
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/pub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Create Release Notes
run: ${{ env.ScriptDir }}/CreateReleaseNotes.ps1

- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -33,7 +36,7 @@ jobs:
with:
tag_name: ${{ github.ref }}
release_name: ${{ env.Product }} ${{ github.ref }}
body: See [README.md](./README.md) for installation instructions and [CHANGELOG.md](./CHANGELOG.md) for specific information about this release.
body_path: ${{ env.BuildDir }}/ReleaseNotes.md
draft: false
prerelease: ${{ env.Prerelease }}

Expand Down
33 changes: 33 additions & 0 deletions scripts/CreateReleaseNotes.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
param()

[string] $RepoRoot = Resolve-Path "$PSScriptRoot\.."

[string] $OutputRoot = "bld"

$StartingLocation = Get-Location
Set-Location -Path $RepoRoot

Write-Host "Getting release notes..."
try
{
$ChangelogLines = Get-Content "CHANGELOG.md"

$LastReleaseHeaders = $ChangelogLines | Select-String -Pattern "^## .* ##$" | Select -First 2

$FirstIndex = [array]::IndexOf($ChangelogLines, $LastReleaseHeaders[0]) + 1
$LastIndex = [array]::IndexOf($ChangelogLines, $LastReleaseHeaders[1]) - 1

$ReleaseNotes = $ChangelogLines[$FirstIndex..$LastIndex] -Match "\*"

$ReleaseNotes | ForEach-Object { Write-Host $_ }

if (-not (Test-Path "$OutputRoot")) {
New-Item "$OutputRoot" -Type Directory | Out-Null
}

Set-Content "$OutputRoot\ReleaseNotes.md" $ReleaseNotes
}
finally
{
Set-Location -Path "$StartingLocation"
}

0 comments on commit 4979dad

Please sign in to comment.