-
Notifications
You must be signed in to change notification settings - Fork 1
/
Build.ps1
70 lines (62 loc) · 2.55 KB
/
Build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
$ModuleName = 'Smtp4Dev4BcContainers'
$repoRootDir = (split-path $PSCommandPath)
$ModulPath = join-path $repoRootDir -ChildPath $ModuleName
#region ValidateThatModuleIsImportable
Write-Host "ValidateThatModuleIsImportable"
Import-Module $ModulPath -Force
#region ValidateThatModuleIsImportable
#region SetModuleVersion
Write-Host "SetModuleVersion"
$ManifestPath = (join-path $ModulPath -ChildPath "$ModuleName.psd1")
$Manifest = Test-ModuleManifest -Path (join-path $ModulPath -ChildPath "$ModuleName.psd1")
$newMajor = $Manifest.Version.Major
$newMinor = $Manifest.Version.Minor
$newBuild = get-date -Format "yyMMdd"
$newRevision = get-date -Format "HHmmss"
$NewVersion = New-Object System.Version -ArgumentList @($newMajor,$newMinor,$newBuild,$newRevision)
Update-ModuleManifest -Path $ManifestPath -ModuleVersion $NewVersion -Verbose
#endregion SetModuleVersion
#region RunScriptAnalyzer
Write-Host "RunScriptAnalyzer"
if (-not (Get-InstalledModule PSScriptAnalyzer -ErrorAction SilentlyContinue)) {
Install-Module -Name PSScriptAnalyzer -Scope CurrentUser
}
gci $ModulPath -filter "*.ps1" -Recurse | Invoke-ScriptAnalyzer -Fix
#endregion RunScriptAnalyzer
#region RefreshDocs
Write-Host "RefreshDocs"
if (-not (Get-InstalledModule platyPS -ErrorAction SilentlyContinue)) {
Install-Module -Name platyPS -Scope CurrentUser
}
Import-Module platyPS
$DocsPath = Join-Path $repoRootDir -ChildPath "docs\"
$null = mkdir $DocsPath -ErrorAction SilentlyContinue
if(gci $DocsPath -filter "*.md"){
$null = Update-MarkdownHelpModule -Path $DocsPath -RefreshModulePage -UpdateInputOutput
} else {
New-MarkdownHelp -Module $ModuleName -OutputFolder $DocsPath -HelpVersion $NewVersion -WithModulePage
}
#Fix mixed language due to my german system
$DocFiles = $DocsPath | gci -filter "*.md"
foreach($DocFile in $DocFiles){
($DocFile | get-content -Raw).Replace('### BEISPIEL','### EXAMPLE') | Set-Content -Path $DocFile.FullName
}
#endregion RefreshDocs
#region ValidateThatModuleIsImportable
Write-Host "ValidateThatModuleIsImportable"
#Do this again since we changed some files in the Build Process
Import-Module $ModulPath -Force
#region ValidateThatModuleIsImportable
#region RunTests
<#
Write-Host "RunTests"
if (-not (Get-InstalledModule Pester -ErrorAction SilentlyContinue)) {
Install-Module -Name Pester -Scope CurrentUser
}
Import-Module Pester
foreach($TestScript in (gci -Path (Join-Path $repoRootDir -ChildPath "test") -Filter "*.tests.ps1" ).FullName){
Write-Host "Run Tests in $TestScript"
Invoke-Pester -Path $TestScript -Output Detailed
}
#>
#endregion RunTests