-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
51 lines (47 loc) · 1.57 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
[CmdletBinding()]
Param (
$Task = 'Default',
$VersionIncrement = 'Patch'
)
function Install-PSDepend {
$PSDependVersion = '0.2.3'
if (!(Get-InstalledModule -Name 'PSDepend' -RequiredVersion $PSDependVersion -ErrorAction 'SilentlyContinue')) {
Install-Module -Name 'PSDepend' -RequiredVersion $PSDependVersion -Force -Scope 'CurrentUser'
}
Import-Module -Name 'PSDepend' -RequiredVersion $PSDependVersion
Invoke-PSDepend -Path "$PSScriptRoot\build.Depend.psd1" -Install -Import -Force
}
switch ($Task) {
'Build' {
Write-Output 'Starting build of BNMoldovaCurrency'
Install-PSDepend
Invoke-Build -Task $Task -Result InvokeBuildResult -VersionIncrement $VersionIncrement
break
}
'Test' {
Write-Output 'Running Pester tests for BNMoldovaCurrency'
Invoke-Build -Task $Task -Result InvokeBuildResult
break
}
'Deploy' {
Write-Output 'Deploying BNMoldovaCurrency'
Invoke-Build -Task $Task -Result InvokeBuildResult
break
}
'Default' {
Write-Output 'Building and testing BNMoldovaCurrency'
Install-PSDepend
Invoke-Build -Task $Task -Result InvokeBuildResult -VersionIncrement $VersionIncrement
break
}
Default {
throw [System.ArgumentException]::new("Unknown task type: $Task")
}
}
if ($InvokeBuildResult.Errors) {
$Result.Tasks | Where-Object { $_.Error } | ForEach-Object {
"Task '$($_.Name)' at $($_.InvocationInfo.ScriptName):$($_.InvocationInfo.ScriptLineNumber)"
$_.Error
}
exit 1
}