forked from Nibushi/SupportDeathClock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.ps1
More file actions
62 lines (51 loc) · 1.77 KB
/
publish.ps1
File metadata and controls
62 lines (51 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<#
.SYNOPSIS
Compiles and Publishes the WinEOL module to the PowerShell Gallery.
.DESCRIPTION
This script performs the following actions:
1. Checks for the API key (ApiKey) parameter.
2. Copies the root README.md to the module folder (WinEOL\README.md) so it appears on the Gallery page.
3. Runs Publish-Module.
4. Cleans up the copied README.md.
.PARAMETER ApiKey
The NuGet API Key for the PowerShell Gallery. Required.
.EXAMPLE
.\publish.ps1 -ApiKey "your-api-key"
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$ApiKey
)
$ErrorActionPreference = 'Stop'
$moduleName = "WinEOL"
$modulePath = Join-Path $PSScriptRoot $moduleName
$manifestPath = Join-Path $modulePath "$moduleName.psd1"
$rootReadme = Join-Path $PSScriptRoot "README.md"
$moduleReadme = Join-Path $modulePath "README.md"
Write-Host "Starting publication process for '$moduleName'..." -ForegroundColor Cyan
# 1. Validation
if (-not (Test-Path $rootReadme)) {
Write-Error "Root README.md not found at $rootReadme"
}
# 2. Copy README to Module path
Write-Host "Copying README.md to module folder..." -ForegroundColor Gray
Copy-Item -Path $rootReadme -Destination $moduleReadme -Force
try {
# 3. Publish
Write-Host "Publishing module to PowerShell Gallery..." -ForegroundColor Cyan
# Note: Validate module first
# Test-ModuleManifest -Path "$modulePath\$moduleName.psd1"
Publish-Module -Path $modulePath -NuGetApiKey $ApiKey -Verbose
Write-Host "Successfully published $moduleName!" -ForegroundColor Green
}
catch {
Write-Error "Publishing failed: $_"
}
finally {
# 4. Cleanup
if (Test-Path $moduleReadme) {
Write-Host "Cleaning up module README..." -ForegroundColor Gray
Remove-Item -Path $moduleReadme -Force
}
}