-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.ps1
94 lines (64 loc) · 2.62 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
[cmdletBinding()]
Param(
[Parameter()]
[Switch]
$Test,
[Parameter()]
[Switch]
$Build,
[Parameter()]
[Switch]
$Deploy
)
#Make some variables, shall we?
$innvocationPath = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)"
$PSModuleRoot = Split-Path -Parent $innvocationPath
$PSModuleRoot
$TestPath = Join-Path $PSModuleRoot "Tests"
#Do Stuff based on passed Args
Switch($true){
$Test {
If(-not (Get-Module Pester)){
Install-Module -Name Pester -SkipPublisherCheck -Force
}
Invoke-Pester -Script $TestPath -OutputFile "$($env:Build_ArtifactStagingDirectory)\Vagrantey.Results.xml" -OutputFormat 'NUnitXml'
#
Get-ChildItem $env:Build_ArtifactStagingDirectory
}
$Build {
If(Test-Path "$($env:Build_ArtifactStagingDirectory)\Vagrantey"){
Remove-Item "$($env:Build_ArtifactStagingDirectory)\Vagrantey" -Recurse -Force
}
$null = New-Item "$($env:Build_ArtifactStagingDirectory)\Vagrantey" -ItemType Directory
Get-ChildItem $PSScriptRoot\Public\*.ps1 | Foreach-Object {
#Get-Content $_.FullName | Add-Content "$($env:Build_ArtifactStagingDirectory)\Vagrantey\Vagrantey.psm1"
If(!(Test-Path "$($env:Build_ArtifactStagingDirectory)\Vagrantey\public")){
$null = New-Item "$($env:Build_ArtifactStagingDirectory)\Vagrantey\public" -ItemType Directory
}
Copy-Item $_.FullName "$($env:Build_ArtifactStagingDirectory)\Vagrantey\public\"
}
Copy-Item "$PSScriptRoot\Vagrantey.psm1" "$($env:Build_ArtifactStagingDirectory)\Vagrantey"
Copy-Item "$PSScriptRoot\Vagrantey.psd1" "$($env:Build_ArtifactStagingDirectory)\Vagrantey"
#Verification of contents
Get-ChildItem -Path "$($env:Build_ArtifactStagingDirectory)\Vagrantey" -Recurse
#Verify we can load the module and see cmdlets
Import-Module "$($env:Build_ArtifactStagingDirectory)\Vagrantey\Vagrantey.psd1"
Get-Command -Module Vagrantey
}
$Deploy {
Try {
$deployCommands = @{
Path = (Resolve-Path -Path "$($env:Build_ArtifactStagingDirectory)\Vagrantey")
NuGetApiKey = $env:NuGetApiKey
ErrorAction = 'Stop'
}
Publish-Module @deployCommands
}
Catch {
throw $_
}
}
default {
echo "Please Provide one of the following switches: -Test, -Build, -Deploy"
}
}