Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions publish/release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,31 @@ if (0 -ne $LASTEXITCODE) {
throw "Failed to verify nupkg"
}

# Pack the PowerShell Gallery module into a .nupkg under tmp/ so the exact package we publish
# is captured as a build artifact. Publish-Module otherwise packs into a random system temp
# folder and discards it, so a failed gallery push leaves us with no package to inspect or
# publish manually. Do this before the gallery push, because that push aborts the script on
# failure (ErrorActionPreference = 'Stop').
$psGalleryPackageDir = "$PSScriptRoot/../tmp/PSGallery-package"
if (Test-Path $psGalleryPackageDir) {
Remove-Item -Recurse -Force $psGalleryPackageDir
}
$null = New-Item -ItemType Directory -Path $psGalleryPackageDir

$localRepository = 'PesterLocalPublish'
try {
Get-PSRepository -Name $localRepository -ErrorAction SilentlyContinue | Unregister-PSRepository
Register-PSRepository -Name $localRepository -SourceLocation $psGalleryPackageDir -PublishLocation $psGalleryPackageDir -InstallationPolicy Trusted
Publish-Module -Path $psGalleryDir -Repository $localRepository -NuGetApiKey 'local' -Verbose -Force
Write-Host "Saved PowerShell Gallery package to $psGalleryPackageDir"
}
catch {
Write-Warning "Failed to capture local PowerShell Gallery package: $_"
}
finally {
Get-PSRepository -Name $localRepository -ErrorAction SilentlyContinue | Unregister-PSRepository
}

Publish-Module -Path $psGalleryDir -NuGetApiKey $PsGalleryApiKey -Verbose -Force

if (-not $isPreRelease -or $Force) {
Expand Down
Loading