Skip to content

Commit 3dfb6d1

Browse files
author
Uwe Janke
committed
Add GitHub Actions workflow for PowerShell Gallery publishing
- New workflow: publish-psgallery.yml - Triggered on: release tag (v*.*.*) - Steps: Validate manifest, Publish to PSGallery, Verify on PSGallery - Requires: GitHub Secret PSGALLERY_API_KEY Usage: 1. Set GitHub Secret: https://github.com/JankeUwe/sqmSQLTool/settings/secrets/actions Name: PSGALLERY_API_KEY Value: <your-psgallery-api-key> 2. Push a tag: git tag v1.4.3.0 && git push origin v1.4.3.0 3. Workflow runs automatically
1 parent 4d40c83 commit 3dfb6d1

1 file changed

Lines changed: 145 additions & 0 deletions

File tree

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# =============================================================================
2+
# sqmSQLTool - Publish to PowerShell Gallery
3+
# =============================================================================
4+
#
5+
# Laeuft bei: Push eines Release-Tags (v*.*.*)
6+
#
7+
# Was passiert:
8+
# 1. PowerShell Gallery API Key aus GitHub Secret laden
9+
# 2. Modul validieren (Test-ModuleManifest)
10+
# 3. Publish-Module zu PSGallery executieren
11+
# 4. Bei Fehler: Detaillierter Error Report
12+
#
13+
# Voraussetzung:
14+
# - GitHub Secret: PSGALLERY_API_KEY (PowerShell Gallery API Key)
15+
# - Gespeichert in: https://github.com/JankeUwe/sqmSQLTool/settings/secrets/actions
16+
#
17+
# =============================================================================
18+
19+
name: Publish to PowerShell Gallery
20+
21+
on:
22+
push:
23+
tags:
24+
- 'v*.*.*'
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
publish-psgallery:
31+
runs-on: windows-latest
32+
name: Publish to PSGallery
33+
34+
steps:
35+
# ------------------------------------------------------------------
36+
# 1. Repository auschecken
37+
# ------------------------------------------------------------------
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
# ------------------------------------------------------------------
42+
# 2. Modul-Version aus PSD1 lesen
43+
# ------------------------------------------------------------------
44+
- name: Read module version
45+
id: version
46+
shell: pwsh
47+
run: |
48+
$psd1 = Import-PowerShellDataFile "sqmSQLTool.psd1"
49+
$ver = $psd1.ModuleVersion
50+
Write-Host "Module version: $ver"
51+
echo "version=$ver" >> $env:GITHUB_OUTPUT
52+
53+
# ------------------------------------------------------------------
54+
# 3. Modul validieren
55+
# ------------------------------------------------------------------
56+
- name: Validate module manifest
57+
shell: pwsh
58+
run: |
59+
Write-Host "🔍 Validiere Modul-Manifest..."
60+
$result = Test-ModuleManifest -Path "sqmSQLTool.psd1" -Verbose
61+
if ($result) {
62+
Write-Host "✅ Manifest valid"
63+
Write-Host " Version: $($result.Version)"
64+
Write-Host " Functions: $($result.ExportedFunctions.Count)"
65+
} else {
66+
Write-Host "❌ Manifest invalid"
67+
exit 1
68+
}
69+
70+
# ------------------------------------------------------------------
71+
# 4. Publish zu PowerShell Gallery
72+
# ------------------------------------------------------------------
73+
- name: Publish to PowerShell Gallery
74+
shell: pwsh
75+
env:
76+
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
77+
run: |
78+
if (-not $env:PSGALLERY_API_KEY) {
79+
Write-Host "❌ FEHLER: PSGALLERY_API_KEY GitHub Secret nicht gesetzt!"
80+
Write-Host "Setze es unter: https://github.com/JankeUwe/sqmSQLTool/settings/secrets/actions"
81+
exit 1
82+
}
83+
84+
Write-Host "🚀 Publish sqmSQLTool ${{ steps.version.outputs.version }} zu PSGallery..."
85+
Write-Host ""
86+
87+
# TLS 1.2 erzwingen (für ältere PS-Versionen)
88+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
89+
90+
try {
91+
Publish-Module -Path "." `
92+
-NuGetApiKey $env:PSGALLERY_API_KEY `
93+
-Repository PSGallery `
94+
-Force `
95+
-ErrorAction Stop
96+
97+
Write-Host ""
98+
Write-Host "✅ ERFOLG! Modul zu PSGallery gepublisht"
99+
} catch {
100+
Write-Host ""
101+
Write-Host "❌ FEHLER beim Publishing:"
102+
Write-Host $_.Exception.Message
103+
Write-Host ""
104+
Write-Host "Inner Exception:"
105+
Write-Host $_.Exception.InnerException.Message
106+
exit 1
107+
}
108+
109+
# ------------------------------------------------------------------
110+
# 5. Verify auf PSGallery
111+
# ------------------------------------------------------------------
112+
- name: Verify on PowerShell Gallery
113+
shell: pwsh
114+
run: |
115+
Write-Host "⏳ Warte 10 Sekunden für PSGallery Index Update..."
116+
Start-Sleep -Seconds 10
117+
118+
Write-Host "🔍 Verifiziere auf PSGallery..."
119+
try {
120+
$module = Find-Module -Name sqmSQLTool -Repository PSGallery -ErrorAction Stop
121+
Write-Host "✅ Modul gefunden!"
122+
Write-Host " Name: $($module.Name)"
123+
Write-Host " Version: $($module.Version)"
124+
Write-Host " Author: $($module.Author)"
125+
Write-Host " Published: $($module.PublishedDate)"
126+
} catch {
127+
Write-Host "⚠️ Modul noch nicht auf PSGallery sichtbar (kann bis 5 Min dauern)"
128+
}
129+
130+
# ------------------------------------------------------------------
131+
# 6. Erfolgs-Notification
132+
# ------------------------------------------------------------------
133+
- name: Success notification
134+
if: success()
135+
shell: pwsh
136+
run: |
137+
Write-Host ""
138+
Write-Host "🎉 ERFOLG! sqmSQLTool ${{ steps.version.outputs.version }} wurde gepublisht!"
139+
Write-Host ""
140+
Write-Host "Verfügbar unter:"
141+
Write-Host " 🌐 PSGallery: https://www.powershellgallery.com/packages/sqmSQLTool/${{ steps.version.outputs.version }}"
142+
Write-Host " 📦 GitHub: https://github.com/JankeUwe/sqmSQLTool/releases/tag/v${{ steps.version.outputs.version }}"
143+
Write-Host ""
144+
Write-Host "Installation:"
145+
Write-Host " Install-Module sqmSQLTool -Repository PSGallery"

0 commit comments

Comments
 (0)