-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (35 loc) · 1.29 KB
/
publish.yml
File metadata and controls
39 lines (35 loc) · 1.29 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
name: Publish PowerShell Module
on:
release:
types: ["published"]
jobs:
publish-to-gallery:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Publish
env:
NUGET_KEY: ${{ secrets.NUGET_KEY }}
shell: pwsh
run: |
$modulePath = Join-Path $env:GITHUB_WORKSPACE "ps-copyid"
if (-not (Test-Path $modulePath)) {
throw "Module path not found: $modulePath"
}
try {
Write-Host "Publishing module from: $modulePath"
Publish-Module -Path $modulePath -NuGetApiKey $env:NUGET_KEY -Repository PSGallery -ErrorAction Stop
# Verify publish was successful
$moduleInfo = Test-ModuleManifest -Path (Join-Path $modulePath "ps-copyid.psd1")
$publishedModule = Find-Module -Name $moduleInfo.Name -RequiredVersion $moduleInfo.Version
if ($publishedModule) {
Write-Host "Successfully published $($moduleInfo.Name) version $($moduleInfo.Version)"
} else {
throw "Module verification failed after publish"
}
}
catch {
throw "Failed to publish module: $_"
}