From 0d98e7db9c66175e9f9a159499af980e62063cde Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 01:31:05 +0200 Subject: [PATCH 1/8] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20initiali?= =?UTF-8?q?zation=20step=20and=20dependency=20on=20`Utilities`=20(#114)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This pull request simplifies the codebase by removing redundant module dependencies and improving code readability across various scripts. It also consolidates file exclusions in the `.jscpd.json` configuration and updates logic for handling module manifest properties. ### Module Dependency Removal: * Removed `#Requires` statements for unused module dependencies (`GitHub`, `Utilities`, `Hashtable`) across multiple scripts, including `Build-PSModule.ps1`, `Build-PSModuleManifest.ps1`, and `Build-PSModuleRootModule.ps1` files. [[1]](diffhunk://#diff-c688e346ad60fbe881bd05b6a5dbc1cd712fdca0bf8b8527965db583af825fd9L11-L12) [[2]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L14-L15) [[3]](diffhunk://#diff-1d337ff39f37506a54fda1c5d0487f1b2c2ef318f216a4d9a56c3e7248b69879L1-R1) [[4]](diffhunk://#diff-faeb855accbc346b12f7a0ece1d91f67e26e8929ab8133aedca4051d179c66faL18-L19) ### Configuration Updates: * Consolidated file exclusions in `.github/linters/.jscpd.json` by replacing specific file paths with a wildcard (`**/scripts/helpers/**`). ### Workflow Simplification: * Removed the `Initialize-PSModule` step from the `Action-Test.yml` workflow, streamlining the setup process. [[1]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4L28-L30) [[2]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4L45-L47) [[3]](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4L62-L64) ### Code Readability Improvements: * Replaced custom `IsNotNullOrEmpty` function calls with native `.NET` methods like `[string]::IsNullOrEmpty` for better clarity and maintainability in scripts such as `Build-PSModuleManifest.ps1` and `Get-PSModuleAliasesToExport.ps1`. [[1]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L63-R64) [[2]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L76-R74) [[3]](diffhunk://#diff-ae18191466ffa02c1a8429365cf96d8768f5eae03331c4a35199f8cd961e76a7L33-R30) [[4]](diffhunk://#diff-f542f4a75d778df60fee6e176c795e133be2ed109d8212c05aa545383bd26c46L33-R30) ### Suppression Attribute Adjustments: * Updated `Diagnostics.CodeAnalysis.SuppressMessageAttribute` to include `Scope = 'Function'` for consistency in scripts like `Get-PSModuleClassesToExport.ps1` and `Get-PSModuleCmdletsToExport.ps1`. [[1]](diffhunk://#diff-c51cdeca9e44fe598bc10e94c98fc0d72f8a6fb36e872193b2fc9b9b1348f1a9L20-R20) [[2]](diffhunk://#diff-f542f4a75d778df60fee6e176c795e133be2ed109d8212c05aa545383bd26c46L13-R14) ## Type of change - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas --- .github/linters/.jscpd.json | 4 +--- .github/workflows/Action-Test.yml | 9 --------- scripts/helpers/Build-PSModule.ps1 | 2 -- scripts/helpers/Build/Build-PSModuleBase.ps1 | 1 - scripts/helpers/Build/Build-PSModuleManifest.ps1 | 8 +++----- scripts/helpers/Build/Build-PSModuleRootModule.ps1 | 5 +---- scripts/helpers/Build/Get-PSModuleAliasesToExport.ps1 | 9 +++------ scripts/helpers/Build/Get-PSModuleClassesToExport.ps1 | 2 +- scripts/helpers/Build/Get-PSModuleCmdletsToExport.ps1 | 9 +++------ scripts/helpers/Build/Get-PSModuleFunctionsToExport.ps1 | 6 ++---- .../Build/Update-PSModuleManifestAliasesToExport.ps1 | 2 -- scripts/main.ps1 | 2 -- 12 files changed, 14 insertions(+), 45 deletions(-) diff --git a/.github/linters/.jscpd.json b/.github/linters/.jscpd.json index 7cc00e60..f734bf16 100644 --- a/.github/linters/.jscpd.json +++ b/.github/linters/.jscpd.json @@ -6,9 +6,7 @@ "ignore": [ "**/tests/**", "**/.github/workflows/Action-Test.yml", - "**/scripts/helpers/Build/Build-PSModuleManifest.ps1", - "**/scripts/helpers/Build/Build-PSModuleRootModule.ps1", - "**/scripts/helpers/Build/PSScriptAnalyzer.Tests.psd1" + "**/scripts/helpers/**" ], "absolute": true } diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index a334e868..9b426109 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -25,9 +25,6 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Initialize environment - uses: PSModule/Initialize-PSModule@v1 - - name: Action-Test uses: ./ with: @@ -42,9 +39,6 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Initialize environment - uses: PSModule/Initialize-PSModule@v1 - - name: Action-Test uses: ./ with: @@ -59,9 +53,6 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Initialize environment - uses: PSModule/Initialize-PSModule@v1 - - name: Action-Test uses: ./ with: diff --git a/scripts/helpers/Build-PSModule.ps1 b/scripts/helpers/Build-PSModule.ps1 index ea854597..29a4d8ea 100644 --- a/scripts/helpers/Build-PSModule.ps1 +++ b/scripts/helpers/Build-PSModule.ps1 @@ -8,8 +8,6 @@ #> [OutputType([void])] [CmdletBinding()] - #Requires -Modules @{ ModuleName = 'GitHub'; ModuleVersion = '0.13.2' } - #Requires -Modules @{ ModuleName = 'Utilities'; ModuleVersion = '0.3.0' } [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSReviewUnusedParameter', '', Scope = 'Function', Justification = 'LogGroup - Scoping affects the variables line of sight.' diff --git a/scripts/helpers/Build/Build-PSModuleBase.ps1 b/scripts/helpers/Build/Build-PSModuleBase.ps1 index a0b2c3db..4a0b9035 100644 --- a/scripts/helpers/Build/Build-PSModuleBase.ps1 +++ b/scripts/helpers/Build/Build-PSModuleBase.ps1 @@ -11,7 +11,6 @@ Build-PSModuleBase -SourceFolderPath 'C:\MyModule\src\MyModule' -OutputFolderPath 'C:\MyModule\build\MyModule' #> [CmdletBinding()] - #Requires -Modules @{ ModuleName = 'GitHub'; ModuleVersion = '0.13.2' } [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSReviewUnusedParameter', '', Scope = 'Function', Justification = 'LogGroup - Scoping affects the variables line of sight.' diff --git a/scripts/helpers/Build/Build-PSModuleManifest.ps1 b/scripts/helpers/Build/Build-PSModuleManifest.ps1 index 62260198..e3ae0f29 100644 --- a/scripts/helpers/Build/Build-PSModuleManifest.ps1 +++ b/scripts/helpers/Build/Build-PSModuleManifest.ps1 @@ -11,8 +11,6 @@ Build-PSModuleManifest -SourceFolderPath 'C:\MyModule\src\MyModule' -OutputFolderPath 'C:\MyModule\build\MyModule' #> [CmdletBinding()] - #Requires -Modules @{ ModuleName = 'GitHub'; ModuleVersion = '0.13.2' } - #Requires -Modules @{ ModuleName = 'Utilities'; ModuleVersion = '0.3.0' } [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSAvoidLongLines', '', Scope = 'Function', Justification = 'Easier to read the multi ternery operators in a single line.' @@ -60,10 +58,10 @@ $manifest.ModuleVersion = '999.0.0' Write-Host "[ModuleVersion] - [$($manifest.ModuleVersion)]" - $manifest.Author = $manifest.Keys -contains 'Author' ? ($manifest.Author | IsNotNullOrEmpty) ? $manifest.Author : $env:GITHUB_REPOSITORY_OWNER : $env:GITHUB_REPOSITORY_OWNER + $manifest.Author = $manifest.Keys -contains 'Author' ? (-not [string]::IsNullOrEmpty($manifest.Author)) ? $manifest.Author : $env:GITHUB_REPOSITORY_OWNER : $env:GITHUB_REPOSITORY_OWNER Write-Host "[Author] - [$($manifest.Author)]" - $manifest.CompanyName = $manifest.Keys -contains 'CompanyName' ? ($manifest.CompanyName | IsNotNullOrEmpty) ? $manifest.CompanyName : $env:GITHUB_REPOSITORY_OWNER : $env:GITHUB_REPOSITORY_OWNER + $manifest.CompanyName = $manifest.Keys -contains 'CompanyName' ? (-not [string]::IsNullOrEmpty($manifest.CompanyName)) ? $manifest.CompanyName : $env:GITHUB_REPOSITORY_OWNER : $env:GITHUB_REPOSITORY_OWNER Write-Host "[CompanyName] - [$($manifest.CompanyName)]" $year = Get-Date -Format 'yyyy' @@ -73,7 +71,7 @@ Write-Host "[Copyright] - [$($manifest.Copyright)]" $repoDescription = gh repo view --json description | ConvertFrom-Json | Select-Object -ExpandProperty description - $manifest.Description = $manifest.Keys -contains 'Description' ? ($manifest.Description | IsNotNullOrEmpty) ? $manifest.Description : $repoDescription : $repoDescription + $manifest.Description = $manifest.Keys -contains 'Description' ? (-not [string]::IsNullOrEmpty($manifest.Description)) ? $manifest.Description : $repoDescription : $repoDescription Write-Host "[Description] - [$($manifest.Description)]" $manifest.PowerShellHostName = $manifest.Keys -contains 'PowerShellHostName' ? -not [string]::IsNullOrEmpty($manifest.PowerShellHostName) ? $manifest.PowerShellHostName : $null : $null diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index adef93a7..b3b9ff16 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -1,7 +1,4 @@ -#Requires -Modules @{ ModuleName = 'GitHub'; ModuleVersion = '0.13.2' } -#Requires -Modules @{ ModuleName = 'Hashtable'; ModuleVersion = '1.1.1' } - -function Build-PSModuleRootModule { +function Build-PSModuleRootModule { <# .SYNOPSIS Compiles the module root module files. diff --git a/scripts/helpers/Build/Get-PSModuleAliasesToExport.ps1 b/scripts/helpers/Build/Get-PSModuleAliasesToExport.ps1 index 5c8a990e..adc21d13 100644 --- a/scripts/helpers/Build/Get-PSModuleAliasesToExport.ps1 +++ b/scripts/helpers/Build/Get-PSModuleAliasesToExport.ps1 @@ -10,11 +10,8 @@ Get-PSModuleAliasesToExport -SourceFolderPath 'C:\MyModule\src\MyModule' #> [CmdletBinding()] - #Requires -Modules @{ ModuleName = 'Utilities'; ModuleVersion = '0.3.0' } - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSAvoidUsingWriteHost', '', Scope = 'Function', - Justification = 'Want to just write to the console, not the pipeline.' - )] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope = 'Function', Justification = 'Want to just write to the console, not the pipeline.')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Scope = 'Function', Justification = 'Contains long links.')] param( # Path to the folder where the module source code is located. [Parameter(Mandatory)] @@ -30,7 +27,7 @@ $manifest = Get-ModuleManifest -Path $manifestFilePath -Verbose:$false Write-Host "[$manifestPropertyName]" - $aliasesToExport = (($manifest.AliasesToExport).count -eq 0) -or ($manifest.AliasesToExport | IsNullOrEmpty) ? '*' : $manifest.AliasesToExport + $aliasesToExport = (($manifest.AliasesToExport).count -eq 0) -or [string]::IsNullOrEmpty($manifest.AliasesToExport) ? '*' : $manifest.AliasesToExport $aliasesToExport | ForEach-Object { Write-Host "[$manifestPropertyName] - [$_]" } diff --git a/scripts/helpers/Build/Get-PSModuleClassesToExport.ps1 b/scripts/helpers/Build/Get-PSModuleClassesToExport.ps1 index b01219a6..4b541f63 100644 --- a/scripts/helpers/Build/Get-PSModuleClassesToExport.ps1 +++ b/scripts/helpers/Build/Get-PSModuleClassesToExport.ps1 @@ -17,7 +17,7 @@ .NOTES Inspired by [about_Classes | Exporting classes with type accelerators](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_classes?view=powershell-7.4#exporting-classes-with-type-accelerators) #> - [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains long links.')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Scope = 'Function', Justification = 'Contains long links.')] [CmdletBinding()] param ( # The path to the module root folder. diff --git a/scripts/helpers/Build/Get-PSModuleCmdletsToExport.ps1 b/scripts/helpers/Build/Get-PSModuleCmdletsToExport.ps1 index 2e07f8c3..1ac20e65 100644 --- a/scripts/helpers/Build/Get-PSModuleCmdletsToExport.ps1 +++ b/scripts/helpers/Build/Get-PSModuleCmdletsToExport.ps1 @@ -10,11 +10,8 @@ Get-PSModuleCmdletsToExport -SourceFolderPath 'C:\MyModule\src\MyModule' #> [CmdletBinding()] - #Requires -Modules @{ ModuleName = 'Utilities'; ModuleVersion = '0.3.0' } - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSAvoidUsingWriteHost', '', Scope = 'Function', - Justification = 'Want to just write to the console, not the pipeline.' - )] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope = 'Function', Justification = 'Want to just write to the console, not the pipeline.')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Scope = 'Function', Justification = 'Contains long links.')] param( # Path to the folder where the module source code is located. [Parameter(Mandatory)] @@ -30,7 +27,7 @@ $manifest = Get-ModuleManifest -Path $manifestFilePath -Verbose:$false Write-Host "[$manifestPropertyName]" - $cmdletsToExport = (($manifest.CmdletsToExport).count -eq 0) -or ($manifest.CmdletsToExport | IsNullOrEmpty) ? '' : $manifest.CmdletsToExport + $cmdletsToExport = (($manifest.CmdletsToExport).count -eq 0) -or [string]::IsNullOrEmpty($manifest.CmdletsToExport) ? '' : $manifest.CmdletsToExport $cmdletsToExport | ForEach-Object { Write-Host "[$manifestPropertyName] - [$_]" } diff --git a/scripts/helpers/Build/Get-PSModuleFunctionsToExport.ps1 b/scripts/helpers/Build/Get-PSModuleFunctionsToExport.ps1 index 03671c89..3d64494d 100644 --- a/scripts/helpers/Build/Get-PSModuleFunctionsToExport.ps1 +++ b/scripts/helpers/Build/Get-PSModuleFunctionsToExport.ps1 @@ -10,10 +10,8 @@ Get-PSModuleFunctionsToExport -SourceFolderPath 'C:\MyModule\src\MyModule' #> [CmdletBinding()] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSAvoidUsingWriteHost', '', Scope = 'Function', - Justification = 'Want to just write to the console, not the pipeline.' - )] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope = 'Function', Justification = 'Want to just write to the console, not the pipeline.')] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Scope = 'Function', Justification = 'Contains long links.')] [OutputType([array])] param( # Path to the folder where the module source code is located. diff --git a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 index 887b73cf..65608df8 100644 --- a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 +++ b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 @@ -15,8 +15,6 @@ 'PSAvoidUsingWriteHost', '', Scope = 'Function', Justification = 'Want to just write to the console, not the pipeline.' )] - #Requires -Modules @{ ModuleName = 'GitHub'; ModuleVersion = '0.13.2' } - #Requires -Modules @{ ModuleName = 'Utilities'; ModuleVersion = '0.3.0' } [CmdletBinding()] param( # Name of the module. diff --git a/scripts/main.ps1 b/scripts/main.ps1 index c760ab99..af18b668 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -5,8 +5,6 @@ [CmdletBinding()] param() -#Requires -Modules Utilities - $path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers') | Get-Item | Resolve-Path -Relative LogGroup "Loading helper scripts from [$path]" { Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | Resolve-Path -Relative | ForEach-Object { From 46d8c8c0a0ac8969052799fafbb86bc6f739c1ac Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Jun 2025 02:31:58 +0200 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20Build-?= =?UTF-8?q?PSModule=20action=20without=20Github-Script=20(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This pull request includes updates to the PowerShell module build process and related scripts, focusing on improving compatibility with GitHub Actions and simplifying output handling. The changes primarily affect the `action.yml` file and several PowerShell scripts. ### Updates to GitHub Actions configuration: * [`action.yml`](diffhunk://#diff-1243c5424efaaa19bd8e813c5e6f6da46316e63761421b3e5f5c8ced9a36e6b6L43-R55): Replaced the `uses` directive for running PowerShell scripts with the `shell: pwsh` option and updated the `run` block to execute the build script directly. Simplified artifact upload by changing the path reference to use `steps.build.outputs.ModuleOutputFolderPath` instead of parsing JSON. ### Updates to script handling: * [`scripts/main.ps1`](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011R16-L23): Added a new environment variable `$env:GITHUB_REPOSITORY_NAME` derived from `$env:GITHUB_REPOSITORY` for repository name extraction. Replaced `Set-GitHubOutput` calls with direct appending to `$env:GITHUB_OUTPUT` for compatibility with GitHub Actions. [[1]](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011R16-L23) [[2]](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011L53-R53) ### Updates to URI generation: * [`scripts/helpers/Build/Build-PSModuleManifest.ps1`](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L390-R390): Simplified the generation of `LicenseUri` and `IconUri` by using `$env:GITHUB_REPOSITORY` directly instead of combining `$env:GITHUB_REPOSITORY_OWNER` and `$env:GITHUB_REPOSITORY_NAME`. [[1]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L390-R390) [[2]](diffhunk://#diff-50cfb011f5c8aeef8145003927ec3e5edfdf26e5d417bcee6e441517c07454f9L406-R406) ## Type of change - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas --- README.md | 15 +++------ action.yml | 32 ++++--------------- scripts/helpers/Build-PSModule.ps1 | 4 +-- scripts/helpers/Build/Build-PSModuleBase.ps1 | 4 +-- .../helpers/Build/Build-PSModuleManifest.ps1 | 16 +++++----- .../Build/Build-PSModuleRootModule.ps1 | 12 +++---- ...Update-PSModuleManifestAliasesToExport.ps1 | 2 +- scripts/main.ps1 | 14 ++++---- 8 files changed, 37 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 048a291f..7cc352da 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,11 @@ This step lets you add custom build logic to process or modify the module conten ## Usage -| Name | Description | Required | Default | -| --------------------| ----------------------------------------------------------------------------------------------- | -------- | ----------------- | -| `Name` | Name of the module to process. | `false` | | -| `Path` | Path to the folder where the modules are located. | `false` | `src` | -| `ModulesOutputPath` | Path to the folder where the built modules are outputted. | `false` | `outputs/modules` | -| `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'` | -| `WorkingDirectory` | The working directory where the script runs. | `false` | `'.'` | +| Name | Description | Required | Default | +| ------------------ | ------------------------------------------------------ | -------- | --------- | +| `Name` | Name of the module to process. | `false` | | +| `ArtifactName` | Name of the artifact to upload. | `false` | `module` | +| `WorkingDirectory` | The working directory where the script will run from. | `false` | `'.'` | ## Expected repository structure diff --git a/action.yml b/action.yml index 62ee0287..5117c561 100644 --- a/action.yml +++ b/action.yml @@ -13,21 +13,6 @@ inputs: description: Name of the artifact to upload. required: false default: module - Debug: - description: Enable debug output. - required: false - default: 'false' - Verbose: - description: Enable verbose output. - required: false - default: 'false' - Version: - description: Specifies the version of the GitHub module to be installed. The value must be an exact version. - required: false - Prerelease: - description: Allow prerelease versions if available. - required: false - default: 'false' WorkingDirectory: description: The working directory where the script will run from. required: false @@ -40,24 +25,19 @@ runs: uses: PSModule/Install-PSModuleHelpers@v1 - name: Run Build-PSModule - uses: PSModule/GitHub-Script@v1 + shell: pwsh id: build + working-directory: ${{ inputs.WorkingDirectory }} env: PSMODULE_BUILD_PSMODULE_INPUT_Name: ${{ inputs.Name }} - with: - Debug: ${{ inputs.Debug }} - Prerelease: ${{ inputs.Prerelease }} - Verbose: ${{ inputs.Verbose }} - Version: ${{ inputs.Version }} - WorkingDirectory: ${{ inputs.WorkingDirectory }} - Script: | - # Build-PSModule - ${{ github.action_path }}/scripts/main.ps1 + run: | + # Build-PSModule + ${{ github.action_path }}/scripts/main.ps1 - name: Upload module artifact uses: actions/upload-artifact@v4 with: name: ${{ inputs.ArtifactName }} - path: ${{ fromJson(steps.build.outputs.result).moduleOutputFolderPath }} + path: ${{ steps.build.outputs.ModuleOutputFolderPath }} if-no-files-found: error retention-days: 1 diff --git a/scripts/helpers/Build-PSModule.ps1 b/scripts/helpers/Build-PSModule.ps1 index 29a4d8ea..15f1ac79 100644 --- a/scripts/helpers/Build-PSModule.ps1 +++ b/scripts/helpers/Build-PSModule.ps1 @@ -30,7 +30,7 @@ [string] $ModuleOutputFolderPath ) - LogGroup "Building module [$ModuleName]" { + Set-GitHubLogGroup "Building module [$ModuleName]" { $moduleSourceFolder = Get-Item -Path $ModuleSourceFolderPath $moduleOutputFolder = New-Item -Path $ModuleOutputFolderPath -Name $ModuleName -ItemType Directory -Force [pscustomobject]@{ @@ -44,7 +44,7 @@ Build-PSModuleRootModule -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder - LogGroup 'Build manifest file - Final Result' { + Set-GitHubLogGroup 'Build manifest file - Final Result' { $outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1" Show-FileContent -Path $outputManifestPath } diff --git a/scripts/helpers/Build/Build-PSModuleBase.ps1 b/scripts/helpers/Build/Build-PSModuleBase.ps1 index 4a0b9035..cc95352b 100644 --- a/scripts/helpers/Build/Build-PSModuleBase.ps1 +++ b/scripts/helpers/Build/Build-PSModuleBase.ps1 @@ -33,7 +33,7 @@ [System.IO.DirectoryInfo] $ModuleOutputFolder ) - LogGroup 'Build base' { + Set-GitHubLogGroup 'Build base' { $relModuleSourceFolder = $ModuleSourceFolder | Resolve-Path -Relative $relModuleOutputFolder = $ModuleOutputFolder | Resolve-Path -Relative Write-Host "Copying files from [$relModuleSourceFolder] to [$relModuleOutputFolder]" @@ -41,7 +41,7 @@ $null = New-Item -Path $ModuleOutputFolder -Name "$ModuleName.psm1" -ItemType File -Force } - LogGroup 'Build base - Result' { + Set-GitHubLogGroup 'Build base - Result' { Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force | Resolve-Path -Relative | Sort-Object } } diff --git a/scripts/helpers/Build/Build-PSModuleManifest.ps1 b/scripts/helpers/Build/Build-PSModuleManifest.ps1 index e3ae0f29..56aab2dd 100644 --- a/scripts/helpers/Build/Build-PSModuleManifest.ps1 +++ b/scripts/helpers/Build/Build-PSModuleManifest.ps1 @@ -33,7 +33,7 @@ [System.IO.DirectoryInfo] $ModuleOutputFolder ) - LogGroup 'Build manifest file' { + Set-GitHubLogGroup 'Build manifest file' { $sourceManifestFilePath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1" Write-Host "[SourceManifestFilePath] - [$sourceManifestFilePath]" if (-not (Test-Path -Path $sourceManifestFilePath)) { @@ -387,7 +387,7 @@ #> Write-Host '[LicenseUri]' - $licenseUri = "https://github.com/$env:GITHUB_REPOSITORY_OWNER/$env:GITHUB_REPOSITORY_NAME/blob/main/LICENSE" + $licenseUri = "https://github.com/$env:GITHUB_REPOSITORY/blob/main/LICENSE" $manifest.LicenseUri = $PSData.Keys -contains 'LicenseUri' ? $null -ne $PSData.LicenseUri ? $PSData.LicenseUri : $licenseUri : $licenseUri Write-Host "[LicenseUri] - [$($manifest.LicenseUri)]" if ([string]::IsNullOrEmpty($manifest.LicenseUri)) { @@ -403,7 +403,7 @@ } Write-Host '[IconUri]' - $iconUri = "https://raw.githubusercontent.com/$env:GITHUB_REPOSITORY_OWNER/$env:GITHUB_REPOSITORY_NAME/main/icon/icon.png" + $iconUri = "https://raw.githubusercontent.com/$env:GITHUB_REPOSITORY/main/icon/icon.png" $manifest.IconUri = $PSData.Keys -contains 'IconUri' ? $null -ne $PSData.IconUri ? $PSData.IconUri : $iconUri : $iconUri Write-Host "[IconUri] - [$($manifest.IconUri)]" if ([string]::IsNullOrEmpty($manifest.IconUri)) { @@ -442,23 +442,23 @@ New-ModuleManifest -Path $outputManifestPath @manifest } - LogGroup 'Build manifest file - Result - Before format' { + Set-GitHubLogGroup 'Build manifest file - Result - Before format' { Show-FileContent -Path $outputManifestPath } - LogGroup 'Build manifest file - Format' { + Set-GitHubLogGroup 'Build manifest file - Format' { Set-ModuleManifest -Path $outputManifestPath } - LogGroup 'Build manifest file - Result - After format' { + Set-GitHubLogGroup 'Build manifest file - Result - After format' { Show-FileContent -Path $outputManifestPath } - LogGroup 'Build manifest file - Validate - Install module dependencies' { + Set-GitHubLogGroup 'Build manifest file - Validate - Install module dependencies' { Resolve-PSModuleDependency -ManifestFilePath $outputManifestPath } - LogGroup 'Build manifest file - Validate - Test manifest file' { + Set-GitHubLogGroup 'Build manifest file - Validate - Test manifest file' { Test-ModuleManifest -Path $outputManifestPath | Format-List | Out-String } } diff --git a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 index b3b9ff16..3b1bfbd8 100644 --- a/scripts/helpers/Build/Build-PSModuleRootModule.ps1 +++ b/scripts/helpers/Build/Build-PSModuleRootModule.ps1 @@ -51,7 +51,7 @@ # Get the path separator for the current OS $pathSeparator = [System.IO.Path]::DirectorySeparatorChar - LogGroup 'Build root module' { + Set-GitHubLogGroup 'Build root module' { $rootModuleFile = New-Item -Path $ModuleOutputFolder -Name "$ModuleName.psm1" -Force #region - Analyze source files @@ -254,26 +254,26 @@ Export-ModuleMember @exports } - LogGroup 'Build root module - Result - Before format' { + Set-GitHubLogGroup 'Build root module - Result - Before format' { Write-Host (Show-FileContent -Path $rootModuleFile) } - LogGroup 'Build root module - Format' { + Set-GitHubLogGroup 'Build root module - Format' { $AllContent = Get-Content -Path $rootModuleFile -Raw $settings = Join-Path -Path $PSScriptRoot 'PSScriptAnalyzer.Tests.psd1' Invoke-Formatter -ScriptDefinition $AllContent -Settings $settings | Out-File -FilePath $rootModuleFile -Encoding utf8BOM -Force } - LogGroup 'Build root module - Result - After format' { + Set-GitHubLogGroup 'Build root module - Result - After format' { Write-Host (Show-FileContent -Path $rootModuleFile) } - # LogGroup 'Build root module - Validate - Import' { + # Set-GitHubLogGroup 'Build root module - Validate - Import' { # Install-PSModule -Path $ModuleOutputFolder # } - # LogGroup 'Build root module - Validate - File list' { + # Set-GitHubLogGroup 'Build root module - Validate - File list' { # Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force | Resolve-Path -Relative | Sort-Object # } } diff --git a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 index 65608df8..5597cd1e 100644 --- a/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 +++ b/scripts/helpers/Build/Update-PSModuleManifestAliasesToExport.ps1 @@ -29,7 +29,7 @@ [Parameter(Mandatory)] [System.IO.DirectoryInfo] $ModuleOutputFolder ) - LogGroup 'Updating aliases to export in module manifest' { + Set-GitHubLogGroup 'Updating aliases to export in module manifest' { Write-Host "Module name: [$ModuleName]" Write-Host "Module output folder: [$ModuleSourceFolder]" diff --git a/scripts/main.ps1 b/scripts/main.ps1 index af18b668..f5f6fba5 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -6,21 +6,21 @@ param() $path = (Join-Path -Path $PSScriptRoot -ChildPath 'helpers') | Get-Item | Resolve-Path -Relative -LogGroup "Loading helper scripts from [$path]" { +Set-GitHubLogGroup "Loading helper scripts from [$path]" { Get-ChildItem -Path $path -Filter '*.ps1' -Recurse | Resolve-Path -Relative | ForEach-Object { Write-Host "$_" . $_ } } -LogGroup 'Loading inputs' { +$env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/' + +Set-GitHubLogGroup 'Loading inputs' { $moduleName = if ([string]::IsNullOrEmpty($env:PSMODULE_BUILD_PSMODULE_INPUT_Name)) { $env:GITHUB_REPOSITORY_NAME } else { $env:PSMODULE_BUILD_PSMODULE_INPUT_Name } - Set-GitHubOutput -Name ModuleName -Value $moduleName - $sourceFolderPath = Resolve-Path -Path 'src' | Select-Object -ExpandProperty Path $moduleOutputFolderPath = Join-Path $pwd -ChildPath 'outputs/module' [pscustomobject]@{ @@ -30,14 +30,14 @@ LogGroup 'Loading inputs' { } | Format-List | Out-String } -LogGroup 'Build local scripts' { +Set-GitHubLogGroup 'Build local scripts' { Write-Host 'Execution order:' $scripts = Get-ChildItem -Filter '*build.ps1' -Recurse | Sort-Object -Property Name | Resolve-Path -Relative $scripts | ForEach-Object { Write-Host " - $_" } $scripts | ForEach-Object { - LogGroup "Build local scripts - [$_]" { + Set-GitHubLogGroup "Build local scripts - [$_]" { . $_ } } @@ -50,6 +50,6 @@ $params = @{ } Build-PSModule @params -Set-GithubOutput -Name ModuleOutputFolderPath -Value $moduleOutputFolderPath +"ModuleOutputFolderPath=$moduleOutputFolderPath" >> $env:GITHUB_OUTPUT exit 0 From 108f15fb963eb339fc5356f552da64ccffbd3690 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Aug 2025 12:57:25 +0200 Subject: [PATCH 3/8] Bump actions/checkout from 4 to 5 (#116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
Release notes

Sourced from actions/checkout's releases.

v5.0.0

What's Changed

⚠️ Minimum Compatible Runner Version

v2.327.1
Release Notes

Make sure your runner is updated to this version or newer to use this release.

Full Changelog: https://github.com/actions/checkout/compare/v4...v5.0.0

v4.3.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4...v4.3.0

v4.2.2

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.2.1...v4.2.2

v4.2.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.2.0...v4.2.1

... (truncated)

Changelog

Sourced from actions/checkout's changelog.

Changelog

V5.0.0

V4.3.0

v4.2.2

v4.2.1

v4.2.0

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4&new-version=5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/Action-Test.yml | 6 +++--- .github/workflows/Auto-Release.yml | 2 +- .github/workflows/Linter.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 9b426109..54e91a3c 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Action-Test uses: ./ @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Action-Test uses: ./ @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Action-Test uses: ./ diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index 680da5c0..50a5a410 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Auto-Release uses: PSModule/Auto-Release@v1 diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index 1f677cbd..94f34b02 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: fetch-depth: 0 From eee6fb1419cac11807ed58a20e4b2fe34a5d0429 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 3 Oct 2025 23:09:33 +0200 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Dependab?= =?UTF-8?q?ot=20configuration=20to=20include=20labels=20for=20GitHub=20Act?= =?UTF-8?q?ions=20(#117)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This pull request makes a small configuration change to the Dependabot settings by adding default labels for GitHub Actions updates. * Added `dependencies` and `github-actions` labels to all GitHub Actions updates in `.github/dependabot.yml` --- .github/dependabot.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f57e1e95..53188fef 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,5 +7,8 @@ version: 2 updates: - package-ecosystem: github-actions # See documentation for possible values directory: / # Location of package manifests + labels: + - dependencies + - github-actions schedule: interval: weekly From f84654dbaaaaf319e459f962de907104ad96b83c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 12 Oct 2025 13:55:38 +0200 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Encode=20all=20Po?= =?UTF-8?q?werShell=20files=20using=20UTF8=20with=20BOM=20(#118)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This pull request makes a minor change to the `Planets.ps1` files in both test repositories. The only update is the addition of a Unicode Byte Order Mark (BOM) at the beginning of each file to ensure proper encoding. - Added a Unicode BOM to the start of `Planets.ps1` in both `srcTestRepo` and `srcWithManifestTestRepo` to enforce UTF-8 encoding. --- tests/srcTestRepo/src/variables/public/Planets.ps1 | 2 +- tests/srcWithManifestTestRepo/src/variables/public/Planets.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/srcTestRepo/src/variables/public/Planets.ps1 b/tests/srcTestRepo/src/variables/public/Planets.ps1 index 736584b9..5927bc51 100644 --- a/tests/srcTestRepo/src/variables/public/Planets.ps1 +++ b/tests/srcTestRepo/src/variables/public/Planets.ps1 @@ -1,4 +1,4 @@ -$script:Planets = @( +$script:Planets = @( @{ Name = 'Mercury' Mass = 0.330 diff --git a/tests/srcWithManifestTestRepo/src/variables/public/Planets.ps1 b/tests/srcWithManifestTestRepo/src/variables/public/Planets.ps1 index 736584b9..5927bc51 100644 --- a/tests/srcWithManifestTestRepo/src/variables/public/Planets.ps1 +++ b/tests/srcWithManifestTestRepo/src/variables/public/Planets.ps1 @@ -1,4 +1,4 @@ -$script:Planets = @( +$script:Planets = @( @{ Name = 'Mercury' Mass = 0.330 From 2a649d5ef96f085174071bdc494fa43167231989 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 15 Oct 2025 13:20:47 +0200 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Move=20documentat?= =?UTF-8?q?ion=20and=20link=20to=20Process-PSModule=20(#119)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This pull request significantly reduces and simplifies the documentation and metadata for the `Build-PSModule` GitHub Action, focusing on minimalism and removing detailed usage and implementation information. Documentation simplification: * The `README.md` file was almost entirely rewritten, removing all detailed explanations about supported module types, build steps, repository structure, manifest generation, and references. It now contains only a single line briefly describing the action and its relation to the PSModule framework. Metadata cleanup: * In `action.yml`, the action's `name` was simplified, and the `branding` section specifying the icon and color was removed to further streamline the action's metadata. --- README.md | 167 +---------------------------------------------------- action.yml | 5 +- 2 files changed, 2 insertions(+), 170 deletions(-) diff --git a/README.md b/README.md index 7cc352da..479041a5 100644 --- a/README.md +++ b/README.md @@ -1,168 +1,3 @@ # Build-PSModule -This action "compiles" the module source code into an efficient PowerShell module that is ready to be published to the PowerShell Gallery. - -This GitHub Action is a part of the [PSModule framework](https://github.com/PSModule). It is recommended to use the [Process-PSModule workflow](https://github.com/PSModule/Process-PSModule) to automate the whole process of managing the PowerShell module. - -## Supported module types - -- Script module type -- Manifest module type - -## Supported practices and principles - -- [PowerShellGallery Publishing Guidelines and Best Practices](https://learn.microsoft.com/powershell/gallery/concepts/publishing-guidelines) are followed as much as possible. - -## How it works - -During the build process the following steps are performed: - -1. **Runs local build scripts:** Searches for any `*build.ps1` files anywhere in the repository. These scripts are executed in **alphabetical order by filename** (irrespective of their path). -This step lets you add custom build logic to process or modify the module contents before further build steps are performed. -1. **Copies the source code** of the module to an output folder. -1. **Builds the module manifest file** based on information from the GitHub repository and the source code. For more information, please read the [Module Manifest](#module-manifest) section. -1. **Builds the root module (.psm1) file** by combining source code and adding automation into the root module file. For more information, please read the [Root module](#root-module) section. -1. **Uploads the module artifact** so that it can be used in the next steps of the workflow. - -## Usage - -| Name | Description | Required | Default | -| ------------------ | ------------------------------------------------------ | -------- | --------- | -| `Name` | Name of the module to process. | `false` | | -| `ArtifactName` | Name of the artifact to upload. | `false` | `module` | -| `WorkingDirectory` | The working directory where the script will run from. | `false` | `'.'` | - -## Expected repository structure - -The action expects the module repository to be structured similarly to [Template-PSModule](https://github.com/PSModule/Template-PSModule). -## Root module - -The `src` folder may contain a 'root module' file. If present, the build function will disregard this file and build a new root module file based on the source code in the module folder. - -The root module file is the main file that is loaded when the module is imported. It is built from the source code files in the module folder in the following order: - -1. Adds a module header from `header.ps1` if it exists and removes the file from the module folder. -1. Adds a data loader that loads files from the `data` folder as variables in the module scope, if the folder exists. The variables are available using the `$script:` syntax. -1. Adds content from the following folders into the root module file. The files on the root of a folder are added before recursively processing subfolders (folders are processed in alphabetical order). Once a file is processed, it is removed from the module folder. - 1. `init` - 1. `classes/private` - 1. `classes/public` - 1. `functions/private` - 1. `functions/public` - 1. `variables/private` - 1. `variables/public` - 1. `*.ps1` on module root -1. Adds a `class` and `enum` exporter that exports the ones from the `classes/public` folder to the caller session, using [TypeAccelerators](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_classes?view=powershell-7.4#exporting-classes-with-type-accelerators). -1. Adds the `Export-ModuleMember` function to the end of the file, to ensure that only the functions, cmdlets, variables and aliases defined in the `public` folders are exported. - -## Module manifest - -The module manifest file describes the module and its contents. PowerShell uses it to load the module and its prerequisites. It also contains important metadata used by the PowerShell Gallery. If a file exists in the source code folder (`src`), it will be used as the base for the module manifest file. While most values in the module manifest are calculated during the build process, some values are preserved if specified in the source manifest file. - -During the module manifest build process the following steps are performed: - -1. Get the manifest file from the source code. If it does not exist, a new manifest file is created. -1. Generate and set the `RootModule` based on the module name. -1. Set a temporary `ModuleVersion` (this is updated during the release process by [Publish-PSModule](https://github.com/PSModule/Publish-PSModule)). -1. Set the `Author` and `CompanyName` based on the GitHub Owner. If a value exists in the source manifest file, that value is used. -1. Set the `Copyright` information based on a default text (`(c) 2024 >>OwnerName<<. All rights reserved.`) and includes the `Author`, `CompanyName` or both when applicable. If a value exists in the source manifest file, that value is used. -1. Set the `Description` based on the GitHub repository description. If a value exists in the source manifest file, that value is used. -1. Set various properties such as `PowerShellHostName`, `PowerShellHostVersion`, `DotNetFrameworkVersion`, `ClrVersion`, and `ProcessorArchitecture`. If values exist in the source manifest file, those values are used. -1. Get the list of files in the module source folder and set the `FileList` property in the manifest. -1. Get the list of required assemblies (`*.dll` files) from the `assemblies` and `modules` (depth = 1) folder and set the `RequiredAssemblies` property. -1. Get the list of nested modules (`*.psm1`, `*.ps1` and `*.dll` files one level down) from the `modules` folder and set the `NestedModules` property. -1. Get the list of scripts to process (`*.ps1` files) from the `scripts` folder and set the `ScriptsToProcess` property. This ensures that the scripts are loaded into the caller session. -1. Get the list of types to process by searching for `*.Types.ps1xml` files in the entire module source folder and set the `TypesToProcess` property. -1. Get the list of formats to process by searching for `*.Format.ps1xml` files in the entire module source folder and set the `FormatsToProcess` property. -1. Get the list of DSC resources to export by searching for `*.psm1` files in the `resources` folder and set the `DscResourcesToExport` property. -1. Get the list of functions, cmdlets, aliases, and variables from the respective `\public` folders and set the respective properties in the manifest. -1. Get the list of modules by searching for all `*.psm1` files in the entire module source folder (excluding the root module) and set the `ModuleList` property. -1. Gather information from source files to update `RequiredModules`, `PowerShellVersion`, and `CompatiblePSEditions` properties. -1. Gather additional information from the GitHub repository: - - `Tags` are generated from repository topics plus compatibility tags from the source files. - - `LicenseUri` is generated assuming there is a `LICENSE` file at the repository root. If a value exists in the source manifest file, that value is used. - - `ProjectUri` is set to the GitHub repository URL. If a value exists in the source manifest file, that value is used. - - `IconUri` is generated assuming there is an `icon.png` file in the `icon` folder at the repository root. If a value exists in the source manifest file, that value is used. -1. `ReleaseNotes` are not automated (could be set via PR or release description). -1. `PreRelease` is managed externally by [Publish-PSModule](https://github.com/PSModule/Publish-PSModule). -1. `RequireLicenseAcceptance` defaults to `false` unless specified in the source manifest. -1. `ExternalModuleDependencies` is not automated. If specified in the source manifest, that value is used. -1. `HelpInfoURI` is not automated. If specified in the source manifest, that value is used. -1. Create a new manifest file in the output folder with the gathered information, which also generates a new `GUID` for the module. - -### Sources for properties in the manifest file - -Below is a list of properties in the module manifest file and their sources: - -```powershell -@{ - RootModule = 'Utilities.psm1' # Generated as .psm1 from the module name; can be overridden in the source manifest. - ModuleVersion = '0.0.1' # Temporary version set during the build; updated by Publish‑PSModule during the release process. - CompatiblePSEditions = @() # Determined from #Requires -PSEdition statements in source files.; defaults to @('Core','Desktop') if none found. - GUID = '' # New GUID generated by New‑ModuleManifest when the manifest is created. - Author = 'PSModule' # Derived from the GitHub owner unless specified in the source manifest. - CompanyName = 'PSModule' # Derived from the GitHub owner unless specified in the source manifest. - Copyright = '(c) 2024 PSModule. All rights reserved.' # Default template; overridden if specified in the source manifest. - Description = 'This is a module.' # Taken from the repository description or the source manifest. - PowerShellVersion = '' # Derived from #Requires -Version statements in source files; blank if none. - PowerShellHostName = '' # Preserved from the source manifest if provided; otherwise omitted. - PowerShellHostVersion = '' # Preserved from the source manifest if provided; otherwise omitted. - DotNetFrameworkVersion = '' # Preserved from the source manifest if provided; otherwise omitted. - ClrVersion = '' # Preserved from the source manifest if provided; otherwise omitted. - ProcessorArchitecture = '' # Preserved from the source manifest if provided; otherwise omitted. - RequiredModules = @() # Gathered from #Requires -Modules statements in source files. - RequiredAssemblies = @() # Collected from assemblies/*.dll and modules/*.dll (depth = 1). - ScriptsToProcess = @() # Collected from scripts/*.ps1, loaded alphabetically into the caller session. - TypesToProcess = @() # Collected from *.Types.ps1xml files anywhere in the source folder. - FormatsToProcess = @() # Collected from *.Format.ps1xml files anywhere in the source folder. - NestedModules = @() # Collected from modules/* (.psm1, .ps1 or .dll one level down). - FunctionsToExport = @() # Collected from functions/public/*.ps1 files. - CmdletsToExport = @() # Preserved from the source manifest if provided; empty otherwise. - VariablesToExport = @() # Collected from variables/public/*.ps1 files. - AliasesToExport = '*' # Generated from functions/public/*.ps1. - DscResourcesToExport = @() # Collected from resources/*.psm1 files. - ModuleList = @() # Informational list of all additional *.psm1 files in the module. - FileList = @() # Informational list of all files in the module source folder. - PrivateData = @{ - PSData = @{ - Tags = @() # Generated from repository topics plus compatibility tags. - LicenseUri = '' # Public link to LICENSE file (or value from source manifest). - ProjectUri = '' # Public link to the GitHub repository (or value from source manifest). - IconUri = '' # Public link to icon\icon.png (or value from source manifest). - ReleaseNotes = '' # Not automated; supply via PR or release description. - Prerelease = '' # Managed by Publish‑PSModule; populated during release. - RequireLicenseAcceptance = $false # Defaults to $false unless specified in the source manifest. - ExternalModuleDependencies = @() # Not automated; preserved if present in the source manifest. - ExperimentalFeatures = @( - @{ - Name = "SomeExperimentalFeature" - Description = "This is an experimental feature." - } - ) - } - OtherKeys = @{} - } - HelpInfoURI = '' # Not automated; preserved if provided in the source manifest. - DefaultCommandPrefix = '' # Not automated; preserved if provided in the source manifest. -} -``` - -## Permissions - -This action does not require any special permissions. - -## References - -**Module manifest:** - -- [about_Module_Manifests](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_module_manifests) -- [How to write a PowerShell module manifest](https://learn.microsoft.com/powershell/scripting/developer/module/how-to-write-a-powershell-module-manifest) -- [New-ModuleManifest](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/new-modulemanifest) -- [Update-ModuleManifest](https://learn.microsoft.com/powershell/module/powershellget/update-modulemanifest) -- [Package metadata values that impact the PowerShell Gallery UI](https://learn.microsoft.com/powershell/gallery/concepts/package-manifest-affecting-ui#powershell-gallery-feature-elements-controlled-by-the-module-manifest) -- [PowerShellGallery Publishing Guidelines and Best Practices](https://learn.microsoft.com/en-us/powershell/gallery/concepts/publishing-guidelines#tag-your-package-with-the-compatible-pseditions-and-platforms) - -**Modules:** - -- [PowerShell scripting performance considerations](https://learn.microsoft.com/powershell/scripting/dev-cross-plat/performance/script-authoring-considerations) -- [PowerShell module authoring considerations](https://learn.microsoft.com/powershell/scripting/dev-cross-plat/performance/module-authoring-considerations) +This GitHub Action is a part of the [PSModule framework](https://github.com/PSModule). diff --git a/action.yml b/action.yml index 5117c561..27a62285 100644 --- a/action.yml +++ b/action.yml @@ -1,9 +1,6 @@ -name: Build-PSModule (by PSModule) +name: Build-PSModule description: Build a PowerShell module to the PowerShell Gallery. author: PSModule -branding: - icon: package - color: gray-dark inputs: Name: From dff3bb9815b88c8ea019147fce5cbdcdb530e883 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Oct 2025 23:06:48 +0100 Subject: [PATCH 7/8] Bump actions/upload-artifact from 4 to 5 (#120) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
Release notes

Sourced from actions/upload-artifact's releases.

v5.0.0

What's Changed

BREAKING CHANGE: this update supports Node v24.x. This is not a breaking change per-se but we're treating it as such.

New Contributors

Full Changelog: https://github.com/actions/upload-artifact/compare/v4...v5.0.0

v4.6.2

What's Changed

New Contributors

Full Changelog: https://github.com/actions/upload-artifact/compare/v4...v4.6.2

v4.6.1

What's Changed

Full Changelog: https://github.com/actions/upload-artifact/compare/v4...v4.6.1

v4.6.0

What's Changed

Full Changelog: https://github.com/actions/upload-artifact/compare/v4...v4.6.0

v4.5.0

What's Changed

New Contributors

... (truncated)

Commits
  • 330a01c Merge pull request #734 from actions/danwkennedy/prepare-5.0.0
  • 03f2824 Update github.dep.yml
  • 905a1ec Prepare v5.0.0
  • 2d9f9cd Merge pull request #725 from patrikpolyak/patch-1
  • 9687587 Merge branch 'main' into patch-1
  • 2848b2c Merge pull request #727 from danwkennedy/patch-1
  • 9b51177 Spell out the first use of GHES
  • cd231ca Update GHES guidance to include reference to Node 20 version
  • de65e23 Merge pull request #712 from actions/nebuk89-patch-1
  • 8747d8c Update README.md
  • Additional commits viewable in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/upload-artifact&package-manager=github_actions&previous-version=4&new-version=5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 27a62285..a593fd52 100644 --- a/action.yml +++ b/action.yml @@ -32,7 +32,7 @@ runs: ${{ github.action_path }}/scripts/main.ps1 - name: Upload module artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: ${{ inputs.ArtifactName }} path: ${{ steps.build.outputs.ModuleOutputFolderPath }} From fe8cc14a7192066cc46cb9514659772ebde05849 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 09:23:46 +0100 Subject: [PATCH 8/8] Bump actions/checkout from 5 to 6 (#121) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
Release notes

Sourced from actions/checkout's releases.

v6.0.0

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v5.0.0...v6.0.0

v6-beta

What's Changed

Updated persist-credentials to store the credentials under $RUNNER_TEMP instead of directly in the local git config.

This requires a minimum Actions Runner version of v2.329.0 to access the persisted credentials for Docker container action scenarios.

v5.0.1

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v5...v5.0.1

Changelog

Sourced from actions/checkout's changelog.

Changelog

V6.0.0

V5.0.1

V5.0.0

V4.3.1

V4.3.0

v4.2.2

v4.2.1

v4.2.0

v4.1.7

v4.1.6

v4.1.5

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=5&new-version=6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/Action-Test.yml | 6 +++--- .github/workflows/Auto-Release.yml | 2 +- .github/workflows/Linter.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 54e91a3c..6799002c 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Action-Test uses: ./ @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Action-Test uses: ./ @@ -51,7 +51,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Action-Test uses: ./ diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index 50a5a410..976b40c7 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Auto-Release uses: PSModule/Auto-Release@v1 diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index 94f34b02..19626293 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0