diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 35bb52d..afa6647 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -35,6 +35,6 @@ jobs: Verbose: true Debug: true Name: PSModuleTest - ModulePath: tests/outputs/modules + WorkingDirectory: tests APIKey: ${{ secrets.APIKEY }} WhatIf: true 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 diff --git a/README.md b/README.md index 547ed2e..83faa3c 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. @@ -47,38 +47,24 @@ 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` | -| `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` | +| `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` | | `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` | - -### 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. +| `WorkingDirectory` | The working directory where the script runs. | `'false'` | `'.'` | ## Example diff --git a/action.yml b/action.yml index 1f4bb6c..2b0fac0 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 @@ -24,22 +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' - ConfigurationFile: - description: The path to the configuration file. Settings in the configuration file take precedence over the action inputs. + 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: .github\auto-release.yml + 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 @@ -52,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 @@ -75,32 +71,39 @@ 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: '.' runs: using: composite steps: + - name: Install-PSModuleHelpers + uses: PSModule/Install-PSModuleHelpers@v1 + - 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_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: + Name: Publish-PSModule Debug: ${{ inputs.Debug }} Prerelease: ${{ inputs.Prerelease }} Verbose: ${{ inputs.Verbose }} Version: ${{ inputs.Version }} - Script: | - # Publish-PSModule - ${{ github.action_path }}\scripts\main.ps1 + WorkingDirectory: ${{ inputs.WorkingDirectory }} + Script: ${{ github.action_path }}/scripts/main.ps1 diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 075285e..96ce20d 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.' @@ -35,69 +35,40 @@ ) 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]" - } else { - Write-Output "Reading from configuration file [$env:GITHUB_ACTION_INPUT_ConfigurationFile]" - $configuration = ConvertFrom-Yaml -Yaml (Get-Content $env:GITHUB_ACTION_INPUT_ConfigurationFile -Raw) - } - - $autoCleanup = ($configuration.AutoCleanup | IsNotNullOrEmpty) ? - $configuration.AutoCleanup -eq 'true' : - $env:GITHUB_ACTION_INPUT_AutoCleanup -eq 'true' - $autoPatching = ($configuration.AutoPatching | IsNotNullOrEmpty) ? - $configuration.AutoPatching -eq 'true' : - $env:GITHUB_ACTION_INPUT_AutoPatching -eq 'true' - $datePrereleaseFormat = ($configuration.DatePrereleaseFormat | IsNotNullOrEmpty) ? - $configuration.DatePrereleaseFormat : - $env:GITHUB_ACTION_INPUT_DatePrereleaseFormat - $incrementalPrerelease = ($configuration.IncrementalPrerelease | IsNotNullOrEmpty) ? - $configuration.IncrementalPrerelease -eq 'true' : - $env:GITHUB_ACTION_INPUT_IncrementalPrerelease -eq 'true' - $versionPrefix = ($configuration.VersionPrefix | IsNotNullOrEmpty) ? - $configuration.VersionPrefix : - $env:GITHUB_ACTION_INPUT_VersionPrefix - $whatIf = ($configuration.WhatIf | IsNotNullOrEmpty) ? - $configuration.WhatIf -eq 'true' : - $env:GITHUB_ACTION_INPUT_WhatIf -eq 'true' - - $ignoreLabels = (($configuration.IgnoreLabels | IsNotNullOrEmpty) ? - $configuration.IgnoreLabels : - $env:GITHUB_ACTION_INPUT_IgnoreLabels) -split ',' | ForEach-Object { $_.Trim() } - $majorLabels = (($configuration.MajorLabels | IsNotNullOrEmpty) ? - $configuration.MajorLabels : - $env:GITHUB_ACTION_INPUT_MajorLabels) -split ',' | ForEach-Object { $_.Trim() } - $minorLabels = (($configuration.MinorLabels | IsNotNullOrEmpty) ? - $configuration.MinorLabels : - $env:GITHUB_ACTION_INPUT_MinorLabels) -split ',' | ForEach-Object { $_.Trim() } - $patchLabels = (($configuration.PatchLabels | IsNotNullOrEmpty) ? - $configuration.PatchLabels : - $env:GITHUB_ACTION_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' + $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() } + $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 + IncrementalPrerelease = $incrementalPrerelease + DatePrereleaseFormat = $datePrereleaseFormat + VersionPrefix = $versionPrefix + WhatIf = $whatIf + IgnoreLabels = $ignoreLabels + MajorLabels = $majorLabels + MinorLabels = $minorLabels + PatchLabels = $patchLabels + } | Format-List | Out-String } 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 +98,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 +141,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 @@ -183,28 +154,35 @@ } Write-Output '-------------------------------------------------' Write-Output 'GitHub version:' - Write-Output ($ghReleaseVersion | Format-Table | Out-String) Write-Output $ghReleaseVersion.ToString() Write-Output '-------------------------------------------------' } LogGroup 'Get latest version - PSGallery' { - try { - Retry -Count 5 -Delay 10 { + $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) - } -Catch { - throw $_ + 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 + } + Start-Sleep -Seconds $delay } - $psGalleryVersion = New-PSSemVer -Version $latest.Version - } catch { + } + 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.' $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 '-------------------------------------------------' } @@ -227,7 +205,6 @@ } Write-Output '-------------------------------------------------' Write-Output 'Manifest version:' - Write-Output ($manifestVersion | Format-Table | Out-String) Write-Output $manifestVersion.ToString() Write-Output '-------------------------------------------------' } @@ -346,11 +323,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" @@ -415,7 +391,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/helpers/Resolve-PSModuleDependency.ps1 b/scripts/helpers/Resolve-PSModuleDependency.ps1 deleted file mode 100644 index 7d8d067..0000000 --- a/scripts/helpers/Resolve-PSModuleDependency.ps1 +++ /dev/null @@ -1,64 +0,0 @@ -#Requires -Modules Retry - -function Resolve-PSModuleDependency { - <# - .SYNOPSIS - Resolve dependencies for a module based on the manifest file. - - .DESCRIPTION - Resolve dependencies for a module based on the manifest file, following PSModuleInfo structure - - .EXAMPLE - Resolve-PSModuleDependency -Path '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. - #> - [Alias('Resolve-PSModuleDependencies')] - [CmdletBinding()] - param( - # The path to the manifest file. - [Parameter(Mandatory)] - [string] $ManifestFilePath - ) - - Write-Verbose 'Resolving dependencies' - - $manifest = Import-PowerShellDataFile -Path $ManifestFilePath - Write-Verbose "Reading [$ManifestFilePath]" - Write-Verbose "Found [$($manifest.RequiredModules.Count)] modules to install" - - foreach ($requiredModule in $manifest.RequiredModules) { - $installParams = @{} - - if ($requiredModule -is [string]) { - $installParams.Name = $requiredModule - } else { - $installParams.Name = $requiredModule.ModuleName - $installParams.MinimumVersion = $requiredModule.ModuleVersion - $installParams.RequiredVersion = $requiredModule.RequiredVersion - $installParams.MaximumVersion = $requiredModule.MaximumVersion - } - $installParams.Force = $true - $installParams.Verbose = $false - - Write-Verbose "[$($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" - $VerbosePreferenceOriginal = $VerbosePreference - $VerbosePreference = 'SilentlyContinue' - Import-Module @installParams - $VerbosePreference = $VerbosePreferenceOriginal - Write-Verbose "[$($installParams.Name)] - Done" - } - Write-Verbose 'Resolving dependencies - Done' -} diff --git a/scripts/main.ps1 b/scripts/main.ps1 index f6f0c4e..b946e9c 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -10,25 +10,23 @@ LogGroup "Loading helper scripts from [$path]" { } LogGroup 'Loading inputs' { - Write-Verbose "Name: [$env:GITHUB_ACTION_INPUT_Name]" - Write-Verbose "GITHUB_REPOSITORY: [$env:GITHUB_REPOSITORY]" - Write-Verbose "GITHUB_WORKSPACE: [$env:GITHUB_WORKSPACE]" - - $name = ($env:GITHUB_ACTION_INPUT_Name | IsNullOrEmpty) ? $env:GITHUB_REPOSITORY_NAME : $env:GITHUB_ACTION_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]" - - $modulePath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath $env:GITHUB_ACTION_INPUT_ModulePath $name - Write-Verbose "Module path: [$modulePath]" - if (-not (Test-Path -Path $modulePath)) { - throw "Module path [$modulePath] does not exist." + $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_ModulePath/$name" | Select-Object -ExpandProperty Path + [pscustomobject]@{ + Name = $name + ModulePath = $modulePath + APIKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey + } | Format-List | Out-String + } $params = @{ Name = $name ModulePath = $modulePath - APIKey = $env:GITHUB_ACTION_INPUT_APIKey + APIKey = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_APIKey } Publish-PSModule @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