File tree Expand file tree Collapse file tree
.github/actions/Publish-PSModule Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ LogGroup 'Publish to PSGallery' {
145145 if ($whatIf ) {
146146 Write-Host " Publish-PSResource -Path $modulePath -Repository PSGallery -ApiKey ***"
147147 } else {
148- $publishedPackage = Find-PSResource - Name $name - Version $publishPSVersion - Repository PSGallery - ErrorAction Stop
148+ $publishedPackage = Find-PSResource - Name $name - Version $publishPSVersion - Repository PSGallery - ErrorAction SilentlyContinue
149149 if ($publishedPackage ) {
150150 Write-Host (
151151 " ::notice title=♻️ Resuming Gallery-only publication::$name $publishPSVersion is already " +
Original file line number Diff line number Diff line change @@ -84,4 +84,25 @@ Describe 'Publish-PSModule recovery' {
8484
8585 $script :publishInvoked | Should - BeFalse
8686 }
87+
88+ It ' publishes when the resolved version is not in the Gallery' {
89+ $publishMarkerPath = Join-Path - Path $script :workspacePath - ChildPath ' publish-invoked'
90+ Set-Item - Path function:global:Find-PSResource - Value {
91+ [CmdletBinding ()]
92+ param (
93+ [string ] $Name ,
94+ [string ] $Version ,
95+ [string ] $Repository
96+ )
97+
98+ Write-Error " Package with name '$Name ', version '$Version ' could not be found in repository '$Repository '."
99+ }
100+ Set-Item - Path function:global:Publish-PSResource - Value {
101+ $null = New-Item - Path (Join-Path - Path $env: GITHUB_WORKSPACE - ChildPath ' publish-invoked' ) - ItemType File - Force
102+ }
103+
104+ { & $script :publishScriptPath } | Should -Not - Throw
105+
106+ (Test-Path - Path $publishMarkerPath ) | Should - BeTrue
107+ }
87108}
You can’t perform that action at this time.
0 commit comments