PsBuildTasks

Reusable sources for build, test, release automation of PowerShell modules, written in DotNet/C# or PowerShell.

View the Project on GitHub abbgrade/PsBuildTasks

GitHub Actions workflows

It provides the following workflows:

It depends on a convention for branch names. These are based on the default settings of the git-flow git extension.

Usage

Build Validation Workflow

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"
}

Pre-Release Workflow

This workflow runs on pushes to release/* branches or when manually started from the Actions tab, and publishes a prerelease to PowerShell Gallery.

  1. Execute the following snippet to initialize or update the pre-release workflow:
task UpdatePreReleaseWorkflow {
    Invoke-WebRequest `
        -Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/pre-release-windows.yml' `
        -OutFile "$PSScriptRoot\.github\workflows\pre-release.yml"
}
  1. Update the module-name input in the workflow.
  2. Configure the repository secret PS_GALLERY_KEY with a PowerShell Gallery API key.

Hotfix Release Workflow

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.

  1. Add the hotfix workflow to your repository:
task UpdateHotfixReleaseWorkflow {
    Invoke-WebRequest `
        -Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/release-hotfix-windows.yml' `
        -OutFile "$PSScriptRoot\.github\workflows\release-hotfix.yml"
}
  1. Update the module-name input in the workflow.
  2. Configure the repository secret PS_GALLERY_KEY with a PowerShell Gallery API key.

Release Workflow

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.

  1. Execute the following snippet to initialize or update the release workflow:
task UpdateReleaseWorkflow {
    Invoke-WebRequest `
        -Uri 'https://raw.githubusercontent.com/abbgrade/PsBuildTasks/main/GitHub/release-windows.yml' `
        -OutFile "$PSScriptRoot\.github\workflows\release.yml"
}
  1. Update the module-name input in the workflow.
  2. Configure the repository secret PS_GALLERY_KEY with a PowerShell Gallery API key.