|
1 |
| -#Requires -Modules Utilities, PowerShellGet, Microsoft.PowerShell.PSResourceGet, Retry, GitHub |
| 1 | +#Requires -Modules Utilities, PowerShellGet, Microsoft.PowerShell.PSResourceGet, Retry, GitHub, PSSemVer |
2 | 2 |
|
3 | 3 | function Publish-PSModule {
|
4 | 4 | <#
|
@@ -170,9 +170,11 @@ function Publish-PSModule {
|
170 | 170 | LogGroup 'Get latest version - PSGallery' {
|
171 | 171 | try {
|
172 | 172 | Retry -Count 5 -Delay 10 {
|
| 173 | + Write-Output "Finding module [$Name] in the PowerShell Gallery." |
173 | 174 | $latest = Find-PSResource -Name $Name -Repository PSGallery -Verbose:$false
|
| 175 | + Write-Output ($latest | Format-Table | Out-String) |
174 | 176 | } -Catch {
|
175 |
| - Write-Output $_ |
| 177 | + throw $_ |
176 | 178 | }
|
177 | 179 | $psGalleryVersion = New-PSSemVer -Version $latest.Version
|
178 | 180 | } catch {
|
@@ -260,7 +262,17 @@ function Publish-PSModule {
|
260 | 262 | $newVersionString = "$($newVersion.Major).$($newVersion.Minor).$($newVersion.Patch)"
|
261 | 263 |
|
262 | 264 | # PowerShell Gallery
|
263 |
| - $psGalleryPrereleases = Find-PSResource -Name $Name -Repository PSGallery -Verbose:$false -Version * -Prerelease |
| 265 | + $params = @{ |
| 266 | + Name = $Name |
| 267 | + Version = '*' |
| 268 | + Prerelease = $true |
| 269 | + Repository = 'PSGallery' |
| 270 | + Verbose = $false |
| 271 | + ErrorAction = 'SilentlyContinue' |
| 272 | + } |
| 273 | + Write-Output 'Finding the latest prerelease version in the PowerShell Gallery.' |
| 274 | + Write-Output ($params | Format-Table | Out-String) |
| 275 | + $psGalleryPrereleases = Find-PSResource @params |
264 | 276 | $psGalleryPrereleases = $psGalleryPrereleases | Where-Object { $_.Version -like "$newVersionString" }
|
265 | 277 | $psGalleryPrereleases = $psGalleryPrereleases | Where-Object { $_.Prerelease -like "$prereleaseName*" }
|
266 | 278 | $latestPSGalleryPrerelease = $psGalleryPrereleases.Prerelease | ForEach-Object {
|
@@ -332,7 +344,7 @@ function Publish-PSModule {
|
332 | 344 | if ($whatIf) {
|
333 | 345 | Write-Output "gh pr comment $($pull_request.number) -b 'Published to the PowerShell Gallery [$publishPSVersion]($psGalleryReleaseLink) has been created.'"
|
334 | 346 | } else {
|
335 |
| - Write-GithubNotice "Module [$Name - $publishPSVersion] published to the PowerShell Gallery." |
| 347 | + Write-GitHubNotice "Module [$Name - $publishPSVersion] published to the PowerShell Gallery." |
336 | 348 | gh pr comment $pull_request.number -b "Module [$Name - $publishPSVersion]($psGalleryReleaseLink) published to the PowerShell Gallery."
|
337 | 349 | if ($LASTEXITCODE -ne 0) {
|
338 | 350 | Write-Error 'Failed to comment on the pull request.'
|
@@ -373,7 +385,7 @@ function Publish-PSModule {
|
373 | 385 | exit $LASTEXITCODE
|
374 | 386 | }
|
375 | 387 | }
|
376 |
| - Write-GithubNotice "Release created: [$newVersion]" |
| 388 | + Write-GitHubNotice "Release created: [$newVersion]" |
377 | 389 | }
|
378 | 390 | }
|
379 | 391 |
|
|
0 commit comments