-
Notifications
You must be signed in to change notification settings - Fork 152
/
createAllManifests.ps1
94 lines (77 loc) · 2.95 KB
/
createAllManifests.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
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# script to create the Docker manifest lists
param (
[ValidateNotNullOrEmpty()]
[string]
$Registry = 'microsoft',
[ValidateSet('stable','preview','servicing', 'lts')]
[Parameter(Mandatory)]
[string]
$Channel='stable',
[switch]
$SkipPush
)
# this function wraps native command Execution
# for more information, read https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right/
function script:Start-NativeExecution
{
param(
[scriptblock]$sb,
[switch]$IgnoreExitcode,
[switch]$VerboseOutputOnError
)
Write-Verbose -Message "Running '$($sb.ToString())'" -Verbose
$backupEAP = $ErrorActionPreference
$ErrorActionPreference = "Continue"
try {
if($VerboseOutputOnError.IsPresent)
{
$output = & $sb 2>&1
}
else
{
& $sb
}
# note, if $sb doesn't have a native invocation, $LASTEXITCODE will
# point to the obsolete value
if ($LASTEXITCODE -ne 0 -and -not $IgnoreExitcode) {
if($VerboseOutputOnError.IsPresent -and $output)
{
$output | Out-String | Write-Verbose -Verbose
}
# Get caller location for easier debugging
$caller = Get-PSCallStack -ErrorAction SilentlyContinue
if($caller)
{
$callerLocationParts = $caller[1].Location -split ":\s*line\s*"
$callerFile = $callerLocationParts[0]
$callerLine = $callerLocationParts[1]
$errorMessage = "Execution of {$sb} by ${callerFile}: line $callerLine failed with exit code $LASTEXITCODE"
throw $errorMessage
}
throw "Execution of {$sb} failed with exit code $LASTEXITCODE"
}
} finally {
$ErrorActionPreference = $backupEAP
}
}
$buildScriptPath = Join-Path -Path $PSScriptRoot -ChildPath 'build.ps1'
$createScriptPath = Join-Path -Path $PSScriptRoot -ChildPath 'createManifest.ps1'
$extraParams = ''
if ($env:STABLERELEASETAG) {
$extraParams += " -StableVersion $($env:STABLERELEASETAG -replace '^v')"
}
if ($env:PREVIEWRELEASETAG) {
$extraParams += " -PreviewVersion $($env:PREVIEWRELEASETAG -replace '^v')"
}
if ($env:LTSRELEASETAG) {
$extraParams += " -LtsVersion $($env:LTSRELEASETAG -replace '^v')"
}
$json = Start-NativeExecution -sb ([scriptblock]::Create("$buildScriptPath -GenerateManifestLists -Channel $Channel -OsFilter All $extraParams"))
$manifestLists = $json | ConvertFrom-Json
$manifestLists.ManifestList | ForEach-Object {
$tag = $_
$manifestList = $manifestLists | Where-Object {$_.ManifestList -eq $tag}
Start-NativeExecution -sb ([scriptblock]::Create("$createScriptPath -ContainerRegistry $Registry -taglist $($manifestList.Tags -join ', ') -ManifestTag $tag -SkipPush:`$$($SkipPush.IsPresent)"))
}