Skip to content

Commit a5df0f5

Browse files
authored
Create PoShGallery-Publish.yml
1 parent a46c44a commit a5df0f5

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Publish to PowerShell Gallery
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
publish:
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Update version in psd1 and UI.xaml
20+
shell: pwsh
21+
run: |
22+
$tagVersion = '${{ github.ref_name }}' -replace '^v', '' # es: "v1.0.0" → "1.0.0"
23+
24+
# Update version in PSD1
25+
$psd1Path = Join-Path $PWD 'IntuneWinAppUtilGUI.psd1'
26+
(Get-Content $psd1Path) -replace '(?<=ModuleVersion\s*=\s*'')[^'']+', $tagVersion | Set-Content $psd1Path
27+
28+
# Update version in XAML title
29+
$xamlPath = Join-Path $PWD 'UI/UI.xaml'
30+
if (Test-Path $xamlPath) {
31+
(Get-Content $xamlPath) -replace '(?<=Title\s*=\s*"IntuneWinAppUtil GUI · )[^"]+', $tagVersion | Set-Content $xamlPath
32+
}
33+
34+
- name: Validate module manifest
35+
shell: pwsh
36+
run: |
37+
$psd1Path = Join-Path $PWD 'IntuneWinAppUtilGUI.psd1'
38+
Test-ModuleManifest -Path $psd1Path -Verbose
39+
40+
- name: Prepare module package
41+
shell: pwsh
42+
run: |
43+
$outDir = Join-Path $PWD 'build'
44+
$moduleName = 'IntuneWinAppUtilGUI'
45+
$moduleDir = Join-Path $outDir $moduleName
46+
47+
if (Test-Path $outDir) { Remove-Item -Recurse -Force $outDir }
48+
New-Item -ItemType Directory -Path $moduleDir -Force | Out-Null
49+
50+
$includeFiles = @(
51+
"$moduleName.psd1",
52+
"$moduleName.psm1",
53+
"README.md"
54+
)
55+
56+
foreach ($file in $includeFiles) {
57+
if (Test-Path $file) {
58+
Copy-Item -Path $file -Destination $moduleDir -Force
59+
}
60+
}
61+
62+
$foldersToInclude = @("Private", "Public", "Assets", "UI")
63+
foreach ($folder in $foldersToInclude) {
64+
if (Test-Path $folder) {
65+
Copy-Item -Path $folder -Destination $moduleDir -Recurse -Force
66+
}
67+
}
68+
69+
- name: Publish module to PowerShell Gallery
70+
shell: pwsh
71+
run: |
72+
$modulePath = Join-Path $PWD 'build' | Join-Path -ChildPath 'IntuneWinAppUtilGUI'
73+
74+
if (-not (Get-PSRepository -Name 'PSGallery' -ErrorAction SilentlyContinue)) {
75+
Register-PSRepository -Name 'PSGallery' -SourceLocation 'https://www.powershellgallery.com/api/v2' -InstallationPolicy Trusted
76+
}
77+
78+
Publish-Module -Path $modulePath `
79+
-NuGetApiKey "${{ secrets.NUGET_API_KEY }}" `
80+
-Verbose

0 commit comments

Comments
 (0)