From 9a13b0567c4f3c05e78baed7a4b9d32a6eaf8c6e Mon Sep 17 00:00:00 2001 From: GraceSolutions Date: Thu, 4 Jun 2026 23:01:56 -0400 Subject: [PATCH] ci: initialize PSResourceGet store before Set-PSResourceRepository --- .gitea/workflows/publish-psgallery.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/publish-psgallery.yml b/.gitea/workflows/publish-psgallery.yml index 9f90cc7..e391266 100644 --- a/.gitea/workflows/publish-psgallery.yml +++ b/.gitea/workflows/publish-psgallery.yml @@ -278,7 +278,21 @@ jobs: throw "Microsoft.PowerShell.PSResourceGet is not installed on the host runner. Provision it (Install-Module Microsoft.PowerShell.PSResourceGet -Scope AllUsers)." } Import-Module Microsoft.PowerShell.PSResourceGet -ErrorAction Stop - Set-PSResourceRepository -Name PSGallery -Trusted -ApiVersion v2 + + $storeDir = Join-Path $HOME '.local/share/PSResourceGet' + if (-not (Test-Path $storeDir)) { + Write-Host "==> Creating PSResourceGet store directory: $storeDir" + New-Item -ItemType Directory -Path $storeDir -Force | Out-Null + } + + $existing = Get-PSResourceRepository -Name PSGallery -ErrorAction SilentlyContinue + if (-not $existing) { + Write-Host "==> Registering PSGallery repository" + Register-PSResourceRepository -PSGallery -Trusted -ErrorAction Stop + } else { + Write-Host "==> PSGallery already registered; ensuring Trusted + ApiVersion v2" + Set-PSResourceRepository -Name PSGallery -Trusted -ApiVersion v2 -ErrorAction Stop + } Get-PSResourceRepository -Name PSGallery | Format-Table Name,Uri,Trusted,ApiVersion - name: Verify PowerShell Gallery API key is configured