-
Notifications
You must be signed in to change notification settings - Fork 0
🩹 [Patch]: Actions are internalized and automatically follow the workflow version #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Marius Storhaug (MariusStorhaug)
merged 8 commits into
main
from
feat/internalize-process-actions
Jul 16, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b92a861
feat: internalize Process-PSModule actions
MariusStorhaug aecf28e
docs: describe bundled workflow actions
MariusStorhaug 4e20b09
refactor: format TestData structure in workflow files for clarity
MariusStorhaug b41d5a9
chore: centrally ignore job.workflow_* lint errors and allow Write-Host
MariusStorhaug d5b1020
Refactor GitHub Actions for PSModule:
MariusStorhaug 5358498
feat: add Initialize-PSModule action with README and main script
MariusStorhaug 761da24
fix: update script path in Resolve-PSModuleVersion action
MariusStorhaug 42cf15d
fix: correct environment variable name for GitHub Actions validation
MariusStorhaug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| name: Build-PSModule | ||
| description: Build a PowerShell module to the PowerShell Gallery. | ||
| author: PSModule | ||
|
|
||
| inputs: | ||
| Name: | ||
| description: Name of the module to build. Defaults to the repository name. | ||
| required: false | ||
| OutputFolder: | ||
| description: Path to the folder where the built module is outputted. | ||
| required: false | ||
| default: 'outputs/module' | ||
| Version: | ||
| description: Module version to stamp into the manifest. | ||
| required: true | ||
| Prerelease: | ||
| description: Prerelease tag to stamp into the manifest's `PrivateData.PSData.Prerelease`. When empty, no prerelease tag is written. | ||
| required: false | ||
| ArtifactName: | ||
| description: Name of the artifact to upload. | ||
| required: false | ||
| default: module | ||
| WorkingDirectory: | ||
| description: The working directory where the script will run from. | ||
| required: false | ||
| default: '.' | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install-PSModuleHelpers | ||
| uses: ./_wf/.github/actions/Install-PSModuleHelpers | ||
|
|
||
| - name: Run Build-PSModule | ||
| shell: pwsh | ||
| id: build | ||
| working-directory: ${{ inputs.WorkingDirectory }} | ||
| env: | ||
| PSMODULE_BUILD_PSMODULE_INPUT_Name: ${{ inputs.Name }} | ||
| PSMODULE_BUILD_PSMODULE_INPUT_OutputFolder: ${{ inputs.OutputFolder }} | ||
| PSMODULE_BUILD_PSMODULE_INPUT_Version: ${{ inputs.Version }} | ||
| PSMODULE_BUILD_PSMODULE_INPUT_Prerelease: ${{ inputs.Prerelease }} | ||
| run: | | ||
| # Build-PSModule | ||
| ${{ github.action_path }}/src/main.ps1 | ||
Check warningCode scanning / CodeQL Code injection Medium
Potential code injection in
${ github.action_path } Error loading related location Loading |
||
|
|
||
| - name: Upload module artifact | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: ${{ inputs.ArtifactName }} | ||
| path: ${{ steps.build.outputs.ModuleOutputFolderPath }} | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
60 changes: 60 additions & 0 deletions
60
.github/actions/Build-PSModule/src/helpers/Build-PSModule.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| function Build-PSModule { | ||
| <# | ||
| .SYNOPSIS | ||
| Builds a module. | ||
|
|
||
| .DESCRIPTION | ||
| Builds a module. | ||
| #> | ||
| [OutputType([void])] | ||
| [CmdletBinding()] | ||
| [Diagnostics.CodeAnalysis.SuppressMessageAttribute( | ||
| 'PSReviewUnusedParameter', '', Scope = 'Function', | ||
| Justification = 'LogGroup - Scoping affects the variables line of sight.' | ||
| )] | ||
| [Diagnostics.CodeAnalysis.SuppressMessageAttribute( | ||
| 'PSAvoidUsingWriteHost', '', Scope = 'Function', | ||
| Justification = 'Want to just write to the console, not the pipeline.' | ||
| )] | ||
| param( | ||
| # Name of the module. | ||
| [Parameter(Mandatory)] | ||
| [string] $ModuleName, | ||
|
|
||
| # Path to the folder where the modules are located. | ||
| [Parameter(Mandatory)] | ||
| [string] $ModuleSourceFolderPath, | ||
|
|
||
| # Path to the folder where the built modules are outputted. | ||
| [Parameter(Mandatory)] | ||
| [string] $ModuleOutputFolderPath, | ||
|
|
||
| # Module version to stamp into the manifest. | ||
| [Parameter(Mandatory)] | ||
| [string] $ModuleVersion, | ||
|
|
||
| # Prerelease tag to stamp into the manifest. When empty, no prerelease tag is written. | ||
| [Parameter()] | ||
| [string] $ModulePrerelease | ||
| ) | ||
|
|
||
| Set-GitHubLogGroup "Building module [$ModuleName]" { | ||
| $moduleSourceFolder = Get-Item -Path $ModuleSourceFolderPath | ||
| $moduleOutputFolder = New-Item -Path $ModuleOutputFolderPath -Name $ModuleName -ItemType Directory -Force | ||
| [pscustomobject]@{ | ||
| ModuleSourceFolderPath = $moduleSourceFolder | ||
| ModuleOutputFolderPath = $moduleOutputFolder | ||
| } | Format-List | Out-String | ||
| } | ||
|
|
||
| Build-PSModuleBase -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder | ||
| Build-PSModuleManifest -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder ` | ||
| -ModuleVersion $ModuleVersion -ModulePrerelease $ModulePrerelease | ||
| Build-PSModuleRootModule -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder | ||
| Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder | ||
|
|
||
| Set-GitHubLogGroup 'Build manifest file - Final Result' { | ||
| $outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1" | ||
| Show-FileContent -Path $outputManifestPath | ||
| } | ||
| } |
66 changes: 66 additions & 0 deletions
66
.github/actions/Build-PSModule/src/helpers/Build/Add-ContentFromItem.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| function Add-ContentFromItem { | ||
| <# | ||
| .SYNOPSIS | ||
| Add the content of a folder or file to the root module file. | ||
|
|
||
| .DESCRIPTION | ||
| This function will add the content of a folder or file to the root module file. | ||
|
|
||
| .EXAMPLE | ||
| Add-ContentFromItem -Path 'C:\MyModule\src\MyModule' -RootModuleFilePath 'C:\MyModule\src\MyModule.psm1' -RootPath 'C:\MyModule\src' | ||
| #> | ||
| param( | ||
| # The path to the folder or file to process. | ||
| [Parameter(Mandatory)] | ||
| [string] $Path, | ||
|
|
||
| # The path to the root module file. | ||
| [Parameter(Mandatory)] | ||
| [string] $RootModuleFilePath, | ||
|
|
||
| # The root path of the module. | ||
| [Parameter(Mandatory)] | ||
| [string] $RootPath | ||
| ) | ||
| # Get the path separator for the current OS | ||
| $pathSeparator = [System.IO.Path]::DirectorySeparatorChar | ||
|
|
||
| $relativeFolderPath = $Path -replace $RootPath, '' | ||
| $relativeFolderPath = $relativeFolderPath -replace $file.Extension, '' | ||
| $relativeFolderPath = $relativeFolderPath.TrimStart($pathSeparator) | ||
| $relativeFolderPath = $relativeFolderPath -split $pathSeparator | ForEach-Object { "[$_]" } | ||
| $relativeFolderPath = $relativeFolderPath -join ' - ' | ||
|
|
||
| Add-Content -Path $RootModuleFilePath -Force -Value @" | ||
| #region $relativeFolderPath | ||
| Write-Debug "[`$scriptName] - $relativeFolderPath - Processing folder" | ||
| "@ | ||
|
|
||
| $files = $Path | Get-ChildItem -File -Force -Filter '*.ps1' | Sort-Object -Property FullName | ||
| foreach ($file in $files) { | ||
| $relativeFilePath = $file.FullName -replace $RootPath, '' | ||
| $relativeFilePath = $relativeFilePath -replace $file.Extension, '' | ||
| $relativeFilePath = $relativeFilePath.TrimStart($pathSeparator) | ||
| $relativeFilePath = $relativeFilePath -split $pathSeparator | ForEach-Object { "[$_]" } | ||
| $relativeFilePath = $relativeFilePath -join ' - ' | ||
|
|
||
| Add-Content -Path $RootModuleFilePath -Force -Value @" | ||
| #region $relativeFilePath | ||
| Write-Debug "[`$scriptName] - $relativeFilePath - Importing" | ||
| "@ | ||
| Get-Content -Path $file.FullName | Add-Content -Path $RootModuleFilePath -Force | ||
| Add-Content -Path $RootModuleFilePath -Value @" | ||
| Write-Debug "[`$scriptName] - $relativeFilePath - Done" | ||
| #endregion $relativeFilePath | ||
| "@ | ||
| } | ||
|
|
||
| $subFolders = $Path | Get-ChildItem -Directory -Force | Sort-Object -Property Name | ||
| foreach ($subFolder in $subFolders) { | ||
| Add-ContentFromItem -Path $subFolder.FullName -RootModuleFilePath $RootModuleFilePath -RootPath $RootPath | ||
| } | ||
| Add-Content -Path $RootModuleFilePath -Force -Value @" | ||
| Write-Debug "[`$scriptName] - $relativeFolderPath - Done" | ||
| #endregion $relativeFolderPath | ||
| "@ | ||
| } |
47 changes: 47 additions & 0 deletions
47
.github/actions/Build-PSModule/src/helpers/Build/Build-PSModuleBase.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| function Build-PSModuleBase { | ||
| <# | ||
| .SYNOPSIS | ||
| Compiles the base module files. | ||
|
|
||
| .DESCRIPTION | ||
| This function will compile the base module files. | ||
| It will copy the source files to the output folder and remove the files that are not needed. | ||
|
|
||
| .EXAMPLE | ||
| Build-PSModuleBase -SourceFolderPath 'C:\MyModule\src\MyModule' -OutputFolderPath 'C:\MyModule\build\MyModule' | ||
| #> | ||
| [CmdletBinding()] | ||
| [Diagnostics.CodeAnalysis.SuppressMessageAttribute( | ||
| 'PSReviewUnusedParameter', '', Scope = 'Function', | ||
| Justification = 'LogGroup - Scoping affects the variables line of sight.' | ||
| )] | ||
| [Diagnostics.CodeAnalysis.SuppressMessageAttribute( | ||
| 'PSAvoidUsingWriteHost', '', Scope = 'Function', | ||
| Justification = 'Want to just write to the console, not the pipeline.' | ||
| )] | ||
| param( | ||
| # Name of the module. | ||
| [Parameter(Mandatory)] | ||
| [string] $ModuleName, | ||
|
|
||
| # Path to the folder where the module source code is located. | ||
| [Parameter(Mandatory)] | ||
| [System.IO.DirectoryInfo] $ModuleSourceFolder, | ||
|
|
||
| # Path to the folder where the built modules are outputted. | ||
| [Parameter(Mandatory)] | ||
| [System.IO.DirectoryInfo] $ModuleOutputFolder | ||
| ) | ||
|
|
||
| Set-GitHubLogGroup 'Build base' { | ||
| $relModuleSourceFolder = $ModuleSourceFolder | Resolve-Path -Relative | ||
| $relModuleOutputFolder = $ModuleOutputFolder | Resolve-Path -Relative | ||
| Write-Host "Copying files from [$relModuleSourceFolder] to [$relModuleOutputFolder]" | ||
| Copy-Item -Path "$ModuleSourceFolder\*" -Destination $ModuleOutputFolder -Recurse -Force -Exclude "$ModuleName.psm1" | ||
| $null = New-Item -Path $ModuleOutputFolder -Name "$ModuleName.psm1" -ItemType File -Force | ||
| } | ||
|
|
||
| Set-GitHubLogGroup 'Build base - Result' { | ||
| Get-ChildItem -Path $ModuleOutputFolder -Recurse -Force | Resolve-Path -Relative | Sort-Object | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.