Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ jobs:
}
[void] (New-ModuleManifest @Params)

- name: Rename prefix file to match module name
run: |
MODULE_NAME=${{ github.event.repository.name }}
git mv src/PSScriptModule.prefix.ps1 "src/$MODULE_NAME.prefix.ps1"

- name: Rename suffix file to match module name
run: |
MODULE_NAME=${{ github.event.repository.name }}
git mv src/PSScriptModule.suffix.ps1 "src/$MODULE_NAME.suffix.ps1"

- name: Update README.md
run: |
OWNER=${{ github.repository_owner }}
Expand Down Expand Up @@ -217,4 +227,3 @@ jobs:
}
}
}

34 changes: 18 additions & 16 deletions PSScriptModule.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ param (
)

# Synopsis: Default task
task . Clean, Build
Task . Clean, Build

# Setup build environment
Enter-Build {
Expand All @@ -36,7 +36,7 @@ Enter-Build {
}

# Synopsis: Analyze the project with PSScriptAnalyzer
task PSScriptAnalyzer {
Task PSScriptAnalyzer {
if (-not (Test-Path $testOutputPath)) {
[void] (New-Item -Path $testOutputPath -ItemType Directory)
}
Expand All @@ -57,7 +57,7 @@ task PSScriptAnalyzer {
}

# Synopsis: Scan the project with Injection Hunter
task InjectionHunter {
Task InjectionHunter {

$config = New-PesterConfiguration @{
Run = @{
Expand All @@ -75,7 +75,7 @@ task InjectionHunter {
}

# Synopsis: Run unit tests and generate code coverage report
task UnitTests {
Task UnitTests {

$container = New-PesterContainer -Path $Script:moduleSourcePath -Data @{ SourcePath = $script:moduleSourcePath }
$config = New-PesterConfiguration @{
Expand All @@ -102,7 +102,7 @@ task UnitTests {
}

# Synopsis: Run integration tests on built module
task IntegrationTests {
Task IntegrationTests {
if (-not (Test-Path $testOutputPath)) {
[void] (New-Item -Path $testOutputPath -ItemType Directory)
}
Expand Down Expand Up @@ -136,10 +136,10 @@ task IntegrationTests {
}

# Synopsis: Run all tests
task Test UnitTests, PSScriptAnalyzer, InjectionHunter
Task Test UnitTests, PSScriptAnalyzer, InjectionHunter

# Synopsis: Generate module help documentation
task Export-CommandHelp {
Task Export-CommandHelp {

# Import the module being built and PlatyPS module
[void] (Import-Module (Join-Path -Path $buildPath -ChildPath "out/$moduleName/$moduleName.psd1") -Force)
Expand Down Expand Up @@ -182,7 +182,7 @@ task Export-CommandHelp {
}

# Synopsis: Build the project
task Build Clean, {
Task Build Clean, {

# Copy src directory to ./build folder
$requestParam = @{
Expand All @@ -206,17 +206,19 @@ task Build Clean, {
# Build Powershell module
[void] (Import-Module ModuleBuilder)
$requestParam = @{
Path = (Join-Path -Path $buildPath -ChildPath "src/$moduleName.psd1")
SourcePath = (Join-Path -Path $buildPath -ChildPath "src/$moduleName.psd1")
OutputDirectory = (Join-Path -Path $buildPath -ChildPath "out/$moduleName")
Prefix = if (Test-Path (Join-Path -Path $buildPath -ChildPath "src/$moduleName.prefix.ps1")) { (Join-Path -Path $buildPath -ChildPath "src/$moduleName.prefix.ps1") } else { $null }
Suffix = if (Test-Path (Join-Path -Path $buildPath -ChildPath "src/$moduleName.suffix.ps1")) { (Join-Path -Path $buildPath -ChildPath "src/$moduleName.suffix.ps1") } else { $null }
SemVer = $SemanticVersion
UnversionedOutputDirectory = $true
ErrorAction = 'Stop'
ErrorAction = [System.Management.Automation.ActionPreference]::Stop
}
Build-Module @requestParam
}

# Synopsis: Create a NuGet package for the module
task Package {
Task Package {
$packageOutputPath = Join-Path -Path $buildPath -ChildPath 'package'
if (!(Test-Path $packageOutputPath)) {
[void] (New-Item -Path $packageOutputPath -ItemType Directory -Force)
Expand All @@ -227,15 +229,15 @@ task Package {
SourceLocation = $packageOutputPath
PublishLocation = $packageOutputPath
InstallationPolicy = 'Trusted'
ErrorAction = 'Stop'
ErrorAction = [System.Management.Automation.ActionPreference]::Stop
}
[void] (Register-PSRepository @requestParam)

$requestParam = @{
Path = (Join-Path -Path $buildPath -ChildPath "out/$moduleName")
Repository = "$($moduleName)_local_feed"
NuGetApiKey = 'ABC123'
ErrorAction = 'Stop'
ErrorAction = [System.Management.Automation.ActionPreference]::Stop
}
[void] (Publish-Module @requestParam)

Expand All @@ -244,17 +246,17 @@ task Package {
}

# Synopsis: Publish the module to PSGallery
task Publish -If ($NugetApiKey) {
Task Publish -If ($NugetApiKey) {
$requestParam = @{
Path = (Join-Path -Path $buildPath -ChildPath "out/$moduleName")
NuGetApiKey = $NugetApiKey
ErrorAction = 'Stop'
ErrorAction = [System.Management.Automation.ActionPreference]::Stop
}
[void] (Publish-Module @requestParam)
}

# Synopsis: Clean up the target build directory
task Clean {
Task Clean {
if (Test-Path $buildPath) {
Write-Warning "Removing build output folder at '$buildPath'"
$requestParam = @{
Expand Down
Empty file added src/Classes/.gitkeep
Empty file.
Empty file added src/Enum/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions src/PSScriptModule.prefix.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<# Code inserted in this file will be placed at the top of the .PSM1 file generated by ModuleBuilder #>
<# Delete this file if not needed for your module #>
<# Delete these comments if you don't want them in your module #>
3 changes: 3 additions & 0 deletions src/PSScriptModule.suffix.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<# Code inserted in this file will be placed at the bottom of the .PSM1 file generated by ModuleBuilder #>
<# Delete this file if not needed for your module #>
<# Delete these comments if you don't want them in your module #>