Reusable sources for build, test, release automation of PowerShell modules, written in DotNet/C# or PowerShell.
It provides the following workflows:
build-validation-matrix.yml <- runs matrix-based build and Pester validation and creates a test report. Runs on pushes to develop, bugfix/*, feature/*, release/*, and dependabot/*, pull requests to develop, or manual dispatch.build-validation-windows.yml <- runs Windows build and test validation on the same branches and pull requests, or by manual dispatch.pre-release-windows.yml <- builds and publishes a prerelease to PowerShell Gallery on pushes to release/* or by manual dispatch.release-windows.yml <- builds and publishes a release to PowerShell Gallery on pushes to main or by manual dispatch; publication is not forced.release-hotfix-windows.yml <- publishes hotfixes to PowerShell Gallery on pushes to hotfix/* or by manual dispatch, with publication forced.It depends on a convention for branch names. These are based on the default settings of the git-flow git extension.
InstallBuildDependencies task which installs modules required to build the module.Build task that builds the module into the publish directory.InstallTestDependencies task which installs modules required to test the module.test directory.InstallReleaseDependencies task which installs modules required to import/publish the module.Both validation workflows run on pushes to develop, bugfix/*, feature/*, release/*, and dependabot/*, on pull requests targeting develop, and when manually started from the Actions tab.
When manually starting either validation workflow, use the verbose option to choose whether PowerShell Write-Verbose messages from tested code are shown. It is disabled by default.
Add the following task to your .build.ps1 file to create/update the matrix validation workflow:
task UpdateValidationWorkflow {
Invoke-WebRequest `
-Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/build-validation-matrix.yml' `
-OutFile "$PSScriptRoot\.github\workflows\build-validation.yml"
}
To use the Windows-only validation workflow instead, add:
task UpdateValidationWindowsWorkflow {
Invoke-WebRequest `
-Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/build-validation-windows.yml' `
-OutFile "$PSScriptRoot\.github\workflows\build-validation-windows.yml"
}
This workflow runs on pushes to release/* branches or when manually started from the Actions tab, and publishes a prerelease to PowerShell Gallery.
task UpdatePreReleaseWorkflow {
Invoke-WebRequest `
-Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/pre-release-windows.yml' `
-OutFile "$PSScriptRoot\.github\workflows\pre-release.yml"
}
module-name input in the workflow.PS_GALLERY_KEY with a PowerShell Gallery API key.This workflow runs on pushes to hotfix/* branches or when manually started from the Actions tab. It uses the release workflow with force-publish set to true.
task UpdateHotfixReleaseWorkflow {
Invoke-WebRequest `
-Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/release-hotfix-windows.yml' `
-OutFile "$PSScriptRoot\.github\workflows\release-hotfix.yml"
}
module-name input in the workflow.PS_GALLERY_KEY with a PowerShell Gallery API key.This workflow runs on pushes to main or when manually started from the Actions tab. Its force-publish input is false, allowing the reusable workflow to decide whether to publish.
task UpdateReleaseWorkflow {
Invoke-WebRequest `
-Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/release-windows.yml' `
-OutFile "$PSScriptRoot\.github\workflows\release.yml"
}
module-name input in the workflow.PS_GALLERY_KEY with a PowerShell Gallery API key.