11[CmdletBinding ()]
22param ()
33
4- # region Load inputs
5- $env: GITHUB_REPOSITORY_NAME = $env: GITHUB_REPOSITORY -replace ' .+/'
4+ Import-Module - Name ' Helpers' - Force
65
7- $name = if ([string ]::IsNullOrEmpty($env: PSMODULE_PUBLISH_PSMODULE_INPUT_Name )) {
8- $env: GITHUB_REPOSITORY_NAME
9- } else {
10- $env: PSMODULE_PUBLISH_PSMODULE_INPUT_Name
11- }
12- $modulePath = Resolve-Path - Path " $env: PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath /$name " | Select-Object - ExpandProperty Path
13- $apiKey = $env: PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey
6+ LogGroup ' Load inputs' {
7+ $env: GITHUB_REPOSITORY_NAME = $env: GITHUB_REPOSITORY -replace ' .+/'
148
15- Write-Output " Module name: [$name ]"
16- Write-Output " Module path: [$modulePath ]"
17- # endregion Load inputs
9+ $name = if ([string ]::IsNullOrEmpty($env: PSMODULE_PUBLISH_PSMODULE_INPUT_Name )) {
10+ $env: GITHUB_REPOSITORY_NAME
11+ } else {
12+ $env: PSMODULE_PUBLISH_PSMODULE_INPUT_Name
13+ }
14+ $modulePath = Resolve-Path - Path " $env: PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath /$name " | Select-Object - ExpandProperty Path
15+ $apiKey = $env: PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey
16+
17+ Write-Output " Module name: [$name ]"
18+ Write-Output " Module path: [$modulePath ]"
19+ }
1820
19- # region Load publish context from environment
20- Set-GitHubLogGroup ' Load publish context from environment' {
21+ LogGroup ' Load publish context from environment' {
2122 $createRelease = $env: PUBLISH_CONTEXT_CreateRelease -eq ' true'
2223 $createPrerelease = $env: PUBLISH_CONTEXT_CreatePrerelease -eq ' true'
2324 $newVersionString = $env: PUBLISH_CONTEXT_NewVersion
@@ -45,21 +46,17 @@ Set-GitHubLogGroup 'Load publish context from environment' {
4546 Write-Output " WhatIf: [$whatIf ]"
4647 Write-Output ' -------------------------------------------------'
4748}
48- # endregion Load publish context from environment
4949
50- # region Load PR information
51- Set-GitHubLogGroup ' Load PR information' {
50+ LogGroup ' Load PR information' {
5251 $githubEventJson = Get-Content $env: GITHUB_EVENT_PATH
5352 $githubEvent = $githubEventJson | ConvertFrom-Json
5453 $pull_request = $githubEvent.pull_request
5554 if (-not $pull_request ) {
5655 throw ' GitHub event does not contain pull_request data. This script must be run from a pull_request event.'
5756 }
5857}
59- # endregion Load PR information
6058
61- # region Validate manifest and set module path
62- Set-GitHubLogGroup ' Validate manifest and set module path' {
59+ LogGroup ' Validate manifest and set module path' {
6360 Add-PSModulePath - Path (Split-Path - Path $modulePath - Parent)
6461 $manifestFilePath = Join-Path $modulePath " $name .psd1"
6562 Write-Output " Module manifest file path: [$manifestFilePath ]"
@@ -68,10 +65,8 @@ Set-GitHubLogGroup 'Validate manifest and set module path' {
6865 exit 1
6966 }
7067}
71- # endregion Validate manifest and set module path
7268
73- # region Update module manifest
74- Set-GitHubLogGroup ' Update module manifest' {
69+ LogGroup ' Update module manifest' {
7570 Write-Output ' Bump module version -> module metadata: Update-ModuleMetadata'
7671 $manifestNewVersion = " $ ( $newVersion.Major ) .$ ( $newVersion.Minor ) .$ ( $newVersion.Patch ) "
7772 Set-ModuleManifest - Path $manifestFilePath - ModuleVersion $manifestNewVersion - Verbose:$false
@@ -82,16 +77,12 @@ Set-GitHubLogGroup 'Update module manifest' {
8277
8378 Show-FileContent - Path $manifestFilePath
8479}
85- # endregion Update module manifest
8680
87- # region Install module dependencies
88- Set-GitHubLogGroup ' Install module dependencies' {
81+ LogGroup ' Install module dependencies' {
8982 Resolve-PSModuleDependency - ManifestFilePath $manifestFilePath
9083}
91- # endregion Install module dependencies
9284
93- # region Publish to PSGallery
94- Set-GitHubLogGroup ' Publish-ToPSGallery' {
85+ LogGroup ' Publish-ToPSGallery' {
9586 if ($createPrerelease ) {
9687 $publishPSVersion = " $ ( $newVersion.Major ) .$ ( $newVersion.Minor ) .$ ( $newVersion.Patch ) -$ ( $newVersion.Prerelease ) "
9788 } else {
@@ -123,10 +114,8 @@ Set-GitHubLogGroup 'Publish-ToPSGallery' {
123114 }
124115 }
125116}
126- # endregion Publish to PSGallery
127117
128- # region Create GitHub Release
129- Set-GitHubLogGroup ' New-GitHubRelease' {
118+ LogGroup ' New-GitHubRelease' {
130119 Write-Output ' Create new GitHub release'
131120 $releaseCreateCommand = @ (' release' , ' create' , $newVersion.ToString ())
132121 $notesFilePath = $null
@@ -202,6 +191,5 @@ Set-GitHubLogGroup 'New-GitHubRelease' {
202191 }
203192 Write-Host " ::notice::Release created: [$newVersion ]"
204193}
205- # endregion Create GitHub Release
206194
207195Write-Output " Publishing complete. Version: [$ ( $newVersion.ToString ()) ]"
0 commit comments