Skip to content

Commit c495e6a

Browse files
Fix error message to reference init.ps1 for missing PUBLISH_CONTEXT_NewVersion and refactor manifest validation region
1 parent 11e4fe6 commit c495e6a

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

scripts/publish.ps1

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Set-GitHubLogGroup 'Load publish context from environment' {
2929
$usePRTitleAsNotesHeading = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsNotesHeading -eq 'true'
3030

3131
if ([string]::IsNullOrWhiteSpace($newVersionString)) {
32-
Write-Error 'PUBLISH_CONTEXT_NewVersion is not set. Run main.ps1 first.'
32+
Write-Error 'PUBLISH_CONTEXT_NewVersion is not set. Run init.ps1 first.'
3333
exit 1
3434
}
3535

@@ -58,29 +58,17 @@ Set-GitHubLogGroup 'Load PR information' {
5858
}
5959
#endregion Load PR information
6060

61-
#region Get manifest version
62-
Set-GitHubLogGroup 'Get latest version - Manifest' {
61+
#region Validate manifest and set module path
62+
Set-GitHubLogGroup 'Validate manifest and set module path' {
6363
Add-PSModulePath -Path (Split-Path -Path $modulePath -Parent)
6464
$manifestFilePath = Join-Path $modulePath "$name.psd1"
6565
Write-Output "Module manifest file path: [$manifestFilePath]"
6666
if (-not (Test-Path -Path $manifestFilePath)) {
6767
Write-Error "Module manifest file not found at [$manifestFilePath]"
6868
exit 1
6969
}
70-
try {
71-
$manifestVersion = New-PSSemVer -Version (Test-ModuleManifest $manifestFilePath -Verbose:$false).Version
72-
} catch {
73-
if ([string]::IsNullOrEmpty($manifestVersion)) {
74-
Write-Warning 'Could not find the module version in the manifest. Using ''0.0.0'' as the version.'
75-
$manifestVersion = New-PSSemVer -Version '0.0.0'
76-
}
77-
}
78-
Write-Output '-------------------------------------------------'
79-
Write-Output 'Manifest version:'
80-
Write-Output $manifestVersion.ToString()
81-
Write-Output '-------------------------------------------------'
8270
}
83-
#endregion Get manifest version
71+
#endregion Validate manifest and set module path
8472

8573
#region Update module manifest
8674
Set-GitHubLogGroup 'Update module manifest' {

0 commit comments

Comments
 (0)