Skip to content

Commit b90e65f

Browse files
tablackburnclaude
andcommitted
ci(release): populate PSData.ReleaseNotes from CHANGELOG at publish time
So the PowerShell Gallery release-notes panel shows curated, user-facing notes per version (matching the GitHub release) instead of a static link. - build.depend.psd1: add ChangelogManagement 3.1.0. - build.psake.ps1: new UpdateReleaseNotes task (Depends Build) that sets the built manifest's PrivateData.PSData.ReleaseNotes from the matching CHANGELOG entry via Update-ModuleManifest, wired in through $PSBPublishDependency. Non-fatal at every step so a release is never blocked. Verified: ChangelogManagement parses this repo's CHANGELOG. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 98a194c commit b90e65f

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

build.depend.psd1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
'PSScriptAnalyzer' = @{
2626
Version = '1.24.0'
2727
}
28+
# Parses CHANGELOG.md (Keep a Changelog format) so the Publish task can populate the
29+
# built manifest's PSData.ReleaseNotes from the matching version's entry.
30+
'ChangelogManagement' = @{
31+
Version = '3.1.0'
32+
}
2833
'PlexAutomationToolkit' = @{
2934
Version = '0.6.3'
3035
}

build.psake.ps1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,60 @@ Task -Name 'DownloadTestTools' -Description 'Download test dependencies (UnRAR)'
146146
}
147147
}
148148

149+
# Populate the built manifest's ReleaseNotes from the matching CHANGELOG.md entry so the
150+
# PowerShell Gallery release-notes panel shows the curated, user-facing notes (the same
151+
# content used for the GitHub release) instead of just a link. Depends on Build so the
152+
# staged manifest in ModuleOutDir exists; runs before Publish (see $PSBPublishDependency
153+
# below). Non-fatal at every step so a release is never blocked.
154+
Task -Name 'UpdateReleaseNotes' -Depends 'Build' -Description 'Set built manifest ReleaseNotes from the matching CHANGELOG.md entry' {
155+
$changelogPath = Join-Path -Path $PSScriptRoot -ChildPath 'CHANGELOG.md'
156+
if (-not (Test-Path -Path $changelogPath)) {
157+
Write-Warning 'CHANGELOG.md not found; leaving ReleaseNotes unchanged.'
158+
return
159+
}
160+
161+
$moduleVersion = $PSBPreference.General.ModuleVersion
162+
try {
163+
Import-Module -Name 'ChangelogManagement' -ErrorAction Stop
164+
$changelogData = Get-ChangelogData -Path $changelogPath -ErrorAction Stop
165+
}
166+
catch {
167+
Write-Warning "Could not read CHANGELOG.md ($($_.Exception.Message)); leaving ReleaseNotes unchanged."
168+
return
169+
}
170+
171+
$releaseEntry = $changelogData.Released |
172+
Where-Object { [string]$_.Version -eq [string]$moduleVersion } |
173+
Select-Object -First 1
174+
if (-not $releaseEntry) {
175+
Write-Warning "No CHANGELOG.md entry found for version $moduleVersion; leaving ReleaseNotes unchanged."
176+
return
177+
}
178+
179+
$releaseNotes = $releaseEntry.RawData.Trim()
180+
if ([string]::IsNullOrWhiteSpace($releaseNotes)) {
181+
Write-Warning "CHANGELOG.md entry for version $moduleVersion is empty; leaving ReleaseNotes unchanged."
182+
return
183+
}
184+
$builtManifest = Join-Path -Path $PSBPreference.Build.ModuleOutDir -ChildPath "$($PSBPreference.General.ModuleName).psd1"
185+
if (-not (Test-Path -Path $builtManifest)) {
186+
Write-Warning "Built manifest not found at '$builtManifest'; leaving ReleaseNotes unchanged."
187+
return
188+
}
189+
try {
190+
Update-ModuleManifest -Path $builtManifest -ReleaseNotes $releaseNotes -ErrorAction Stop
191+
Write-Host " Set ReleaseNotes on built manifest from CHANGELOG [$($releaseEntry.Version)] ($($releaseNotes.Length) chars)" -ForegroundColor Gray
192+
}
193+
catch {
194+
# Keep publishing unblocked: a failure here just leaves the manifest's existing
195+
# ReleaseNotes in place rather than aborting the release.
196+
Write-Warning "Failed to set ReleaseNotes on the built manifest ($($_.Exception.Message)); leaving it unchanged."
197+
}
198+
}
199+
200+
# Inject ReleaseNotes into the built manifest before publishing (PowerShellBuild's Publish
201+
# defaults to depending only on 'Test').
202+
$PSBPublishDependency = @('Test', 'UpdateReleaseNotes')
203+
149204
# Import the Test task from PowerShellBuild (uses $PSBTestDependency which includes Pester and Analyze)
150205
Task -Name 'Test' -FromModule 'PowerShellBuild' -MinimumVersion '0.7.3'

0 commit comments

Comments
 (0)