Update Build Process Versions and Steps

This commit is contained in:
Wes Carroll
2019-07-10 21:10:13 -04:00
parent 46951b76ba
commit 7f5fb6c1ac
2 changed files with 72 additions and 40 deletions
+3 -3
View File
@@ -7,7 +7,7 @@
SkipPublisherCheck = $true SkipPublisherCheck = $true
} }
Target = 'CurrentUser' Target = 'CurrentUser'
Version = '5.5.1' Version = '5.5.2'
Tags = 'Bootstrap' Tags = 'Bootstrap'
} }
@@ -19,7 +19,7 @@
SkipPublisherCheck = $true SkipPublisherCheck = $true
} }
Target = 'CurrentUser' Target = 'CurrentUser'
Version = '4.7.3' Version = '4.8.1'
Tags = 'Bootstrap' Tags = 'Bootstrap'
} }
@@ -31,7 +31,7 @@
SkipPublisherCheck = $true SkipPublisherCheck = $true
} }
Target = 'CurrentUser' Target = 'CurrentUser'
Version = '1.18.0' Version = '1.18.1'
Tags = 'Bootstrap' Tags = 'Bootstrap'
} }
+69 -37
View File
@@ -2,8 +2,26 @@
$version = "{0}.{1}" -f $(Get-Content .\version.txt), $(Get-Date -format 'yyyyMMdd') $version = "{0}.{1}" -f $(Get-Content .\version.txt), $(Get-Date -format 'yyyyMMdd')
#Define the default task
task . CreateArtifacts task . CreateArtifacts
#Region - Helper Functions
function ImportRawModule() {
If (Get-Module -Name ZertoApiWrapper) {
Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop
}
Import-Module "$BuildRoot\ZertoApiWrapper\ZertoApiWrapper.psd1" -ErrorAction Stop
}
function ImportBuiltModule() {
If (Get-Module -Name ZertoApiWrapper) {
Remove-Module -Name ZertoApiWrapper -Force -ErrorAction Stop
}
Import-Module "$BuildRoot\temp\ZertoApiWrapper.psd1" -ErrorAction Stop
}
#EndRegion
#Region - Module Checks
<# Synopsis: Ensure platyPS is installed #> <# Synopsis: Ensure platyPS is installed #>
task CheckPlatyPSInstalled { task CheckPlatyPSInstalled {
if ($null -eq (Get-Module -List platyPS)) { if ($null -eq (Get-Module -List platyPS)) {
@@ -24,7 +42,9 @@ task CheckPSScriptAnalyzerInstalled {
Install-Module -Scope CurrentUser -Repository PSGallery -Name PSScriptAnalyzer Install-Module -Scope CurrentUser -Repository PSGallery -Name PSScriptAnalyzer
} }
} }
#EndRegion
#Region - PSSA Tasks
<# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #> <# Synopsis: Analyze ZertoApiWrapper functions for Code Violations #>
task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, { task AnalyzeSourceFiles CheckPSScriptAnalyzerInstalled, {
$scriptAnalyzerParams = @{ $scriptAnalyzerParams = @{
@@ -56,14 +76,42 @@ task AnalyzeBuiltFiles CheckPSScriptAnalyzerInstalled, CreatePsm1ForRelease, {
throw "One or more PSScriptAnalyzer errors/warnings were found" throw "One or more PSScriptAnalyzer errors/warnings were found"
} }
} }
#EndRegion
task FileTests CheckPesterInstalled, { #Region - Clean Operations
$testResultsFile = "$BuildRoot\Tests\TestResults.xml" task CleanTemp {
if (-not $(Test-Path "$BuildRoot\temp")) {
New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory"
}
Remove-Item -Recurse -Path "$BuildRoot\temp\*"
}
task CleanPublish {
if ($(Test-Path "$BuildRoot\publish")) {
Remove-Item -Recurse -Path "$BuildRoot\publish\*"
}
}
#EndRegion
#Region - Pester Tests
task RawFileTests CheckPesterInstalled, {
ImportRawModule
$testResultsFile = "$BuildRoot\Tests\RawTestResults.xml"
$script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails $script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails
$FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount $FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
Assert ($results.FailedCount -eq 0) $FailureMessage Assert ($results.FailedCount -eq 0) $FailureMessage
} }
task BuiltFileTests CheckPesterInstalled, {
ImportBuiltModule
$testResultsFile = "$BuildRoot\Tests\BuiltTestResults.xml"
$script:results = Invoke-Pester -Script "$BuildRoot" -Tag Unit -OutputFile $testResultsFile -PassThru -Show Fails
$FailureMessage = '{0} Unit test(s) failed. Aborting build' -f $results.FailedCount
Assert ($results.FailedCount -eq 0) $FailureMessage
}
#EndRegion
#Region - Build Help System
$buildMamlParams = @{ $buildMamlParams = @{
Inputs = { Get-ChildItem docs\*.md } Inputs = { Get-ChildItem docs\*.md }
Outputs = "$BuildRoot\temp\en-us\ZertoApiWrapper-help.xml" Outputs = "$BuildRoot\temp\en-us\ZertoApiWrapper-help.xml"
@@ -77,17 +125,12 @@ task BuildMamlHelp CheckPlatyPSInstalled, {
} }
task UpdateMarkdownHelp CheckPlatyPSInstalled, { task UpdateMarkdownHelp CheckPlatyPSInstalled, {
Remove-Module ZertoApiWrapper -force -ErrorAction SilentlyContinue ImportRawModule
Import-Module .\ZertoApiWrapper\ZertoApiWrapper.psm1 -Force
Update-MarkdownHelp -Path docs -AlphabeticParamsOrder
}
task UpdateMarkdownHelpModule CheckPlatyPSInstalled, {
Remove-Module ZertoApiWrapper -force -ErrorAction SilentlyContinue
Import-Module .\ZertoApiWrapper\ZertoApiWrapper.psm1 -Force
Update-MarkdownHelpModule -Path docs -AlphabeticParamsOrder Update-MarkdownHelpModule -Path docs -AlphabeticParamsOrder
} }
#EndRegion
#Region - Build Module Files
task CreatePsd1ForRelease CleanTemp, { task CreatePsd1ForRelease CleanTemp, {
$functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName } $functionsToExport = Get-ChildItem -Path 'ZertoApiWrapper\Public\*.ps1' | ForEach-Object { $_.BaseName }
$releaseNotes = "# {0}{1}" -f $version, $(Get-Content .\RELEASENOTES.md -Raw) $releaseNotes = "# {0}{1}" -f $version, $(Get-Content .\RELEASENOTES.md -Raw)
@@ -114,20 +157,14 @@ task CreatePsd1ForRelease CleanTemp, {
New-ModuleManifest @ManifestParams New-ModuleManifest @ManifestParams
} }
task CleanTemp {
if (-not $(Test-Path "$BuildRoot\temp")) {
New-Item -Path $BuildRoot -Name "temp" -ItemType "Directory"
}
Remove-Item -Recurse -Path "$BuildRoot\temp\*"
}
task CreatePsm1ForRelease CreatePsd1ForRelease, { task CreatePsm1ForRelease CreatePsd1ForRelease, {
$emptyLine = "" $emptyLine = ""
$psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1" $psm1Path = "$BuildRoot\temp\ZertoApiWrapper.psm1"
$lines = '#------------------------------------------------------------#' $lines = '#------------------------------------------------------------#'
$Public = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction SilentlyContinue ) $Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction Stop )
$functionCount = 0 $Public = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Public\*.ps1 -ErrorAction Stop )
$exportString = "" <# $functionCount = 0
$exportString = ""
foreach ($file in $Public) { foreach ($file in $Public) {
if ($functionCount -eq 0) { if ($functionCount -eq 0) {
$functionCount++ $functionCount++
@@ -136,8 +173,7 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, {
$functionCount++ $functionCount++
$exportString = "{0}, {1}" -f $exportString, $file.BaseName $exportString = "{0}, {1}" -f $exportString, $file.BaseName
} }
} } #>
$Private = @( Get-ChildItem -Path $BuildRoot\ZertoApiWrapper\Private\*.ps1 -ErrorAction SilentlyContinue )
Add-Content -Path $psm1Path -Value $lines Add-Content -Path $psm1Path -Value $lines
Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#" Add-Content -Path $psm1Path -Value "#---------------------Private Functions----------------------#"
Add-Content -Path $psm1Path -Value $lines Add-Content -Path $psm1Path -Value $lines
@@ -154,27 +190,23 @@ task CreatePsm1ForRelease CreatePsd1ForRelease, {
Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw) Add-Content -Path $psm1Path -Value $(Get-Content -Path $file.Fullname -Raw)
Add-Content -Path $psm1Path -Value $emptyLine Add-Content -Path $psm1Path -Value $emptyLine
} }
Add-Content -Path $psm1Path -Value $emptyLine # Add-Content -Path $psm1Path -Value $emptyLine
Add-Content -Path $psm1Path -Value "Export-ModuleMember -Function $exportString" # Add-Content -Path $psm1Path -Value "Export-ModuleMember -Function $exportString"
} }
#EndRegion
task CreateArtifacts CleanPublish, CreateModule, { #Region - Artifacts \ Publish
# Full Build Process - No Publishing
task CreateArtifacts CleanPublish, CleanTemp, AnalyzeSourceFiles, RawFileTests, AnalyzeBuiltFiles, BuiltFileTests, BuildMamlHelp, {
if (-not $(Test-Path "$BuildRoot\publish")) { if (-not $(Test-Path "$BuildRoot\publish")) {
New-Item -Path $BuildRoot -Name "publish" -ItemType Directory New-Item -Path $BuildRoot -Name "publish" -ItemType Directory
} }
Compress-Archive -Path .\temp\* -DestinationPath .\publish\ZertoApiWrapper.zip Compress-Archive -Path .\temp\* -DestinationPath .\publish\ZertoApiWrapper.zip
Get-Module -Name ZertoApiWrapper | Remove-Module -Force ImportBuiltModule
Import-Module .\temp\ZertoApiWrapper.psd1 -Force
(Get-Module ZertoApiWrapper).ReleaseNotes | Add-Content .\publish\release-notes.txt (Get-Module ZertoApiWrapper).ReleaseNotes | Add-Content .\publish\release-notes.txt
(Get-Module ZertoApiWrapper).Version.ToString() | Add-Content .\publish\release-version.txt (Get-Module ZertoApiWrapper).Version.ToString() | Add-Content .\publish\release-version.txt
Copy-Item "$BuildRoot\ZertoApiWrapper.build.ps1" "$BuildRoot\publish\ZertoApiWrapper.build.ps1"
Copy-Item "$BuildRoot\ZertoApiWrapper.Depend.psd1" "$BuildRoot\publish\ZertoApiWrapper.Depend.psd1"
Copy-Item "$BuildRoot\build.ps1" "$BuildRoot\publish\build.ps1"
} }
#EndRegion
task CleanPublish {
if ($(Test-Path "$BuildRoot\publish")) {
Remove-Item -Recurse -Path "$BuildRoot\publish\*"
}
}
task CreateModule CleanTemp, FileTests, AnalyzeBuiltFiles, BuildMamlHelp, {
}