-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack_build.ps1
88 lines (70 loc) · 2.71 KB
/
pack_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
[CmdletBinding()]
param (
[Parameter(Mandatory=$true, Position=0)]
[string]
$TemplateName,
[Parameter(Mandatory=$true)]
[string]
$BuildPath,
[Parameter(Mandatory=$false)]
[switch] $IgnoreMissing,
[Parameter(Mandatory=$false)]
[switch] $RemoveBuild
)
$InformationPreference= 'Continue'
push-Location $PSScriptRoot
$importSpecs = Get-Content -Raw -Path "import.json" | ConvertFrom-Json
$keys = $importSpecs | ForEach-Object { $_ | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name } | Where-Object {$_ -like $TemplateName}
$resolvedBuildPath = Resolve-Path $BuildPath
if((Test-Path $resolvedBuildPath -PathType Container) -eq $false)
{
Write-Information "Could not find build path $BuildPath" -ForegroundColor
return
}
$keys | ForEach-Object {
$importSpec = $importSpecs.$_
$TemplateName = $_
$buildGeneset = Join-Path $resolvedBuildPath -ChildPath "$TemplateName-stage1\$TemplateName"
if((Test-Path $buildGeneset -PathType Container) -eq $false)
{
if($IgnoreMissing){
Write-Information "Could not find build vm in path $buildGeneset"
return
}else{
Write-Error "Could not find build vm in path $buildGeneset"
exit
}
}
$packTarget = $importSpec.pack
if($null -ne $packTarget)
{
$day = Get-Date -Format "yyyyMMdd"
$packTarget = $packTarget.replace("{date}", $day)
Write-Information "packing $TemplateName to $packTarget"
$packTargetPath = "genes\"+ $packTarget.Replace('/', '\\')
$geneSetPath = split-path $packTargetPath -parent
if((Test-Path $geneSetPath) -ne $true){
& eryph-packer geneset init $packTarget --public --workdir genes | Out-Null
}
if((Test-Path $packTargetPath) -ne $true){
& eryph-packer geneset-tag init $packTarget --workdir genes | Out-Null
}
& eryph-packer geneset-tag add-vm $packTarget $buildGeneset --workdir genes | Out-Null
& eryph-packer geneset-tag pack $packTarget --workdir genes | Out-Null
git add $geneSetPath | Out-Null
}
$updateTarget = $importSpec.update
if($null -ne $updateTarget)
{
$updatePath = "genes\"+ $updateTarget.Replace('/', '\\')
if((Test-Path $updatePath) -ne $true){
& eryph-packer geneset-tag init $updateTarget --workdir genes
}
& eryph-packer geneset-tag ref $updateTarget $packTarget --workdir genes | Out-Null
& eryph-packer geneset-tag pack $updateTarget --workdir genes | Out-Null
}
if($RemoveBuild){
Remove-Item -Path $buildGeneset -Recurse -Force
}
Write-Output $packTarget
}