|
1 | 1 | function Publish-PSModule { |
2 | 2 | <# |
3 | 3 | .SYNOPSIS |
4 | | - Publishes a module to the PowerShell Gallery and GitHub Pages. |
| 4 | + Publishes a module to the PowerShell Gallery. |
5 | 5 |
|
6 | 6 | .DESCRIPTION |
7 | | - Publishes a module to the PowerShell Gallery and GitHub Pages. |
| 7 | + Publishes a module to the PowerShell Gallery. |
8 | 8 |
|
9 | 9 | .EXAMPLE |
10 | 10 | Publish-PSModule -Name 'PSModule.FX' -APIKey $env:PSGALLERY_API_KEY |
|
33 | 33 | [string] $APIKey |
34 | 34 | ) |
35 | 35 |
|
36 | | - LogGroup 'Set configuration' { |
| 36 | + Set-GitHubLogGroup 'Set configuration' { |
37 | 37 | $autoCleanup = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoCleanup -eq 'true' |
38 | 38 | $autoPatching = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoPatching -eq 'true' |
39 | 39 | $incrementalPrerelease = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IncrementalPrerelease -eq 'true' |
|
59 | 59 | } | Format-List | Out-String |
60 | 60 | } |
61 | 61 |
|
62 | | - LogGroup 'Event information - JSON' { |
| 62 | + Set-GitHubLogGroup 'Event information - JSON' { |
63 | 63 | $githubEventJson = Get-Content $env:GITHUB_EVENT_PATH |
64 | 64 | $githubEventJson | Format-List | Out-String |
65 | 65 | } |
66 | 66 |
|
67 | | - LogGroup 'Event information - Object' { |
| 67 | + Set-GitHubLogGroup 'Event information - Object' { |
68 | 68 | $githubEvent = $githubEventJson | ConvertFrom-Json |
69 | 69 | $pull_request = $githubEvent.pull_request |
70 | 70 | $githubEvent | Format-List | Out-String |
71 | 71 | } |
72 | 72 |
|
73 | | - LogGroup 'Event information - Details' { |
| 73 | + Set-GitHubLogGroup 'Event information - Details' { |
74 | 74 | $defaultBranchName = (gh repo view --json defaultBranchRef | ConvertFrom-Json | Select-Object -ExpandProperty defaultBranchRef).name |
75 | 75 | $isPullRequest = $githubEvent.PSObject.Properties.Name -Contains 'pull_request' |
76 | 76 | if (-not ($isPullRequest -or $whatIf)) { |
|
96 | 96 | Write-Output '-------------------------------------------------' |
97 | 97 | } |
98 | 98 |
|
99 | | - LogGroup 'Pull request - details' { |
| 99 | + Set-GitHubLogGroup 'Pull request - details' { |
100 | 100 | $pull_request | Format-List | Out-String |
101 | 101 | } |
102 | 102 |
|
103 | | - LogGroup 'Pull request - Labels' { |
| 103 | + Set-GitHubLogGroup 'Pull request - Labels' { |
104 | 104 | $labels = @() |
105 | 105 | $labels += $pull_request.labels.name |
106 | 106 | $labels | Format-List | Out-String |
107 | 107 | } |
108 | 108 |
|
109 | | - LogGroup 'Calculate release type' { |
| 109 | + Set-GitHubLogGroup 'Calculate release type' { |
110 | 110 | $createRelease = $isMerged -and $targetIsDefaultBranch |
111 | 111 | $closedPullRequest = $prIsClosed -and -not $isMerged |
112 | 112 | $createPrerelease = $labels -Contains 'prerelease' -and -not $createRelease -and -not $closedPullRequest |
|
134 | 134 | Write-Output '-------------------------------------------------' |
135 | 135 | } |
136 | 136 |
|
137 | | - LogGroup 'Get latest version - GitHub' { |
| 137 | + Set-GitHubLogGroup 'Get latest version - GitHub' { |
138 | 138 | $releases = gh release list --json 'createdAt,isDraft,isLatest,isPrerelease,name,publishedAt,tagName' | ConvertFrom-Json |
139 | 139 | if ($LASTEXITCODE -ne 0) { |
140 | 140 | Write-Error 'Failed to list all releases for the repo.' |
|
157 | 157 | Write-Output '-------------------------------------------------' |
158 | 158 | } |
159 | 159 |
|
160 | | - LogGroup 'Get latest version - PSGallery' { |
| 160 | + Set-GitHubLogGroup 'Get latest version - PSGallery' { |
161 | 161 | $count = 5 |
162 | 162 | $delay = 10 |
163 | 163 | for ($i = 1; $i -le $count; $i++) { |
|
186 | 186 | Write-Output '-------------------------------------------------' |
187 | 187 | } |
188 | 188 |
|
189 | | - LogGroup 'Get latest version - Manifest' { |
| 189 | + Set-GitHubLogGroup 'Get latest version - Manifest' { |
190 | 190 | Add-PSModulePath -Path (Split-Path -Path $ModulePath -Parent) |
191 | 191 | $manifestFilePath = Join-Path $ModulePath "$Name.psd1" |
192 | 192 | Write-Output "Module manifest file path: [$manifestFilePath]" |
|
208 | 208 | Write-Output '-------------------------------------------------' |
209 | 209 | } |
210 | 210 |
|
211 | | - LogGroup 'Get latest version' { |
| 211 | + Set-GitHubLogGroup 'Get latest version' { |
212 | 212 | Write-Output "GitHub: [$($ghReleaseVersion.ToString())]" |
213 | 213 | Write-Output "PSGallery: [$($psGalleryVersion.ToString())]" |
214 | 214 | Write-Output "Manifest: [$($manifestVersion.ToString())] (ignored)" |
|
220 | 220 | Write-Output '-------------------------------------------------' |
221 | 221 | } |
222 | 222 |
|
223 | | - LogGroup 'Calculate new version' { |
| 223 | + Set-GitHubLogGroup 'Calculate new version' { |
224 | 224 | # - Increment based on label on PR |
225 | 225 | $newVersion = New-PSSemVer -Version $latestVersion |
226 | 226 | $newVersion.Prefix = $versionPrefix |
|
302 | 302 | } |
303 | 303 | Write-Output "New version is [$($newVersion.ToString())]" |
304 | 304 |
|
305 | | - LogGroup 'Update module manifest' { |
| 305 | + Set-GitHubLogGroup 'Update module manifest' { |
306 | 306 | Write-Output 'Bump module version -> module metadata: Update-ModuleMetadata' |
307 | 307 | $manifestNewVersion = "$($newVersion.Major).$($newVersion.Minor).$($newVersion.Patch)" |
308 | 308 | Set-ModuleManifest -Path $manifestFilePath -ModuleVersion $manifestNewVersion -Verbose:$false |
|
314 | 314 | Show-FileContent -Path $manifestFilePath |
315 | 315 | } |
316 | 316 |
|
317 | | - LogGroup 'Install module dependencies' { |
| 317 | + Set-GitHubLogGroup 'Install module dependencies' { |
318 | 318 | Resolve-PSModuleDependency -ManifestFilePath $manifestFilePath |
319 | 319 | } |
320 | 320 |
|
321 | 321 | if ($createPrerelease -or $createRelease -or $whatIf) { |
322 | | - LogGroup 'Publish-ToPSGallery' { |
| 322 | + Set-GitHubLogGroup 'Publish-ToPSGallery' { |
323 | 323 | if ($createPrerelease) { |
324 | 324 | $publishPSVersion = "$($newVersion.Major).$($newVersion.Minor).$($newVersion.Patch)-$($newVersion.Prerelease)" |
325 | 325 | } else { |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 |
|
355 | | - LogGroup 'New-GitHubRelease' { |
| 355 | + Set-GitHubLogGroup 'New-GitHubRelease' { |
356 | 356 | Write-Output 'Create new GitHub release' |
357 | 357 | if ($createPrerelease) { |
358 | 358 | if ($whatIf) { |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 |
|
391 | | - LogGroup 'List prereleases using the same name' { |
| 391 | + Set-GitHubLogGroup 'List prereleases using the same name' { |
392 | 392 | $prereleasesToCleanup = $releases | Where-Object { $_.tagName -like "*$prereleaseName*" } |
393 | 393 | $prereleasesToCleanup | Select-Object -Property name, publishedAt, isPrerelease, isLatest | Format-Table | Out-String |
394 | 394 | } |
395 | 395 |
|
396 | 396 | if ((($closedPullRequest -or $createRelease) -and $autoCleanup) -or $whatIf) { |
397 | | - LogGroup "Cleanup prereleases for [$prereleaseName]" { |
| 397 | + Set-GitHubLogGroup "Cleanup prereleases for [$prereleaseName]" { |
398 | 398 | foreach ($rel in $prereleasesToCleanup) { |
399 | 399 | $relTagName = $rel.tagName |
400 | 400 | Write-Output "Deleting prerelease: [$relTagName]." |
|
0 commit comments