Minimal PowerShell module template with build, test, docs, and publish automation.
Click Use this template on GitHub to create your own module repo from this one.
Invoke-Buildpipeline (template.build.ps1)- Module packaging with
ModuleBuilder(Source/ModuleBuilder.ps1) - Pester tests (
Tests/) - Markdown help generation with
platyPS(Docs/) - GitHub Actions workflow that builds, creates a GitHub Release, and optionally publishes to the PowerShell Gallery on every version tag push (
.github/workflows/publish.yml)
Rename Source/NewModule.psm1 and Source/NewModule.psd1 to your module name, then update the manifest (Source/YourModule.psd1):
RootModule— match the.psm1filenameModuleVersion,GUID,Author,CompanyName,DescriptionTags,ProjectUri,LicenseUriFunctionsToExport/CmdletsToExport/AliasesToExport
Open .github/workflows/publish.yml and replace both occurrences of MODULE_NAME with your module name:
Compress-Archive -Path .\Output\YourModule ...
Publish-Module -Path .\Output\YourModule ....\Install-Requirements.ps1Installs required modules using min/max version ranges:
ModuleBuilder(3.1.8 - 4.x)Pester(5.7.0 - 6.x)InvokeBuild(5.14.23 - 6.x)platyPS(0.14.2 - 1.x)
Run Local build (compile + import + docs):
.\template.build.ps1 -Type LocalRun Full pipeline (compile + import + tests):
.\template.build.ps1 -Type FullRun an individual task:
Invoke-Build -Task BuildModule
Invoke-Build -Task RunTests
Invoke-Build -Task GenerateMarkdownDocsSource/— module source (.psm1,.psd1,Public/,Private/)Output/— built artifact (git-ignored)Tests/— Pester testsDocs/— generated markdown help
The publish workflow fires automatically when a version tag is pushed. To enable Gallery publishing:
- Generate an API key at powershellgallery.com
- Add it as a repository secret named
PSGALLERY_API_KEYin GitHub > Settings > Secrets and variables > Actions
If PSGALLERY_API_KEY is not set the workflow still runs — it builds, tests, and creates the GitHub Release, but skips the Gallery publish step.
# Commit and push your changes first
git add .
git commit -m "[feat] add my new feature"
git push origin main
# Tag the release — this triggers the publish workflow **NOTE** Make sure you are updating your versioning
git tag -a v1.1.0 -m "Release v1.0.0"
git push origin v1.1.0Pushing the tag triggers .github/workflows/publish.yml, which:
- Installs dependencies
- Runs the full build pipeline (the tag version number is extracted and passed in as
-Version) - Zips the
Output/<ModuleName>folder - Creates a GitHub Release with auto-generated release notes and the zip attached
- Publishes to the PowerShell Gallery (if
PSGALLERY_API_KEYis set)
If you need to re-run a release after fixing something:
# Delete the tag locally and on remote, then re-create it
git tag -d v1.0.1
git push origin :refs/tags/v1.0.1
git tag -a v1.0.1 -m "Release v1.0.1"
git push origin v1.0.1- Tests import the built module from
Output/, notSource/— always run a build before running tests. - Markdown help generation depends on
ModuleImportso the module name is available at doc-gen time.