Skip to content

Commit de32190

Browse files
committed
Deploy: use explicit manifest versions and dep-ordered publish
The previous workflow auto-incremented the revision (2.0.0 -> 2.0.0.1) and then committed the bump back to main. With explicit semver bumps in manifests for 2.0.0, that auto-bump is no longer wanted. Also, Test-ModuleManifest validates RequiredModules against installed modules, which fails when publishing the dependency chain (IntelliTect.File requires IntelliTect.Common, etc.) before each dep has reached the gallery. Changes: - Drop the auto-bump and follow-up commit steps entirely. - Drive publishing in explicit dependency order (Common, File, Git, PSToolbox). - Use Import-PowerShellDataFile to read the version (no manifest validation). - Find-PSResource short-circuits if the version is already on PSGallery so pushes that touched only docs/CI don't fail with 'version already exists'. - Pass -SkipModuleManifestValidate to Publish-PSResource so RequiredModules checks don't block the chain. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 65ce46a commit de32190

1 file changed

Lines changed: 28 additions & 44 deletions

File tree

‎.github/workflows/Deploy.yml‎

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -32,49 +32,8 @@ jobs:
3232
}
3333
$modules = $modules | Sort-Object -Unique
3434
Write-Host "Changed modules: $($modules -join ', ')"
35-
if ($modules.Length -eq 0) {
36-
"modules=" >> $env:GITHUB_OUTPUT
37-
return
38-
}
39-
$staging = New-Item -ItemType Directory -Force -Path StagingChangedModules
40-
foreach ($m in $modules) {
41-
Copy-Item -Path "Modules/$m" -Destination $staging.FullName -Recurse -Force
42-
}
4335
"modules=$($modules -join ',')" >> $env:GITHUB_OUTPUT
4436
45-
- name: Bump Module Version
46-
if: steps.discover.outputs.modules != ''
47-
shell: pwsh
48-
run: |
49-
$moduleFolders = Get-ChildItem StagingChangedModules -Directory
50-
foreach ($item in $moduleFolders) {
51-
$manifest = Get-ChildItem $item.FullName -Filter '*.psd1' | Select-Object -First 1
52-
if (-not $manifest) {
53-
Write-Error "Manifest for $($item.Name) was not found"
54-
continue
55-
}
56-
$current = (Test-ModuleManifest -Path $manifest.FullName).Version
57-
$build = if ($current.Build -ge 0) { $current.Build } else { 0 }
58-
$revision = if ($current.Revision -ge 0) { $current.Revision + 1 } else { 1 }
59-
$updated = [Version]::new($current.Major, $current.Minor, $build, $revision)
60-
$repoManifest = Join-Path '.' 'Modules' $item.Name $manifest.Name
61-
Update-ModuleManifest -Path $repoManifest -ModuleVersion $updated
62-
Update-ModuleManifest -Path $manifest.FullName -ModuleVersion $updated
63-
Write-Host "$($item.Name): $current -> $updated"
64-
}
65-
66-
- name: Commit Version Bump
67-
if: steps.discover.outputs.modules != ''
68-
shell: bash
69-
run: |
70-
git config --global user.email "actions@github.com"
71-
git config --global user.name "github-actions[bot]"
72-
git add Modules/*/*.psd1
73-
if ! git diff --staged --quiet; then
74-
git commit -m "[skip ci] Bump module version from build agent"
75-
git push
76-
fi
77-
7837
- name: Install PSResourceGet
7938
if: steps.discover.outputs.modules != ''
8039
shell: pwsh
@@ -90,7 +49,32 @@ jobs:
9049
PSGALLERY_API_KEY: ${{ secrets.POWERSHELL_GALLERY_API_KEY }}
9150
run: |
9251
Import-Module Microsoft.PowerShell.PSResourceGet
93-
foreach ($item in Get-ChildItem StagingChangedModules -Directory) {
94-
Write-Host "Publishing $($item.Name) ..."
95-
Publish-PSResource -Path $item.FullName -ApiKey $env:PSGALLERY_API_KEY -Repository PSGallery -Verbose
52+
53+
# Publish in dependency order: leaf modules first, umbrella last.
54+
$order = @(
55+
'IntelliTect.Common',
56+
'IntelliTect.File',
57+
'IntelliTect.Git',
58+
'IntelliTect.PSToolbox'
59+
)
60+
$changed = '${{ steps.discover.outputs.modules }}' -split ','
61+
62+
foreach ($name in $order) {
63+
if ($changed -notcontains $name) { continue }
64+
$path = Join-Path '.' 'Modules' $name
65+
$manifestPath = Join-Path $path "$name.psd1"
66+
if (-not (Test-Path $manifestPath)) {
67+
Write-Warning "Manifest not found for $name at $manifestPath; skipping."
68+
continue
69+
}
70+
$data = Import-PowerShellDataFile -Path $manifestPath
71+
$version = $data.ModuleVersion
72+
Write-Host "Checking PSGallery for $name $version ..."
73+
$existing = Find-PSResource -Name $name -Version $version -Repository PSGallery -ErrorAction SilentlyContinue
74+
if ($existing) {
75+
Write-Host "$name $version already on PSGallery; skipping."
76+
continue
77+
}
78+
Write-Host "Publishing $name $version ..."
79+
Publish-PSResource -Path $path -ApiKey $env:PSGALLERY_API_KEY -Repository PSGallery -SkipModuleManifestValidate -Verbose
9680
}

0 commit comments

Comments
 (0)