Add script for publishing to PowerShell Gallery

This commit is contained in:
Alphaeus Mote
2025-05-09 14:37:56 -04:00
parent 7478796d16
commit 060ab64d70
2 changed files with 74 additions and 18 deletions
+39
View File
@@ -0,0 +1,39 @@
# Publish-PSProxmoxToGallery.ps1
# This script publishes the PSProxmox module to the PowerShell Gallery.
param(
[Parameter(Mandatory = $true)]
[string]$ApiKey,
[Parameter(Mandatory = $false)]
[string]$Version = (Get-Date -Format "yyyy.MM.dd.HHmm")
)
# Ensure the module is built
Write-Host "Building the module..."
& "$PSScriptRoot\build-release-only.ps1"
# Get the release directory
$releaseDir = Join-Path -Path (Split-Path -Parent $PSScriptRoot) -ChildPath "Release\$Version"
if (-not (Test-Path -Path $releaseDir)) {
Write-Error "Release directory not found: $releaseDir"
exit 1
}
# Publish the module to PowerShell Gallery
Write-Host "Publishing module to PowerShell Gallery..."
try {
Publish-Module -Path $releaseDir -NuGetApiKey $ApiKey -Verbose
Write-Host "Module published successfully!" -ForegroundColor Green
}
catch {
Write-Error "Failed to publish module: $_"
exit 1
}
# Open the PowerShell Gallery page
$moduleName = "PSProxmox"
Start-Process "https://www.powershellgallery.com/packages/$moduleName"
Write-Host "Done!"