From 7fe9b7651478fa6d1409a9cc5d94acdcfcc9be78 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 27 Feb 2025 22:11:37 +0100 Subject: [PATCH 01/30] WorkspaceDirectory --- .github/workflows/Action-Test.yml | 3 ++- action.yml | 34 ++++++++++++++++------------ scripts/helpers/Publish-PSModule.ps1 | 28 +++++++++++------------ scripts/main.ps1 | 22 ++++++++++++------ 4 files changed, 51 insertions(+), 36 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 35bb52d..08cba2f 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -35,6 +35,7 @@ jobs: Verbose: true Debug: true Name: PSModuleTest - ModulePath: tests/outputs/modules + ModulePath: modules + WorkingDirectory: tests/outputs APIKey: ${{ secrets.APIKEY }} WhatIf: true diff --git a/action.yml b/action.yml index 1f4bb6c..bf19eb3 100644 --- a/action.yml +++ b/action.yml @@ -75,6 +75,10 @@ inputs: description: Allow prerelease versions if available. required: false default: 'false' + WorkingDirectory: + description: The working directory where the script will run from. + required: false + default: ${{ github.workspace }} runs: using: composite @@ -82,25 +86,27 @@ runs: - name: Run Publish-PSModule uses: PSModule/GitHub-Script@v1 env: - GITHUB_ACTION_INPUT_Name: ${{ inputs.Name }} - GITHUB_ACTION_INPUT_ModulePath: ${{ inputs.ModulePath }} - GITHUB_ACTION_INPUT_APIKey: ${{ inputs.APIKey }} - GITHUB_ACTION_INPUT_AutoCleanup: ${{ inputs.AutoCleanup }} - GITHUB_ACTION_INPUT_AutoPatching: ${{ inputs.AutoPatching }} - GITHUB_ACTION_INPUT_ConfigurationFile: ${{ inputs.ConfigurationFile }} - GITHUB_ACTION_INPUT_DatePrereleaseFormat: ${{ inputs.DatePrereleaseFormat }} - GITHUB_ACTION_INPUT_IgnoreLabels: ${{ inputs.IgnoreLabels }} - GITHUB_ACTION_INPUT_IncrementalPrerelease: ${{ inputs.IncrementalPrerelease }} - GITHUB_ACTION_INPUT_MajorLabels: ${{ inputs.MajorLabels }} - GITHUB_ACTION_INPUT_MinorLabels: ${{ inputs.MinorLabels }} - GITHUB_ACTION_INPUT_PatchLabels: ${{ inputs.PatchLabels }} - GITHUB_ACTION_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }} - GITHUB_ACTION_INPUT_WhatIf: ${{ inputs.WhatIf }} + PSMODULE_PUBLISH_PSMODULE_INPUT_Name: ${{ inputs.Name }} + PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath: ${{ inputs.ModulePath }} + PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey: ${{ inputs.APIKey }} + PSMODULE_PUBLISH_PSMODULE_INPUT_AutoCleanup: ${{ inputs.AutoCleanup }} + PSMODULE_PUBLISH_PSMODULE_INPUT_AutoPatching: ${{ inputs.AutoPatching }} + PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile: ${{ inputs.ConfigurationFile }} + PSMODULE_PUBLISH_PSMODULE_INPUT_DatePrereleaseFormat: ${{ inputs.DatePrereleaseFormat }} + PSMODULE_PUBLISH_PSMODULE_INPUT_IgnoreLabels: ${{ inputs.IgnoreLabels }} + PSMODULE_PUBLISH_PSMODULE_INPUT_IncrementalPrerelease: ${{ inputs.IncrementalPrerelease }} + PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels: ${{ inputs.MajorLabels }} + PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels: ${{ inputs.MinorLabels }} + PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels: ${{ inputs.PatchLabels }} + PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }} + PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }} + PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory: ${{ inputs.WorkingDirectory }} with: Debug: ${{ inputs.Debug }} Prerelease: ${{ inputs.Prerelease }} Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} + WorkingDirectory: ${{ inputs.WorkingDirectory }} Script: | # Publish-PSModule ${{ github.action_path }}\scripts\main.ps1 diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 075285e..cb1bbe6 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -35,44 +35,44 @@ ) LogGroup 'Set configuration' { - if (-not (Test-Path -Path $env:GITHUB_ACTION_INPUT_ConfigurationFile -PathType Leaf)) { - Write-Output "Configuration file not found at [$env:GITHUB_ACTION_INPUT_ConfigurationFile]" + if (-not (Test-Path -Path $env:PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile -PathType Leaf)) { + Write-Output "Configuration file not found at [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile]" } else { - Write-Output "Reading from configuration file [$env:GITHUB_ACTION_INPUT_ConfigurationFile]" - $configuration = ConvertFrom-Yaml -Yaml (Get-Content $env:GITHUB_ACTION_INPUT_ConfigurationFile -Raw) + Write-Output "Reading from configuration file [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile]" + $configuration = ConvertFrom-Yaml -Yaml (Get-Content $env:PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile -Raw) } $autoCleanup = ($configuration.AutoCleanup | IsNotNullOrEmpty) ? $configuration.AutoCleanup -eq 'true' : - $env:GITHUB_ACTION_INPUT_AutoCleanup -eq 'true' + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoCleanup -eq 'true' $autoPatching = ($configuration.AutoPatching | IsNotNullOrEmpty) ? $configuration.AutoPatching -eq 'true' : - $env:GITHUB_ACTION_INPUT_AutoPatching -eq 'true' + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoPatching -eq 'true' $datePrereleaseFormat = ($configuration.DatePrereleaseFormat | IsNotNullOrEmpty) ? $configuration.DatePrereleaseFormat : - $env:GITHUB_ACTION_INPUT_DatePrereleaseFormat + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_DatePrereleaseFormat $incrementalPrerelease = ($configuration.IncrementalPrerelease | IsNotNullOrEmpty) ? $configuration.IncrementalPrerelease -eq 'true' : - $env:GITHUB_ACTION_INPUT_IncrementalPrerelease -eq 'true' + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IncrementalPrerelease -eq 'true' $versionPrefix = ($configuration.VersionPrefix | IsNotNullOrEmpty) ? $configuration.VersionPrefix : - $env:GITHUB_ACTION_INPUT_VersionPrefix + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix $whatIf = ($configuration.WhatIf | IsNotNullOrEmpty) ? $configuration.WhatIf -eq 'true' : - $env:GITHUB_ACTION_INPUT_WhatIf -eq 'true' + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf -eq 'true' $ignoreLabels = (($configuration.IgnoreLabels | IsNotNullOrEmpty) ? $configuration.IgnoreLabels : - $env:GITHUB_ACTION_INPUT_IgnoreLabels) -split ',' | ForEach-Object { $_.Trim() } + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IgnoreLabels) -split ',' | ForEach-Object { $_.Trim() } $majorLabels = (($configuration.MajorLabels | IsNotNullOrEmpty) ? $configuration.MajorLabels : - $env:GITHUB_ACTION_INPUT_MajorLabels) -split ',' | ForEach-Object { $_.Trim() } + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels) -split ',' | ForEach-Object { $_.Trim() } $minorLabels = (($configuration.MinorLabels | IsNotNullOrEmpty) ? $configuration.MinorLabels : - $env:GITHUB_ACTION_INPUT_MinorLabels) -split ',' | ForEach-Object { $_.Trim() } + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels) -split ',' | ForEach-Object { $_.Trim() } $patchLabels = (($configuration.PatchLabels | IsNotNullOrEmpty) ? $configuration.PatchLabels : - $env:GITHUB_ACTION_INPUT_PatchLabels) -split ',' | ForEach-Object { $_.Trim() } + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels) -split ',' | ForEach-Object { $_.Trim() } Write-Output '-------------------------------------------------' Write-Output "Auto cleanup enabled: [$autoCleanup]" diff --git a/scripts/main.ps1 b/scripts/main.ps1 index f6f0c4e..a787261 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -10,16 +10,24 @@ LogGroup "Loading helper scripts from [$path]" { } LogGroup 'Loading inputs' { - Write-Verbose "Name: [$env:GITHUB_ACTION_INPUT_Name]" + Write-Verbose "Name: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name]" Write-Verbose "GITHUB_REPOSITORY: [$env:GITHUB_REPOSITORY]" - Write-Verbose "GITHUB_WORKSPACE: [$env:GITHUB_WORKSPACE]" + Write-Verbose "GITHUB_WORKSPACE: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory]" - $name = ($env:GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_INPUT_Name + $name = if ([string]::IsNullOrEmpty($env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name)) { + $env:GITHUB_REPOSITORY_NAME + } else { + $env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name + } Write-Verbose "Module name: [$name]" - Write-Verbose "Module path: [$env:GITHUB_ACTION_INPUT_ModulePath]" - Write-Verbose "Doc path: [$env:GITHUB_ACTION_INPUT_DocsPath]" + Write-Verbose "Module path: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath]" + Write-Verbose "Doc path: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_DocsPath]" - $modulePath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_ModulePath $name + $params = @{ + Path = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory + ChildPath = "$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath/$name" + } + $modulePath = Join-Path @params Write-Verbose "Module path: [$modulePath]" if (-not (Test-Path -Path $modulePath)) { throw "Module path [$modulePath] does not exist." @@ -29,6 +37,6 @@ LogGroup 'Loading inputs' { $params = @{ Name = $name ModulePath = $modulePath - APIKey = $env:GITHUB_ACTION_INPUT_APIKey + APIKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey } Publish-PSModule @params From 09c7f021eee3f81693a3365dca2b8a39c1003983 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 27 Feb 2025 22:13:26 +0100 Subject: [PATCH 02/30] =?UTF-8?q?=F0=9F=93=9D=20[Docs]:=20Add=20`WorkingDi?= =?UTF-8?q?rectory`=20setting=20to=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 547ed2e..0a54376 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ The action can be configured using the following settings: | `Verbose` | Enable verbose output. | `'false'` | `false` | | `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | | `false` | | `Prerelease` | Allow prerelease versions if available. | `'false'` | `false` | +| `WorkingDirectory` | The working directory where the script runs. | `'false'` | `${{ github.workspace }}` | ### Configuration file From b4697a398e678945209dbfe6e41e864eb349b601 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 27 Feb 2025 22:21:30 +0100 Subject: [PATCH 03/30] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Replace=20Wr?= =?UTF-8?q?ite-Verbose=20with=20Write-Host=20for=20clearer=20console=20out?= =?UTF-8?q?put=20in=20dependency=20resolution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helpers/Resolve-PSModuleDependency.ps1 | 23 +++++++++++-------- scripts/main.ps1 | 12 +++------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/scripts/helpers/Resolve-PSModuleDependency.ps1 b/scripts/helpers/Resolve-PSModuleDependency.ps1 index 7d8d067..d82f7e0 100644 --- a/scripts/helpers/Resolve-PSModuleDependency.ps1 +++ b/scripts/helpers/Resolve-PSModuleDependency.ps1 @@ -1,6 +1,4 @@ -#Requires -Modules Retry - -function Resolve-PSModuleDependency { +function Resolve-PSModuleDependency { <# .SYNOPSIS Resolve dependencies for a module based on the manifest file. @@ -18,19 +16,24 @@ function Resolve-PSModuleDependency { Should later be adapted to take 4 parameters sets: specific version ("requiredVersion" | "GUID"), latest version ModuleVersion, and latest version within a range MinimumVersion - MaximumVersion. #> + [Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSAvoidUsingWriteHost', '', Scope = 'Function', + Justification = 'Want to just write to the console, not the pipeline.' + )] [Alias('Resolve-PSModuleDependencies')] [CmdletBinding()] + #Requires -Modules @{ ModuleName = 'Retry'; ModuleVersion = '0.1.3' } param( # The path to the manifest file. [Parameter(Mandatory)] [string] $ManifestFilePath ) - Write-Verbose 'Resolving dependencies' + Write-Host 'Resolving dependencies' $manifest = Import-PowerShellDataFile -Path $ManifestFilePath - Write-Verbose "Reading [$ManifestFilePath]" - Write-Verbose "Found [$($manifest.RequiredModules.Count)] modules to install" + Write-Host "Reading [$ManifestFilePath]" + Write-Host "Found [$($manifest.RequiredModules.Count)] modules to install" foreach ($requiredModule in $manifest.RequiredModules) { $installParams = @{} @@ -46,19 +49,19 @@ function Resolve-PSModuleDependency { $installParams.Force = $true $installParams.Verbose = $false - Write-Verbose "[$($installParams.Name)] - Installing module" + Write-Host "[$($installParams.Name)] - Installing module" $VerbosePreferenceOriginal = $VerbosePreference $VerbosePreference = 'SilentlyContinue' Retry -Count 5 -Delay 10 { Install-Module @installParams -AllowPrerelease:$false } $VerbosePreference = $VerbosePreferenceOriginal - Write-Verbose "[$($installParams.Name)] - Importing module" + Write-Host "[$($installParams.Name)] - Importing module" $VerbosePreferenceOriginal = $VerbosePreference $VerbosePreference = 'SilentlyContinue' Import-Module @installParams $VerbosePreference = $VerbosePreferenceOriginal - Write-Verbose "[$($installParams.Name)] - Done" + Write-Host "[$($installParams.Name)] - Done" } - Write-Verbose 'Resolving dependencies - Done' + Write-Host 'Resolving dependencies - Done' } diff --git a/scripts/main.ps1 b/scripts/main.ps1 index a787261..e360ef2 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -23,15 +23,9 @@ LogGroup 'Loading inputs' { Write-Verbose "Module path: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath]" Write-Verbose "Doc path: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_DocsPath]" - $params = @{ - Path = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory - ChildPath = "$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath/$name" - } - $modulePath = Join-Path @params - Write-Verbose "Module path: [$modulePath]" - if (-not (Test-Path -Path $modulePath)) { - throw "Module path [$modulePath] does not exist." - } + $modulePath = Resolve-Path -Path "$env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory/$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath/$name" | + Select-Object -ExpandProperty Path + Write-Verbose "Resolved path: [$modulePath]" } $params = @{ From 97a4917e856bd0e4b19cca081e0f3e08cb088eac Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 27 Feb 2025 22:56:24 +0100 Subject: [PATCH 04/30] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Add=20new=20?= =?UTF-8?q?configuration=20and=20settings=20files,=20remove=20obsolete=20f?= =?UTF-8?q?iles,=20and=20update=20loader=20script=20for=20improved=20modul?= =?UTF-8?q?e=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 3 +-- action.yml | 6 +++--- scripts/main.ps1 | 18 ++++++++++-------- .../PSModuleTest/PSModuleTest.psd1 | 0 .../PSModuleTest/PSModuleTest.psm1 | 0 .../PSModuleTest/assemblies/LsonLib.dll | Bin .../PSModuleTest/data/Config.psd1 | 0 .../PSModuleTest/data/Settings.psd1 | 0 .../formats/CultureInfo.Format.ps1xml | 0 .../formats/Mygciview.Format.ps1xml | 0 .../PSModuleTest/modules/OtherPSModule.psm1 | 0 .../PSModuleTest/scripts/loader.ps1 | 0 .../types/DirectoryInfo.Types.ps1xml | 0 .../PSModuleTest/types/FileInfo.Types.ps1xml | 0 14 files changed, 14 insertions(+), 13 deletions(-) rename tests/outputs/{modules => module}/PSModuleTest/PSModuleTest.psd1 (100%) rename tests/outputs/{modules => module}/PSModuleTest/PSModuleTest.psm1 (100%) rename tests/outputs/{modules => module}/PSModuleTest/assemblies/LsonLib.dll (100%) rename tests/outputs/{modules => module}/PSModuleTest/data/Config.psd1 (100%) rename tests/outputs/{modules => module}/PSModuleTest/data/Settings.psd1 (100%) rename tests/outputs/{modules => module}/PSModuleTest/formats/CultureInfo.Format.ps1xml (100%) rename tests/outputs/{modules => module}/PSModuleTest/formats/Mygciview.Format.ps1xml (100%) rename tests/outputs/{modules => module}/PSModuleTest/modules/OtherPSModule.psm1 (100%) rename tests/outputs/{modules => module}/PSModuleTest/scripts/loader.ps1 (100%) rename tests/outputs/{modules => module}/PSModuleTest/types/DirectoryInfo.Types.ps1xml (100%) rename tests/outputs/{modules => module}/PSModuleTest/types/FileInfo.Types.ps1xml (100%) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 08cba2f..afa6647 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -35,7 +35,6 @@ jobs: Verbose: true Debug: true Name: PSModuleTest - ModulePath: modules - WorkingDirectory: tests/outputs + WorkingDirectory: tests APIKey: ${{ secrets.APIKEY }} WhatIf: true diff --git a/action.yml b/action.yml index bf19eb3..7291df2 100644 --- a/action.yml +++ b/action.yml @@ -12,7 +12,7 @@ inputs: ModulePath: description: Path to the module to publish. required: false - default: outputs/modules + default: outputs/module APIKey: description: PowerShell Gallery API Key. required: true @@ -27,7 +27,7 @@ inputs: ConfigurationFile: description: The path to the configuration file. Settings in the configuration file take precedence over the action inputs. required: false - default: .github\auto-release.yml + default: .github/auto-release.yml DatePrereleaseFormat: description: If specified, uses a date based prerelease scheme. The format should be a valid .NET format string like 'yyyyMMddHHmm'. required: false @@ -109,4 +109,4 @@ runs: WorkingDirectory: ${{ inputs.WorkingDirectory }} Script: | # Publish-PSModule - ${{ github.action_path }}\scripts\main.ps1 + ${{ github.action_path }}/scripts/main.ps1 diff --git a/scripts/main.ps1 b/scripts/main.ps1 index e360ef2..176ed4c 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -10,22 +10,24 @@ LogGroup "Loading helper scripts from [$path]" { } LogGroup 'Loading inputs' { - Write-Verbose "Name: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name]" - Write-Verbose "GITHUB_REPOSITORY: [$env:GITHUB_REPOSITORY]" - Write-Verbose "GITHUB_WORKSPACE: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory]" - $name = if ([string]::IsNullOrEmpty($env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name)) { $env:GITHUB_REPOSITORY_NAME } else { $env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name } - Write-Verbose "Module name: [$name]" - Write-Verbose "Module path: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath]" - Write-Verbose "Doc path: [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_DocsPath]" - $modulePath = Resolve-Path -Path "$env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory/$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath/$name" | Select-Object -ExpandProperty Path Write-Verbose "Resolved path: [$modulePath]" + + [pscustomobject]@{ + Name = $name + WorkingDirectory = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory + ModulePath = $modulePath + DocsPath = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_DocsPath + APIKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey + GITHUB_REPOSITORY = $env:GITHUB_REPOSITORY + } | Format-List + } $params = @{ diff --git a/tests/outputs/modules/PSModuleTest/PSModuleTest.psd1 b/tests/outputs/module/PSModuleTest/PSModuleTest.psd1 similarity index 100% rename from tests/outputs/modules/PSModuleTest/PSModuleTest.psd1 rename to tests/outputs/module/PSModuleTest/PSModuleTest.psd1 diff --git a/tests/outputs/modules/PSModuleTest/PSModuleTest.psm1 b/tests/outputs/module/PSModuleTest/PSModuleTest.psm1 similarity index 100% rename from tests/outputs/modules/PSModuleTest/PSModuleTest.psm1 rename to tests/outputs/module/PSModuleTest/PSModuleTest.psm1 diff --git a/tests/outputs/modules/PSModuleTest/assemblies/LsonLib.dll b/tests/outputs/module/PSModuleTest/assemblies/LsonLib.dll similarity index 100% rename from tests/outputs/modules/PSModuleTest/assemblies/LsonLib.dll rename to tests/outputs/module/PSModuleTest/assemblies/LsonLib.dll diff --git a/tests/outputs/modules/PSModuleTest/data/Config.psd1 b/tests/outputs/module/PSModuleTest/data/Config.psd1 similarity index 100% rename from tests/outputs/modules/PSModuleTest/data/Config.psd1 rename to tests/outputs/module/PSModuleTest/data/Config.psd1 diff --git a/tests/outputs/modules/PSModuleTest/data/Settings.psd1 b/tests/outputs/module/PSModuleTest/data/Settings.psd1 similarity index 100% rename from tests/outputs/modules/PSModuleTest/data/Settings.psd1 rename to tests/outputs/module/PSModuleTest/data/Settings.psd1 diff --git a/tests/outputs/modules/PSModuleTest/formats/CultureInfo.Format.ps1xml b/tests/outputs/module/PSModuleTest/formats/CultureInfo.Format.ps1xml similarity index 100% rename from tests/outputs/modules/PSModuleTest/formats/CultureInfo.Format.ps1xml rename to tests/outputs/module/PSModuleTest/formats/CultureInfo.Format.ps1xml diff --git a/tests/outputs/modules/PSModuleTest/formats/Mygciview.Format.ps1xml b/tests/outputs/module/PSModuleTest/formats/Mygciview.Format.ps1xml similarity index 100% rename from tests/outputs/modules/PSModuleTest/formats/Mygciview.Format.ps1xml rename to tests/outputs/module/PSModuleTest/formats/Mygciview.Format.ps1xml diff --git a/tests/outputs/modules/PSModuleTest/modules/OtherPSModule.psm1 b/tests/outputs/module/PSModuleTest/modules/OtherPSModule.psm1 similarity index 100% rename from tests/outputs/modules/PSModuleTest/modules/OtherPSModule.psm1 rename to tests/outputs/module/PSModuleTest/modules/OtherPSModule.psm1 diff --git a/tests/outputs/modules/PSModuleTest/scripts/loader.ps1 b/tests/outputs/module/PSModuleTest/scripts/loader.ps1 similarity index 100% rename from tests/outputs/modules/PSModuleTest/scripts/loader.ps1 rename to tests/outputs/module/PSModuleTest/scripts/loader.ps1 diff --git a/tests/outputs/modules/PSModuleTest/types/DirectoryInfo.Types.ps1xml b/tests/outputs/module/PSModuleTest/types/DirectoryInfo.Types.ps1xml similarity index 100% rename from tests/outputs/modules/PSModuleTest/types/DirectoryInfo.Types.ps1xml rename to tests/outputs/module/PSModuleTest/types/DirectoryInfo.Types.ps1xml diff --git a/tests/outputs/modules/PSModuleTest/types/FileInfo.Types.ps1xml b/tests/outputs/module/PSModuleTest/types/FileInfo.Types.ps1xml similarity index 100% rename from tests/outputs/modules/PSModuleTest/types/FileInfo.Types.ps1xml rename to tests/outputs/module/PSModuleTest/types/FileInfo.Types.ps1xml From 9cc6dd1632e5eae5e8f096cc493b45075d5d4163 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 00:56:35 +0100 Subject: [PATCH 05/30] =?UTF-8?q?=F0=9F=A9=B9=20[Enhancement]:=20Add=20det?= =?UTF-8?q?ailed=20logging=20of=20input=20parameters=20for=20module=20publ?= =?UTF-8?q?ishing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 176ed4c..c24dddf 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -10,6 +10,17 @@ LogGroup "Loading helper scripts from [$path]" { } LogGroup 'Loading inputs' { + + [pscustomobject]@{ + Name = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name + WorkingDirectory = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory + ModulePath = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath + DocsPath = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_DocsPath + APIKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey + GITHUB_REPOSITORY = $env:GITHUB_REPOSITORY + } | Format-List + + $name = if ([string]::IsNullOrEmpty($env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name)) { $env:GITHUB_REPOSITORY_NAME } else { From 73579d75b6cf4fd129166c14739de4b3411e8826 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 01:00:05 +0100 Subject: [PATCH 06/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Update=20WorkingD?= =?UTF-8?q?irectory=20input=20to=20use=20GitHub=20workspace=20path=20for?= =?UTF-8?q?=20module=20publishing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 7291df2..ddf8b59 100644 --- a/action.yml +++ b/action.yml @@ -100,7 +100,7 @@ runs: PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels: ${{ inputs.PatchLabels }} PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }} PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }} - PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory: ${{ inputs.WorkingDirectory }} + PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory: ${{ github.workspace }}/${{ inputs.WorkingDirectory }} with: Debug: ${{ inputs.Debug }} Prerelease: ${{ inputs.Prerelease }} From 3bc26e49757cf3cfd8f6f881c984fdbf48086ff9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 01:00:39 +0100 Subject: [PATCH 07/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Update=20WorkingD?= =?UTF-8?q?irectory=20input=20to=20use=20GitHub=20workspace=20path=20for?= =?UTF-8?q?=20improved=20module=20publishing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ddf8b59..13f48b5 100644 --- a/action.yml +++ b/action.yml @@ -106,7 +106,7 @@ runs: Prerelease: ${{ inputs.Prerelease }} Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} - WorkingDirectory: ${{ inputs.WorkingDirectory }} + WorkingDirectory: ${{ github.workspace }}/${{ inputs.WorkingDirectory }} Script: | # Publish-PSModule ${{ github.action_path }}/scripts/main.ps1 From 123328b5bace417ac962e43f3b154be4edba8137 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 01:11:43 +0100 Subject: [PATCH 08/30] =?UTF-8?q?=F0=9F=A9=B9=20[Enhancement]:=20Refactor?= =?UTF-8?q?=20Resolve-PSModuleDependency=20to=20support=20Install-PSResour?= =?UTF-8?q?ce=20with=20NuGet=20version=20ranges=20and=20improve=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../helpers/Resolve-PSModuleDependency.ps1 | 112 ++++++++++++++---- 1 file changed, 87 insertions(+), 25 deletions(-) diff --git a/scripts/helpers/Resolve-PSModuleDependency.ps1 b/scripts/helpers/Resolve-PSModuleDependency.ps1 index d82f7e0..3dfe964 100644 --- a/scripts/helpers/Resolve-PSModuleDependency.ps1 +++ b/scripts/helpers/Resolve-PSModuleDependency.ps1 @@ -1,15 +1,17 @@ function Resolve-PSModuleDependency { <# .SYNOPSIS - Resolve dependencies for a module based on the manifest file. + Resolves module dependencies from a manifest file using Install-PSResource. .DESCRIPTION - Resolve dependencies for a module based on the manifest file, following PSModuleInfo structure + Reads a module manifest (PSD1) and for each required module converts the old + Install-Module parameters (MinimumVersion, MaximumVersion, RequiredVersion) + into a single NuGet version range string for Install-PSResource's –Version parameter. + (Note: If RequiredVersion is set, that value takes precedence.) .EXAMPLE - Resolve-PSModuleDependency -Path 'C:\MyModule\MyModule.psd1' - - Installs all modules defined in the manifest file, following PSModuleInfo structure. + Resolve-PSModuleDependency -ManifestFilePath 'C:\MyModule\MyModule.psd1' + Installs all modules defined in the manifest file, following PSModuleInfo structure. .NOTES Should later be adapted to support both pre-reqs, and dependencies. @@ -20,48 +22,108 @@ 'PSAvoidUsingWriteHost', '', Scope = 'Function', Justification = 'Want to just write to the console, not the pipeline.' )] - [Alias('Resolve-PSModuleDependencies')] [CmdletBinding()] - #Requires -Modules @{ ModuleName = 'Retry'; ModuleVersion = '0.1.3' } param( # The path to the manifest file. [Parameter(Mandatory)] [string] $ManifestFilePath ) - Write-Host 'Resolving dependencies' + # Helper: Convert legacy version parameters into a NuGet version range string. + function Convert-VersionSpec { + param( + [string]$MinimumVersion, + [string]$MaximumVersion, + [string]$RequiredVersion + ) + if ($RequiredVersion) { + # Use exact match in bracket notation. + return "[$RequiredVersion]" + } elseif ($MinimumVersion -and $MaximumVersion) { + # Both bounds provided; both are inclusive. + return "[$MinimumVersion,$MaximumVersion]" + } elseif ($MinimumVersion) { + # Only a minimum is provided. Use a minimum-inclusive range. + return "[$MinimumVersion, ]" + } elseif ($MaximumVersion) { + # Only a maximum is provided; lower bound open. + return "(, $MaximumVersion]" + } else { + return $null + } + } + Write-Host 'Resolving dependencies' $manifest = Import-PowerShellDataFile -Path $ManifestFilePath - Write-Host "Reading [$ManifestFilePath]" - Write-Host "Found [$($manifest.RequiredModules.Count)] modules to install" + Write-Host " - Reading [$ManifestFilePath]" + Write-Host " - Found [$($manifest.RequiredModules.Count)] module(s) to install" foreach ($requiredModule in $manifest.RequiredModules) { - $installParams = @{} + # Build parameters for Install-PSResource (new version spec). + $psResourceParams = @{ + TrustRepository = $true + } + # Build parameters for Import-Module (legacy version spec). + $importParams = @{ + Force = $true + Verbose = $false + } if ($requiredModule -is [string]) { - $installParams.Name = $requiredModule + $psResourceParams.Name = $requiredModule + $importParams.Name = $requiredModule } else { - $installParams.Name = $requiredModule.ModuleName - $installParams.MinimumVersion = $requiredModule.ModuleVersion - $installParams.RequiredVersion = $requiredModule.RequiredVersion - $installParams.MaximumVersion = $requiredModule.MaximumVersion + $psResourceParams.Name = $requiredModule.ModuleName + $importParams.Name = $requiredModule.ModuleName + + # Convert legacy version info for Install-PSResource. + $versionSpec = Convert-VersionSpec ` + -MinimumVersion $requiredModule.ModuleVersion ` + -MaximumVersion $requiredModule.MaximumVersion ` + -RequiredVersion $requiredModule.RequiredVersion + + if ($versionSpec) { + $psResourceParams.Version = $versionSpec + } + + # For Import-Module, keep the original version parameters. + if ($requiredModule.ModuleVersion) { + $importParams.MinimumVersion = $requiredModule.ModuleVersion + } + if ($requiredModule.RequiredVersion) { + $importParams.RequiredVersion = $requiredModule.RequiredVersion + } + if ($requiredModule.MaximumVersion) { + $importParams.MaximumVersion = $requiredModule.MaximumVersion + } } - $installParams.Force = $true - $installParams.Verbose = $false - Write-Host "[$($installParams.Name)] - Installing module" + Write-Host " - [$($psResourceParams.Name)] - Installing module with Install-PSResource using version spec: $($psResourceParams.Version)" $VerbosePreferenceOriginal = $VerbosePreference $VerbosePreference = 'SilentlyContinue' - Retry -Count 5 -Delay 10 { - Install-Module @installParams -AllowPrerelease:$false + $retryCount = 5 + $retryDelay = 10 + for ($i = 0; $i -lt $retryCount; $i++) { + try { + Install-PSResource @psResourceParams + break + } catch { + Write-Warning "Installation of $($psResourceParams.Name) failed with error: $_" + if ($i -eq $retryCount - 1) { + throw + } + Write-Warning "Retrying in $retryDelay seconds..." + Start-Sleep -Seconds $retryDelay + } } $VerbosePreference = $VerbosePreferenceOriginal - Write-Host "[$($installParams.Name)] - Importing module" + + Write-Host " - [$($importParams.Name)] - Importing module with legacy version spec" $VerbosePreferenceOriginal = $VerbosePreference $VerbosePreference = 'SilentlyContinue' - Import-Module @installParams + Import-Module @importParams $VerbosePreference = $VerbosePreferenceOriginal - Write-Host "[$($installParams.Name)] - Done" + Write-Host " - [$($importParams.Name)] - Done" } - Write-Host 'Resolving dependencies - Done' + Write-Host ' - Resolving dependencies - Done' } From 3a67413fd4354f3e83f989cb03e118cb1e876da4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 01:19:35 +0100 Subject: [PATCH 09/30] =?UTF-8?q?=F0=9F=A9=B9=20[Refactor]:=20Move=20Conve?= =?UTF-8?q?rt-VersionSpec=20function=20to=20a=20separate=20script=20for=20?= =?UTF-8?q?improved=20modularity=20and=20maintainability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Convert-VersionSpec.ps1 | 98 +++++++++++++++++++ .../helpers/Resolve-PSModuleDependency.ps1 | 24 ----- 2 files changed, 98 insertions(+), 24 deletions(-) create mode 100644 scripts/helpers/Convert-VersionSpec.ps1 diff --git a/scripts/helpers/Convert-VersionSpec.ps1 b/scripts/helpers/Convert-VersionSpec.ps1 new file mode 100644 index 0000000..14357a8 --- /dev/null +++ b/scripts/helpers/Convert-VersionSpec.ps1 @@ -0,0 +1,98 @@ +function Convert-VersionSpec { + <# + .SYNOPSIS + Converts legacy version parameters into a NuGet version range string. + + .DESCRIPTION + This function takes minimum, maximum, or required version parameters + and constructs a NuGet-compatible version range string. + + - If `RequiredVersion` is specified, the output is an exact match range. + - If both `MinimumVersion` and `MaximumVersion` are provided, + an inclusive range is returned. + - If only `MinimumVersion` is provided, it returns a minimum-inclusive range. + - If only `MaximumVersion` is provided, it returns an upper-bound range. + - If no parameters are provided, `$null` is returned. + + .EXAMPLE + Convert-VersionSpec -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" + + Output: + ```powershell + [1.0.0,2.0.0] + ``` + + Returns an inclusive version range from 1.0.0 to 2.0.0. + + .EXAMPLE + Convert-VersionSpec -RequiredVersion "1.5.0" + + Output: + ```powershell + [1.5.0] + ``` + + Returns an exact match for version 1.5.0. + + .EXAMPLE + Convert-VersionSpec -MinimumVersion "1.0.0" + + Output: + ```powershell + [1.0.0, ] + ``` + + Returns a minimum-inclusive version range starting at 1.0.0. + + .EXAMPLE + Convert-VersionSpec -MaximumVersion "2.0.0" + + Output: + ```powershell + (, 2.0.0] + ``` + + Returns an upper-bound range up to version 2.0.0. + + .OUTPUTS + string + + .NOTES + The NuGet version range string based on the provided parameters. + The returned string follows NuGet versioning syntax. + + .LINK + https://psmodule.io/Convert/Functions/Convert-VersionSpec + #> + [OutputType([string])] + [CmdletBinding()] + param( + # The minimum version for the range. If specified alone, the range is open-ended upwards. + [Parameter()] + [string] $MinimumVersion, + + # The maximum version for the range. If specified alone, the range is open-ended downwards. + [Parameter()] + [string] $MaximumVersion, + + # Specifies an exact required version. If set, an exact version range is returned. + [Parameter()] + [string] $RequiredVersion + ) + + if ($RequiredVersion) { + # Use exact match in bracket notation. + return "[$RequiredVersion]" + } elseif ($MinimumVersion -and $MaximumVersion) { + # Both bounds provided; both are inclusive. + return "[$MinimumVersion,$MaximumVersion]" + } elseif ($MinimumVersion) { + # Only a minimum is provided. Use a minimum-inclusive range. + return "[$MinimumVersion, ]" + } elseif ($MaximumVersion) { + # Only a maximum is provided; lower bound open. + return "(, $MaximumVersion]" + } else { + return $null + } +} diff --git a/scripts/helpers/Resolve-PSModuleDependency.ps1 b/scripts/helpers/Resolve-PSModuleDependency.ps1 index 3dfe964..edb3c29 100644 --- a/scripts/helpers/Resolve-PSModuleDependency.ps1 +++ b/scripts/helpers/Resolve-PSModuleDependency.ps1 @@ -29,30 +29,6 @@ [string] $ManifestFilePath ) - # Helper: Convert legacy version parameters into a NuGet version range string. - function Convert-VersionSpec { - param( - [string]$MinimumVersion, - [string]$MaximumVersion, - [string]$RequiredVersion - ) - if ($RequiredVersion) { - # Use exact match in bracket notation. - return "[$RequiredVersion]" - } elseif ($MinimumVersion -and $MaximumVersion) { - # Both bounds provided; both are inclusive. - return "[$MinimumVersion,$MaximumVersion]" - } elseif ($MinimumVersion) { - # Only a minimum is provided. Use a minimum-inclusive range. - return "[$MinimumVersion, ]" - } elseif ($MaximumVersion) { - # Only a maximum is provided; lower bound open. - return "(, $MaximumVersion]" - } else { - return $null - } - } - Write-Host 'Resolving dependencies' $manifest = Import-PowerShellDataFile -Path $ManifestFilePath Write-Host " - Reading [$ManifestFilePath]" From 43de48d6b93cbd1ffb015bd9eb2f32abec64df04 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 20:21:54 +0100 Subject: [PATCH 10/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Remove=20GitHub?= =?UTF-8?q?=20workspace=20path=20from=20WorkingDirectory=20input=20for=20c?= =?UTF-8?q?onsistency=20in=20module=20publishing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 4 ++-- scripts/main.ps1 | 25 ++++--------------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/action.yml b/action.yml index 13f48b5..7291df2 100644 --- a/action.yml +++ b/action.yml @@ -100,13 +100,13 @@ runs: PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels: ${{ inputs.PatchLabels }} PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }} PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }} - PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory: ${{ github.workspace }}/${{ inputs.WorkingDirectory }} + PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory: ${{ inputs.WorkingDirectory }} with: Debug: ${{ inputs.Debug }} Prerelease: ${{ inputs.Prerelease }} Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} - WorkingDirectory: ${{ github.workspace }}/${{ inputs.WorkingDirectory }} + WorkingDirectory: ${{ inputs.WorkingDirectory }} Script: | # Publish-PSModule ${{ github.action_path }}/scripts/main.ps1 diff --git a/scripts/main.ps1 b/scripts/main.ps1 index c24dddf..d92cea4 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -10,33 +10,16 @@ LogGroup "Loading helper scripts from [$path]" { } LogGroup 'Loading inputs' { - - [pscustomobject]@{ - Name = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name - WorkingDirectory = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory - ModulePath = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath - DocsPath = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_DocsPath - APIKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey - GITHUB_REPOSITORY = $env:GITHUB_REPOSITORY - } | Format-List - - $name = if ([string]::IsNullOrEmpty($env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name)) { $env:GITHUB_REPOSITORY_NAME } else { $env:PSMODULE_PUBLISH_PSMODULE_INPUT_Name } - $modulePath = Resolve-Path -Path "$env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory/$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath/$name" | - Select-Object -ExpandProperty Path - Write-Verbose "Resolved path: [$modulePath]" - + $modulePath = Resolve-Path -Path "$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ModulePath/$name" | Select-Object -ExpandProperty Path [pscustomobject]@{ - Name = $name - WorkingDirectory = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory - ModulePath = $modulePath - DocsPath = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_DocsPath - APIKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey - GITHUB_REPOSITORY = $env:GITHUB_REPOSITORY + Name = $name + ModulePath = $modulePath + APIKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey } | Format-List } From 21decfc48b3fd4aa5cdfc3b6a95790d55521df4d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 28 Feb 2025 22:35:11 +0100 Subject: [PATCH 11/30] Fix PSModule/Process-PSModule/issues/82 --- scripts/helpers/Publish-PSModule.ps1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index cb1bbe6..5717dc0 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -346,11 +346,10 @@ LogGroup 'Publish-ToPSGallery' { if ($createPrerelease) { $publishPSVersion = "$($newVersion.Major).$($newVersion.Minor).$($newVersion.Patch)-$($newVersion.Prerelease)" - $psGalleryReleaseLink = "https://www.powershellgallery.com/packages/$Name/$publishPSVersion" } else { - $publishPSVersion = $newVersion.ToString() - $psGalleryReleaseLink = "https://www.powershellgallery.com/packages/$Name/$($newVersion.ToString())" + $publishPSVersion = "$($newVersion.Major).$($newVersion.Minor).$($newVersion.Patch)" } + $psGalleryReleaseLink = "https://www.powershellgallery.com/packages/$Name/$publishPSVersion" Write-Output "Publish module to PowerShell Gallery using [$APIKey]" if ($whatIf) { Write-Output "Publish-PSResource -Path $ModulePath -Repository PSGallery -ApiKey $APIKey" From 91ba6bd8ca73f1368a6c04d3234a691f01c951d3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 2 Mar 2025 11:17:36 +0100 Subject: [PATCH 12/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Convert=20output?= =?UTF-8?q?=20of=20Format-List=20to=20string=20for=20improved=20logging=20?= =?UTF-8?q?consistency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 14 +++++++------- scripts/main.ps1 | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 5717dc0..a471a31 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -91,13 +91,13 @@ LogGroup 'Event information - JSON' { $githubEventJson = Get-Content $env:GITHUB_EVENT_PATH - $githubEventJson | Format-List + $githubEventJson | Format-List | Out-String } LogGroup 'Event information - Object' { $githubEvent = $githubEventJson | ConvertFrom-Json $pull_request = $githubEvent.pull_request - $githubEvent | Format-List + $githubEvent | Format-List | Out-String } LogGroup 'Event information - Details' { @@ -127,13 +127,13 @@ } LogGroup 'Pull request - details' { - $pull_request | Format-List + $pull_request | Format-List | Out-String } LogGroup 'Pull request - Labels' { $labels = @() $labels += $pull_request.labels.name - $labels | Format-List + $labels | Format-List | Out-String } LogGroup 'Calculate release type' { @@ -170,10 +170,10 @@ Write-Error 'Failed to list all releases for the repo.' exit $LASTEXITCODE } - $releases | Select-Object -Property name, isPrerelease, isLatest, publishedAt | Format-Table + $releases | Select-Object -Property name, isPrerelease, isLatest, publishedAt | Format-Table | Out-String $latestRelease = $releases | Where-Object { $_.isLatest -eq $true } - $latestRelease | Format-List + $latestRelease | Format-List | Out-String $ghReleaseVersionString = $latestRelease.tagName if ($ghReleaseVersionString | IsNotNullOrEmpty) { $ghReleaseVersion = New-PSSemVer -Version $ghReleaseVersionString @@ -414,7 +414,7 @@ LogGroup 'List prereleases using the same name' { $prereleasesToCleanup = $releases | Where-Object { $_.tagName -like "*$prereleaseName*" } - $prereleasesToCleanup | Select-Object -Property name, publishedAt, isPrerelease, isLatest | Format-Table + $prereleasesToCleanup | Select-Object -Property name, publishedAt, isPrerelease, isLatest | Format-Table | Out-String } if ((($closedPullRequest -or $createRelease) -and $autoCleanup) -or $whatIf) { diff --git a/scripts/main.ps1 b/scripts/main.ps1 index d92cea4..b946e9c 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -20,7 +20,7 @@ LogGroup 'Loading inputs' { Name = $name ModulePath = $modulePath APIKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey - } | Format-List + } | Format-List | Out-String } From a3d6774f966e4e71a1db7b674b51480d880ce971 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 5 Mar 2025 20:18:26 +0100 Subject: [PATCH 13/30] =?UTF-8?q?=F0=9F=A9=B9=20[Enhancement]:=20Add=20Ins?= =?UTF-8?q?tall-PSModuleHelpers=20step=20and=20remove=20obsolete=20Convert?= =?UTF-8?q?-VersionSpec=20and=20Resolve-PSModuleDependency=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 3 + scripts/helpers/Convert-VersionSpec.ps1 | 98 ---------------- .../helpers/Resolve-PSModuleDependency.ps1 | 105 ------------------ 3 files changed, 3 insertions(+), 203 deletions(-) delete mode 100644 scripts/helpers/Convert-VersionSpec.ps1 delete mode 100644 scripts/helpers/Resolve-PSModuleDependency.ps1 diff --git a/action.yml b/action.yml index 7291df2..6d301a1 100644 --- a/action.yml +++ b/action.yml @@ -83,6 +83,9 @@ inputs: runs: using: composite steps: + - name: Install-PSModuleHelpers + uses: PSModule/Install-PSModuleHelpers@v1 + - name: Run Publish-PSModule uses: PSModule/GitHub-Script@v1 env: diff --git a/scripts/helpers/Convert-VersionSpec.ps1 b/scripts/helpers/Convert-VersionSpec.ps1 deleted file mode 100644 index 14357a8..0000000 --- a/scripts/helpers/Convert-VersionSpec.ps1 +++ /dev/null @@ -1,98 +0,0 @@ -function Convert-VersionSpec { - <# - .SYNOPSIS - Converts legacy version parameters into a NuGet version range string. - - .DESCRIPTION - This function takes minimum, maximum, or required version parameters - and constructs a NuGet-compatible version range string. - - - If `RequiredVersion` is specified, the output is an exact match range. - - If both `MinimumVersion` and `MaximumVersion` are provided, - an inclusive range is returned. - - If only `MinimumVersion` is provided, it returns a minimum-inclusive range. - - If only `MaximumVersion` is provided, it returns an upper-bound range. - - If no parameters are provided, `$null` is returned. - - .EXAMPLE - Convert-VersionSpec -MinimumVersion "1.0.0" -MaximumVersion "2.0.0" - - Output: - ```powershell - [1.0.0,2.0.0] - ``` - - Returns an inclusive version range from 1.0.0 to 2.0.0. - - .EXAMPLE - Convert-VersionSpec -RequiredVersion "1.5.0" - - Output: - ```powershell - [1.5.0] - ``` - - Returns an exact match for version 1.5.0. - - .EXAMPLE - Convert-VersionSpec -MinimumVersion "1.0.0" - - Output: - ```powershell - [1.0.0, ] - ``` - - Returns a minimum-inclusive version range starting at 1.0.0. - - .EXAMPLE - Convert-VersionSpec -MaximumVersion "2.0.0" - - Output: - ```powershell - (, 2.0.0] - ``` - - Returns an upper-bound range up to version 2.0.0. - - .OUTPUTS - string - - .NOTES - The NuGet version range string based on the provided parameters. - The returned string follows NuGet versioning syntax. - - .LINK - https://psmodule.io/Convert/Functions/Convert-VersionSpec - #> - [OutputType([string])] - [CmdletBinding()] - param( - # The minimum version for the range. If specified alone, the range is open-ended upwards. - [Parameter()] - [string] $MinimumVersion, - - # The maximum version for the range. If specified alone, the range is open-ended downwards. - [Parameter()] - [string] $MaximumVersion, - - # Specifies an exact required version. If set, an exact version range is returned. - [Parameter()] - [string] $RequiredVersion - ) - - if ($RequiredVersion) { - # Use exact match in bracket notation. - return "[$RequiredVersion]" - } elseif ($MinimumVersion -and $MaximumVersion) { - # Both bounds provided; both are inclusive. - return "[$MinimumVersion,$MaximumVersion]" - } elseif ($MinimumVersion) { - # Only a minimum is provided. Use a minimum-inclusive range. - return "[$MinimumVersion, ]" - } elseif ($MaximumVersion) { - # Only a maximum is provided; lower bound open. - return "(, $MaximumVersion]" - } else { - return $null - } -} diff --git a/scripts/helpers/Resolve-PSModuleDependency.ps1 b/scripts/helpers/Resolve-PSModuleDependency.ps1 deleted file mode 100644 index edb3c29..0000000 --- a/scripts/helpers/Resolve-PSModuleDependency.ps1 +++ /dev/null @@ -1,105 +0,0 @@ -function Resolve-PSModuleDependency { - <# - .SYNOPSIS - Resolves module dependencies from a manifest file using Install-PSResource. - - .DESCRIPTION - Reads a module manifest (PSD1) and for each required module converts the old - Install-Module parameters (MinimumVersion, MaximumVersion, RequiredVersion) - into a single NuGet version range string for Install-PSResource's –Version parameter. - (Note: If RequiredVersion is set, that value takes precedence.) - - .EXAMPLE - Resolve-PSModuleDependency -ManifestFilePath 'C:\MyModule\MyModule.psd1' - Installs all modules defined in the manifest file, following PSModuleInfo structure. - - .NOTES - Should later be adapted to support both pre-reqs, and dependencies. - Should later be adapted to take 4 parameters sets: specific version ("requiredVersion" | "GUID"), latest version ModuleVersion, - and latest version within a range MinimumVersion - MaximumVersion. - #> - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSAvoidUsingWriteHost', '', Scope = 'Function', - Justification = 'Want to just write to the console, not the pipeline.' - )] - [CmdletBinding()] - param( - # The path to the manifest file. - [Parameter(Mandatory)] - [string] $ManifestFilePath - ) - - Write-Host 'Resolving dependencies' - $manifest = Import-PowerShellDataFile -Path $ManifestFilePath - Write-Host " - Reading [$ManifestFilePath]" - Write-Host " - Found [$($manifest.RequiredModules.Count)] module(s) to install" - - foreach ($requiredModule in $manifest.RequiredModules) { - # Build parameters for Install-PSResource (new version spec). - $psResourceParams = @{ - TrustRepository = $true - } - # Build parameters for Import-Module (legacy version spec). - $importParams = @{ - Force = $true - Verbose = $false - } - - if ($requiredModule -is [string]) { - $psResourceParams.Name = $requiredModule - $importParams.Name = $requiredModule - } else { - $psResourceParams.Name = $requiredModule.ModuleName - $importParams.Name = $requiredModule.ModuleName - - # Convert legacy version info for Install-PSResource. - $versionSpec = Convert-VersionSpec ` - -MinimumVersion $requiredModule.ModuleVersion ` - -MaximumVersion $requiredModule.MaximumVersion ` - -RequiredVersion $requiredModule.RequiredVersion - - if ($versionSpec) { - $psResourceParams.Version = $versionSpec - } - - # For Import-Module, keep the original version parameters. - if ($requiredModule.ModuleVersion) { - $importParams.MinimumVersion = $requiredModule.ModuleVersion - } - if ($requiredModule.RequiredVersion) { - $importParams.RequiredVersion = $requiredModule.RequiredVersion - } - if ($requiredModule.MaximumVersion) { - $importParams.MaximumVersion = $requiredModule.MaximumVersion - } - } - - Write-Host " - [$($psResourceParams.Name)] - Installing module with Install-PSResource using version spec: $($psResourceParams.Version)" - $VerbosePreferenceOriginal = $VerbosePreference - $VerbosePreference = 'SilentlyContinue' - $retryCount = 5 - $retryDelay = 10 - for ($i = 0; $i -lt $retryCount; $i++) { - try { - Install-PSResource @psResourceParams - break - } catch { - Write-Warning "Installation of $($psResourceParams.Name) failed with error: $_" - if ($i -eq $retryCount - 1) { - throw - } - Write-Warning "Retrying in $retryDelay seconds..." - Start-Sleep -Seconds $retryDelay - } - } - $VerbosePreference = $VerbosePreferenceOriginal - - Write-Host " - [$($importParams.Name)] - Importing module with legacy version spec" - $VerbosePreferenceOriginal = $VerbosePreference - $VerbosePreference = 'SilentlyContinue' - Import-Module @importParams - $VerbosePreference = $VerbosePreferenceOriginal - Write-Host " - [$($importParams.Name)] - Done" - } - Write-Host ' - Resolving dependencies - Done' -} From 5b05980f20ec17eb0b563cea9f89b74321384fcc Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 6 Mar 2025 17:18:43 +0100 Subject: [PATCH 14/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Update=20WorkingD?= =?UTF-8?q?irectory=20default=20value=20to=20'.'=20for=20consistency=20in?= =?UTF-8?q?=20script=20execution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a54376..88e1c11 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ The action can be configured using the following settings: | `Verbose` | Enable verbose output. | `'false'` | `false` | | `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | | `false` | | `Prerelease` | Allow prerelease versions if available. | `'false'` | `false` | -| `WorkingDirectory` | The working directory where the script runs. | `'false'` | `${{ github.workspace }}` | +| `WorkingDirectory` | The working directory where the script runs. | `'false'` | `'.'` | ### Configuration file diff --git a/action.yml b/action.yml index 6d301a1..77727a1 100644 --- a/action.yml +++ b/action.yml @@ -78,7 +78,7 @@ inputs: WorkingDirectory: description: The working directory where the script will run from. required: false - default: ${{ github.workspace }} + default: '.' runs: using: composite From dff8f9e41c052c2785b336b302e74de21d6129e4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 8 Mar 2025 11:57:58 +0100 Subject: [PATCH 15/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Remove=20GITHUB?= =?UTF-8?q?=5FTOKEN=20environment=20variable=20from=20Auto-Release=20workf?= =?UTF-8?q?low=20for=20security=20improvement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Auto-Release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index ec157c9..680da5c 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -30,7 +30,5 @@ jobs: - name: Auto-Release uses: PSModule/Auto-Release@v1 - env: - GITHUB_TOKEN: ${{ github.token }} # Used for GitHub CLI authentication with: IncrementalPrerelease: false From efd9ed16d2b5021e49ed1a47bc14b5b8636265ed Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 10 Mar 2025 14:17:52 +0100 Subject: [PATCH 16/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Convert=20PSGalle?= =?UTF-8?q?ry=20version=20to=20string=20for=20improved=20output=20formatti?= =?UTF-8?q?ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index a471a31..8f73202 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -197,14 +197,13 @@ } -Catch { throw $_ } - $psGalleryVersion = New-PSSemVer -Version $latest.Version + $psGalleryVersion = New-PSSemVer -Version $latest.Version.ToString() } catch { Write-Warning 'Could not find module online. Using ''0.0.0'' as the version.' $psGalleryVersion = New-PSSemVer -Version '0.0.0' } Write-Output '-------------------------------------------------' Write-Output 'PSGallery version:' - Write-Output ($psGalleryVersion | Format-Table | Out-String) Write-Output $psGalleryVersion.ToString() Write-Output '-------------------------------------------------' } From aa9220c32cd8004ddc8514496a943e54ed689e40 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 21:52:40 +0100 Subject: [PATCH 17/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Initialize=20$lat?= =?UTF-8?q?est=20variable=20to=20null=20before=20fetching=20the=20latest?= =?UTF-8?q?=20version=20from=20PSGallery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 8f73202..35af23b 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -189,6 +189,7 @@ } LogGroup 'Get latest version - PSGallery' { + $latest = $null try { Retry -Count 5 -Delay 10 { Write-Output "Finding module [$Name] in the PowerShell Gallery." From 9d39b3a1616dd742ede8fa38e20479cfc95bbea4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 21:59:51 +0100 Subject: [PATCH 18/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Remove=20redundan?= =?UTF-8?q?t=20initialization=20of=20$latest=20variable=20in=20Publish-PSM?= =?UTF-8?q?odule=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 35af23b..8f73202 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -189,7 +189,6 @@ } LogGroup 'Get latest version - PSGallery' { - $latest = $null try { Retry -Count 5 -Delay 10 { Write-Output "Finding module [$Name] in the PowerShell Gallery." From f896bd274c4ff2700ba293fedd84eaddd215ddfd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 22:11:53 +0100 Subject: [PATCH 19/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Improve=20error?= =?UTF-8?q?=20handling=20when=20fetching=20the=20latest=20module=20version?= =?UTF-8?q?=20from=20PSGallery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 8f73202..0450eb7 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -189,16 +189,17 @@ } LogGroup 'Get latest version - PSGallery' { - try { - Retry -Count 5 -Delay 10 { - Write-Output "Finding module [$Name] in the PowerShell Gallery." - $latest = Find-PSResource -Name $Name -Repository PSGallery -Verbose:$false - Write-Output ($latest | Format-Table | Out-String) - } -Catch { - throw $_ - } + Retry -Count 5 -Delay 10 { + Write-Output "Finding module [$Name] in the PowerShell Gallery." + $latest = Find-PSResource -Name $Name -Repository PSGallery -Verbose:$false + Write-Output ($latest | Format-Table | Out-String) + } -Catch { + Write-Warning "Failed to find the module [$Name] in the PowerShell Gallery." + Write-Warning $_.Exception.Message + } + if ($latest) { $psGalleryVersion = New-PSSemVer -Version $latest.Version.ToString() - } catch { + } else { Write-Warning 'Could not find module online. Using ''0.0.0'' as the version.' $psGalleryVersion = New-PSSemVer -Version '0.0.0' } From 24aff89b8fe1101dfbfcbaf9a9532b7b21a76494 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 22:22:40 +0100 Subject: [PATCH 20/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Update=20output?= =?UTF-8?q?=20formatting=20for=20GitHub=20version=20and=20manifest=20versi?= =?UTF-8?q?on=20in=20Publish-PSModule=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 0450eb7..ef81c5f 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -183,7 +183,6 @@ } Write-Output '-------------------------------------------------' Write-Output 'GitHub version:' - Write-Output ($ghReleaseVersion | Format-Table | Out-String) Write-Output $ghReleaseVersion.ToString() Write-Output '-------------------------------------------------' } @@ -197,7 +196,7 @@ Write-Warning "Failed to find the module [$Name] in the PowerShell Gallery." Write-Warning $_.Exception.Message } - if ($latest) { + if ($null -ne $latest) { $psGalleryVersion = New-PSSemVer -Version $latest.Version.ToString() } else { Write-Warning 'Could not find module online. Using ''0.0.0'' as the version.' @@ -227,7 +226,6 @@ } Write-Output '-------------------------------------------------' Write-Output 'Manifest version:' - Write-Output ($manifestVersion | Format-Table | Out-String) Write-Output $manifestVersion.ToString() Write-Output '-------------------------------------------------' } From 3e9d57fac906a1feee1bac408da2bac8d37d721b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 22:27:22 +0100 Subject: [PATCH 21/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Correctly=20conve?= =?UTF-8?q?rt=20the=20latest=20version=20to=20string=20format=20in=20Publi?= =?UTF-8?q?sh-PSModule=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index ef81c5f..7fd5358 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -197,7 +197,7 @@ Write-Warning $_.Exception.Message } if ($null -ne $latest) { - $psGalleryVersion = New-PSSemVer -Version $latest.Version.ToString() + $psGalleryVersion = New-PSSemVer -Version ($latest.Version).ToString() } else { Write-Warning 'Could not find module online. Using ''0.0.0'' as the version.' $psGalleryVersion = New-PSSemVer -Version '0.0.0' From 48ab2090e089a2872d6c9cb472dd94d8656f1552 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 22:28:42 +0100 Subject: [PATCH 22/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Enhance=20null=20?= =?UTF-8?q?check=20for=20latest=20module=20version=20in=20Publish-PSModule?= =?UTF-8?q?=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 7fd5358..6859799 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -196,7 +196,7 @@ Write-Warning "Failed to find the module [$Name] in the PowerShell Gallery." Write-Warning $_.Exception.Message } - if ($null -ne $latest) { + if (-not [string]::IsNullOrEmpty($latest.Name)) { $psGalleryVersion = New-PSSemVer -Version ($latest.Version).ToString() } else { Write-Warning 'Could not find module online. Using ''0.0.0'' as the version.' From 6e305a8214321392e180ad39e35c0ac5f2d10bd3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 22:39:26 +0100 Subject: [PATCH 23/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Simplify=20versio?= =?UTF-8?q?n=20check=20for=20latest=20module=20in=20Publish-PSModule=20scr?= =?UTF-8?q?ipt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 6859799..d44e2cc 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -196,7 +196,7 @@ Write-Warning "Failed to find the module [$Name] in the PowerShell Gallery." Write-Warning $_.Exception.Message } - if (-not [string]::IsNullOrEmpty($latest.Name)) { + if ($latest.Version) { $psGalleryVersion = New-PSSemVer -Version ($latest.Version).ToString() } else { Write-Warning 'Could not find module online. Using ''0.0.0'' as the version.' From a0004a05a03ba7137d42c1f2f9f3aa95d8e3b0ab Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 22:45:46 +0100 Subject: [PATCH 24/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Refactor=20retry?= =?UTF-8?q?=20logic=20for=20fetching=20latest=20module=20version=20in=20Pu?= =?UTF-8?q?blish-PSModule=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index d44e2cc..a0095e1 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -11,7 +11,7 @@ #> [OutputType([void])] [CmdletBinding()] - #Requires -Modules Utilities, PowerShellGet, Microsoft.PowerShell.PSResourceGet, Retry, GitHub, PSSemVer + #Requires -Modules Utilities, PowerShellGet, Microsoft.PowerShell.PSResourceGet, GitHub, PSSemVer [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSReviewUnusedParameter', '', Scope = 'Function', Justification = 'LogGroup - Scoping affects the variables line of sight.' @@ -188,13 +188,22 @@ } LogGroup 'Get latest version - PSGallery' { - Retry -Count 5 -Delay 10 { - Write-Output "Finding module [$Name] in the PowerShell Gallery." - $latest = Find-PSResource -Name $Name -Repository PSGallery -Verbose:$false - Write-Output ($latest | Format-Table | Out-String) - } -Catch { - Write-Warning "Failed to find the module [$Name] in the PowerShell Gallery." - Write-Warning $_.Exception.Message + $count = 5 + $delay = 10 + for ($i = 1; $i -le $count; $i++) { + try { + Write-Output "Finding module [$Name] in the PowerShell Gallery." + $latest = Find-PSResource -Name $Name -Repository PSGallery -Verbose:$false + Write-Output ($latest | Format-Table | Out-String) + break + } catch { + if ($i -eq $count) { + Write-Warning "Failed to find the module [$Name] in the PowerShell Gallery." + Write-Warning $_.Exception.Message + throw $_ + } + Start-Sleep -Seconds $delay + } } if ($latest.Version) { $psGalleryVersion = New-PSSemVer -Version ($latest.Version).ToString() From 5086efe5e309204cf1295a9a2faeeaf7e6e6e5fe Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 22:48:57 +0100 Subject: [PATCH 25/30] [Fix]: Ensure proper string interpolation for output of latest module in Publish-PSModule script --- scripts/helpers/Publish-PSModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index a0095e1..a8f7da9 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -194,7 +194,7 @@ try { Write-Output "Finding module [$Name] in the PowerShell Gallery." $latest = Find-PSResource -Name $Name -Repository PSGallery -Verbose:$false - Write-Output ($latest | Format-Table | Out-String) + Write-Output "$($latest | Format-Table | Out-String)" break } catch { if ($i -eq $count) { From a59d8274ccec0c5252cd567069bfcfbb2d88520f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 13 Mar 2025 22:50:44 +0100 Subject: [PATCH 26/30] =?UTF-8?q?=F0=9F=A9=B9=20[Fix]:=20Remove=20unnecess?= =?UTF-8?q?ary=20throw=20statement=20in=20error=20handling=20for=20module?= =?UTF-8?q?=20search=20in=20Publish-PSModule=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/helpers/Publish-PSModule.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index a8f7da9..95522f4 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -200,7 +200,6 @@ if ($i -eq $count) { Write-Warning "Failed to find the module [$Name] in the PowerShell Gallery." Write-Warning $_.Exception.Message - throw $_ } Start-Sleep -Seconds $delay } From e2f081ead92f3f9650172fe1bc7504daeca992a9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 23 Mar 2025 16:14:12 +0100 Subject: [PATCH 27/30] [Refactor]: Remove ConfigurationFile input and update action script parameters in action.yml --- action.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 77727a1..cf435e4 100644 --- a/action.yml +++ b/action.yml @@ -24,10 +24,6 @@ inputs: description: Control wether to automatically handle patches. If disabled, the action will only create a patch release if the pull request has a 'patch' label. required: false default: 'true' - ConfigurationFile: - description: The path to the configuration file. Settings in the configuration file take precedence over the action inputs. - required: false - default: .github/auto-release.yml DatePrereleaseFormat: description: If specified, uses a date based prerelease scheme. The format should be a valid .NET format string like 'yyyyMMddHHmm'. required: false @@ -94,7 +90,6 @@ runs: PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey: ${{ inputs.APIKey }} PSMODULE_PUBLISH_PSMODULE_INPUT_AutoCleanup: ${{ inputs.AutoCleanup }} PSMODULE_PUBLISH_PSMODULE_INPUT_AutoPatching: ${{ inputs.AutoPatching }} - PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile: ${{ inputs.ConfigurationFile }} PSMODULE_PUBLISH_PSMODULE_INPUT_DatePrereleaseFormat: ${{ inputs.DatePrereleaseFormat }} PSMODULE_PUBLISH_PSMODULE_INPUT_IgnoreLabels: ${{ inputs.IgnoreLabels }} PSMODULE_PUBLISH_PSMODULE_INPUT_IncrementalPrerelease: ${{ inputs.IncrementalPrerelease }} @@ -105,11 +100,11 @@ runs: PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }} PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory: ${{ inputs.WorkingDirectory }} with: + Name: Publish-PSModule Debug: ${{ inputs.Debug }} Prerelease: ${{ inputs.Prerelease }} Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} WorkingDirectory: ${{ inputs.WorkingDirectory }} Script: | - # Publish-PSModule ${{ github.action_path }}/scripts/main.ps1 From e61617f13f7b326fb286c239afc6771db9bfa55a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 23 Mar 2025 16:22:55 +0100 Subject: [PATCH 28/30] Remove config file way of using Publish-PSModule (expecting only Process-PSModule usage) --- README.md | 17 +------ action.yml | 3 +- scripts/helpers/Publish-PSModule.ps1 | 75 +++++++++------------------- 3 files changed, 25 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 88e1c11..68c619f 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ prerelease with the branch name (in normalized form) as the prerelease name. By - `fix` The types of labels used for the types of prereleases can be configured using the `MajorLabels`, `MinorLabels` and `PatchLabels` -parameters/settings in the configuration file. See the [Usage](#usage) section for more information. +parameters/settings. See the [Usage](#usage) section for more information. When a pull request is merged into the default branch, the action will create a release based on the labels and clean up any previous prereleases that was created. @@ -50,7 +50,6 @@ The action can be configured using the following settings: | `APIKey` | PowerShell Gallery API Key. | `true` | | | `AutoCleanup`| Control wether to automatically cleanup prereleases. If disabled, the action will not remove any prereleases. | `false` | `true` | | `AutoPatching` | Control wether to automatically handle patches. If disabled, the action will only create a patch release if the pull request has a 'patch' label. | `false` | `true` | -| `ConfigurationFile` | The path to the configuration file. Settings in the configuration file take precedence over the action inputs. | `false` | `.github\auto-release.yml` | | `DatePrereleaseFormat` | The format to use for the prerelease number using [.NET DateTime format strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings). | `false` | `''` | | `IgnoreLabels` | A comma separated list of labels that do not trigger a release. | `false` | `NoRelease` | | `IncrementalPrerelease` | Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch. | `false` | `true` | @@ -67,20 +66,6 @@ The action can be configured using the following settings: | `Prerelease` | Allow prerelease versions if available. | `'false'` | `false` | | `WorkingDirectory` | The working directory where the script runs. | `'false'` | `'.'` | -### Configuration file - -The configuration file is a YAML file that can be used to configure the action. -By default, the configuration file is expected at `.github\auto-release.yml`, which can be changed using the `ConfigurationFile` setting. -The actions configuration can be change by altering the settings in the configuration file. - -```yaml -DatePrereleaseFormat: 'yyyyMMddHHmm' -IncrementalPrerelease: false -VersionPrefix: '' -``` - -This example uses the date format for the prerelease, disables the incremental prerelease and removes the version prefix. - ## Example ```yaml diff --git a/action.yml b/action.yml index cf435e4..e12b252 100644 --- a/action.yml +++ b/action.yml @@ -106,5 +106,4 @@ runs: Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} WorkingDirectory: ${{ inputs.WorkingDirectory }} - Script: | - ${{ github.action_path }}/scripts/main.ps1 + Script: ${{ github.action_path }}/scripts/main.ps1 diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 95522f4..d12405f 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -35,58 +35,29 @@ ) LogGroup 'Set configuration' { - if (-not (Test-Path -Path $env:PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile -PathType Leaf)) { - Write-Output "Configuration file not found at [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile]" - } else { - Write-Output "Reading from configuration file [$env:PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile]" - $configuration = ConvertFrom-Yaml -Yaml (Get-Content $env:PSMODULE_PUBLISH_PSMODULE_INPUT_ConfigurationFile -Raw) - } - - $autoCleanup = ($configuration.AutoCleanup | IsNotNullOrEmpty) ? - $configuration.AutoCleanup -eq 'true' : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoCleanup -eq 'true' - $autoPatching = ($configuration.AutoPatching | IsNotNullOrEmpty) ? - $configuration.AutoPatching -eq 'true' : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoPatching -eq 'true' - $datePrereleaseFormat = ($configuration.DatePrereleaseFormat | IsNotNullOrEmpty) ? - $configuration.DatePrereleaseFormat : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_DatePrereleaseFormat - $incrementalPrerelease = ($configuration.IncrementalPrerelease | IsNotNullOrEmpty) ? - $configuration.IncrementalPrerelease -eq 'true' : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IncrementalPrerelease -eq 'true' - $versionPrefix = ($configuration.VersionPrefix | IsNotNullOrEmpty) ? - $configuration.VersionPrefix : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix - $whatIf = ($configuration.WhatIf | IsNotNullOrEmpty) ? - $configuration.WhatIf -eq 'true' : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf -eq 'true' - - $ignoreLabels = (($configuration.IgnoreLabels | IsNotNullOrEmpty) ? - $configuration.IgnoreLabels : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IgnoreLabels) -split ',' | ForEach-Object { $_.Trim() } - $majorLabels = (($configuration.MajorLabels | IsNotNullOrEmpty) ? - $configuration.MajorLabels : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels) -split ',' | ForEach-Object { $_.Trim() } - $minorLabels = (($configuration.MinorLabels | IsNotNullOrEmpty) ? - $configuration.MinorLabels : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels) -split ',' | ForEach-Object { $_.Trim() } - $patchLabels = (($configuration.PatchLabels | IsNotNullOrEmpty) ? - $configuration.PatchLabels : - $env:PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels) -split ',' | ForEach-Object { $_.Trim() } - - Write-Output '-------------------------------------------------' - Write-Output "Auto cleanup enabled: [$autoCleanup]" - Write-Output "Auto patching enabled: [$autoPatching]" - Write-Output "Date-based prerelease format: [$datePrereleaseFormat]" - Write-Output "Incremental prerelease enabled: [$incrementalPrerelease]" - Write-Output "Version prefix: [$versionPrefix]" - Write-Output "What if mode: [$whatIf]" - Write-Output '' - Write-Output "Ignore labels: [$($ignoreLabels -join ', ')]" - Write-Output "Major labels: [$($majorLabels -join ', ')]" - Write-Output "Minor labels: [$($minorLabels -join ', ')]" - Write-Output "Patch labels: [$($patchLabels -join ', ')]" - Write-Output '-------------------------------------------------' + $autoCleanup = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoCleanup -eq 'true' + $autoPatching = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoPatching -eq 'true' + $datePrereleaseFormat = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_DatePrereleaseFormat + $incrementalPrerelease = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IncrementalPrerelease -eq 'true' + $versionPrefix = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix + $whatIf = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf -eq 'true' + $ignoreLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IgnoreLabels -split ',' | ForEach-Object { $_.Trim() } + $majorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels -split ',' | ForEach-Object { $_.Trim() } + $minorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels -split ',' | ForEach-Object { $_.Trim() } + $patchLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels -split ',' | ForEach-Object { $_.Trim() } + + [pscustomobject]@{ + AutoCleanup = $autoCleanup + AutoPatching = $autoPatching + DatePrereleaseFormat = $datePrereleaseFormat + IncrementalPrerelease = $incrementalPrerelease + VersionPrefix = $versionPrefix + WhatIf = $whatIf + IgnoreLabels = $ignoreLabels + MajorLabels = $majorLabels + MinorLabels = $minorLabels + PatchLabels = $patchLabels + } | Format-List | Out-String } LogGroup 'Event information - JSON' { From ae417b16e47370b83292bf7a3cc54e6527192d29 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Mar 2025 19:21:35 +0100 Subject: [PATCH 29/30] [Refactor]: Update README and action.yml to streamline input parameters and improve clarity --- README.md | 8 ++++---- action.yml | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 68c619f..83faa3c 100644 --- a/README.md +++ b/README.md @@ -47,18 +47,18 @@ The action can be configured using the following settings: | Name | Description | Required | Default | | --- | --- | --- | --- | +| `Name` | Name of the module to publish. Defaults to the repository name. | `false` | | +| `ModulePath` | Path to the folder where the module to publish is located. | `false` | `outputs/modules` | | `APIKey` | PowerShell Gallery API Key. | `true` | | | `AutoCleanup`| Control wether to automatically cleanup prereleases. If disabled, the action will not remove any prereleases. | `false` | `true` | | `AutoPatching` | Control wether to automatically handle patches. If disabled, the action will only create a patch release if the pull request has a 'patch' label. | `false` | `true` | | `DatePrereleaseFormat` | The format to use for the prerelease number using [.NET DateTime format strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings). | `false` | `''` | -| `IgnoreLabels` | A comma separated list of labels that do not trigger a release. | `false` | `NoRelease` | | `IncrementalPrerelease` | Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch. | `false` | `true` | +| `VersionPrefix` | The prefix to use for the version number. | `false` | `v` | | `MajorLabels` | A comma separated list of labels that trigger a major release. | `false` | `major, breaking` | | `MinorLabels` | A comma separated list of labels that trigger a minor release. | `false` | `minor, feature` | -| `ModulePath` | Path to the folder where the module to publish is located. | `false` | `outputs/modules` | -| `Name` | Name of the module to publish. Defaults to the repository name. | `false` | | | `PatchLabels` | A comma separated list of labels that trigger a patch release. | `false` | `patch, fix` | -| `VersionPrefix` | The prefix to use for the version number. | `false` | `v` | +| `IgnoreLabels` | A comma separated list of labels that do not trigger a release. | `false` | `NoRelease` | | `WhatIf` | Control wether to simulate the action. If enabled, the action will not create any releases. Used for testing. | `false` | `false` | | `Debug` | Enable debug output. | `'false'` | `false` | | `Verbose` | Enable verbose output. | `'false'` | `false` | diff --git a/action.yml b/action.yml index e12b252..2b0fac0 100644 --- a/action.yml +++ b/action.yml @@ -24,18 +24,18 @@ inputs: description: Control wether to automatically handle patches. If disabled, the action will only create a patch release if the pull request has a 'patch' label. required: false default: 'true' + IncrementalPrerelease: + description: Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch. + required: false + default: 'true' DatePrereleaseFormat: description: If specified, uses a date based prerelease scheme. The format should be a valid .NET format string like 'yyyyMMddHHmm'. required: false default: '' - IgnoreLabels: - description: A comma separated list of labels that do not trigger a release. - required: false - default: NoRelease - IncrementalPrerelease: - description: Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch. + VersionPrefix: + description: The prefix to use for the version number. required: false - default: 'true' + default: v MajorLabels: description: A comma separated list of labels that trigger a major release. required: false @@ -48,10 +48,10 @@ inputs: description: A comma separated list of labels that trigger a patch release. required: false default: patch, fix - VersionPrefix: - description: The prefix to use for the version number. + IgnoreLabels: + description: A comma separated list of labels that do not trigger a release. required: false - default: v + default: NoRelease WhatIf: description: If specified, the action will only log the changes it would make, but will not actually create or delete any releases or tags. required: false From ff1fb42e682cbe9074f670ae7b4bb1ccd65b895f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 24 Mar 2025 19:45:05 +0100 Subject: [PATCH 30/30] [Fix]: Correctly assign DatePrereleaseFormat variable in Publish-PSModule script --- scripts/helpers/Publish-PSModule.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index d12405f..96ce20d 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -37,8 +37,8 @@ LogGroup 'Set configuration' { $autoCleanup = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoCleanup -eq 'true' $autoPatching = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_AutoPatching -eq 'true' - $datePrereleaseFormat = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_DatePrereleaseFormat $incrementalPrerelease = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IncrementalPrerelease -eq 'true' + $datePrereleaseFormat = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_DatePrereleaseFormat $versionPrefix = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix $whatIf = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf -eq 'true' $ignoreLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IgnoreLabels -split ',' | ForEach-Object { $_.Trim() } @@ -49,8 +49,8 @@ [pscustomobject]@{ AutoCleanup = $autoCleanup AutoPatching = $autoPatching - DatePrereleaseFormat = $datePrereleaseFormat IncrementalPrerelease = $incrementalPrerelease + DatePrereleaseFormat = $datePrereleaseFormat VersionPrefix = $versionPrefix WhatIf = $whatIf IgnoreLabels = $ignoreLabels