@@ -13,36 +13,41 @@ jobs:
1313 steps :
1414 - uses : actions/checkout@v3
1515
16- # Install BuildHelpers with AllowClobber
17- - name : Install BuildHelpers with AllowClobber
16+ # Install BuildHelpers clean with AllowClobber
17+ - name : Install BuildHelpers (Force + AllowClobber)
1818 shell : pwsh
1919 run : |
2020 Install-Module BuildHelpers -Force -AllowClobber -Scope CurrentUser
2121 Import-Module BuildHelpers -Force
2222
23- # Patch Update-Metadata to avoid PropertyName error
24- - name : Patch Update-Metadata
23+ # Patch BuildHelpers Update-Metadata to avoid ' PropertyName' error
24+ - name : Patch BuildHelpers Update-Metadata
2525 shell : pwsh
2626 run : |
27- function Update-Metadata {
28- param (
29- [string]$Path,
30- [string]$PropertyName = 'ModuleVersion',
31- $Value
32- )
33- $content = Get-Content $Path -Raw
34- $pattern = "$PropertyName\s*=\s*'[^']*'"
35- if ($content -match $pattern) {
36- $content = $content -replace $pattern, "$PropertyName = '$Value'"
37- } else {
38- Write-Warning "Property $PropertyName not found, appending."
39- $content += "`n$PropertyName = '$Value'"
27+ $patchedModule = New-Module -Name BuildHelpers -ScriptBlock {
28+ function Update-Metadata {
29+ param (
30+ [string]$Path,
31+ [string]$PropertyName = 'ModuleVersion',
32+ $Value
33+ )
34+ $content = Get-Content $Path -Raw
35+ $pattern = "$PropertyName\s*=\s*'[^']*'"
36+ if ($content -match $pattern) {
37+ $content = $content -replace $pattern, "$PropertyName = '$Value'"
38+ } else {
39+ Write-Warning "Property $PropertyName not found, appending."
40+ $content += "`n$PropertyName = '$Value'"
41+ }
42+ Set-Content -Path $Path -Value $content -Encoding UTF8
43+ Write-Host "Updated '$PropertyName' in $Path"
4044 }
41- Set-Content -Path $Path -Value $content -Encoding UTF8
42- Write-Host "Updated '$PropertyName' in $Path"
45+ Export-ModuleMember -Function Update-Metadata
4346 }
44- Set-Alias -Name Update-Metadata -Value Update-Metadata -Scope Global
4547
48+ Import-Module $patchedModule -Force
49+
50+ # Check if the version has been bumped
4651 - name : Check if version has been bumped
4752 shell : pwsh
4853 id : check_if_versions_bumped
5257 $bumped = $GithubVersion -ge $GalleryVersion
5358 echo "VERSION_BUMPED=$bumped" >> $env:GITHUB_ENV
5459
60+ # Publish to PSGallery if version is bumped
5561 - name : Publish to PSGallery
5662 shell : powershell
5763 if : env.VERSION_BUMPED == 'True'
0 commit comments