Skip to content

Commit ce32b49

Browse files
committed
attempt to add a verification which checks if version in the repo matches the release tag
1 parent b979d18 commit ce32b49

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/publish.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,49 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121

22+
# --- Manual Version Reminder / Guard ---
23+
- name: Verify manifest version matches release tag (manual update reminder)
24+
if: github.event_name == 'release'
25+
shell: pwsh
26+
run: |
27+
$tag = "$env:GITHUB_REF" -replace '^refs/tags/', ''
28+
if (-not $tag) { Write-Error 'No tag ref found.'; exit 1 }
29+
$tagCore = $tag -replace '^v',''
30+
if ($tagCore -notmatch '^([0-9]+\.[0-9]+\.[0-9]+)(?:-([A-Za-z0-9\-]+))?$') {
31+
Write-Error "Tag '$tag' has invalid format. Use vX.Y.Z or vX.Y.Z-suffix"; exit 1
32+
}
33+
$expectedVersion = $Matches[1]
34+
$expectedPrerelease = $Matches[2]
35+
$psd1Path = Join-Path $PWD 'PSGraph/PSQuickGraph.psd1'
36+
if (-not (Test-Path $psd1Path)) { Write-Error 'PSQuickGraph.psd1 not found.'; exit 1 }
37+
$raw = Get-Content $psd1Path -Raw
38+
$moduleVersion = ($raw | Select-String -Pattern "ModuleVersion\s*=\s*'([^']+)'" -AllMatches).Matches.Groups[1].Value
39+
$prLine = ($raw | Select-String -Pattern "^\s*Prerelease\s*=\s*'([^']+)'" -AllMatches)
40+
$manifestPrerelease = if ($prLine) { $prLine.Matches.Groups[1].Value } else { $null }
41+
$ok = $true
42+
if ($moduleVersion -ne $expectedVersion) {
43+
Write-Host "::error::Manifest ModuleVersion ($moduleVersion) does not match tag version ($expectedVersion)."; $ok = $false
44+
}
45+
if ($expectedPrerelease) {
46+
if ($manifestPrerelease -ne $expectedPrerelease) {
47+
Write-Host "::error::Manifest Prerelease ('$manifestPrerelease') does not match tag prerelease ('$expectedPrerelease')."; $ok = $false
48+
}
49+
} else {
50+
if ($manifestPrerelease) {
51+
Write-Host "::warning::Manifest has Prerelease '$manifestPrerelease' but tag is a stable release."; $ok = $false
52+
}
53+
}
54+
if (-not $ok) {
55+
Write-Host '--- Manual Action Required ---'
56+
Write-Host 'Update PSGraph/PSQuickGraph.psd1 with:'
57+
Write-Host " ModuleVersion = '$expectedVersion'"
58+
if ($expectedPrerelease) { Write-Host " Prerelease = '$expectedPrerelease'" } else { Write-Host ' (Remove/Comment any Prerelease entry)' }
59+
Write-Host 'Commit the change and recreate the release (or re-run after fixing).'
60+
exit 1
61+
} else {
62+
Write-Host "Manifest version check passed ($moduleVersion${if($manifestPrerelease){"-$manifestPrerelease"}})."
63+
}
64+
2265
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
2366
uses: actions/setup-dotnet@v3
2467
with:

0 commit comments

Comments
 (0)