forked from microsoft/azure-api-management-monetization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
47 lines (40 loc) · 1.09 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
$ErrorActionPreference = "Stop"
$here = Split-Path -Parent $PSCommandPath
$toolsDir = "$here/tools"
if ($IsWindows) {
$os = "win"
}
elseif ($IsLinux) {
$os = "linux"
}
elseif ($IsMacOS) {
$os = "osx"
}
else {
throw "Unsupported OS"
}
function installBicep {
$version = "v0.3.126"
$extension = $IsWindows ? ".exe" : ""
$bicepUri = "https://github.com/Azure/bicep/releases/download/$version/bicep-$os-x64$extension"
$dir = New-Item -Path $toolsDir/bicep/$version -ItemType Directory -Force
$bicep = "$dir\bicep$extension"
if (Test-Path $dir/* -Filter bicep*) {
Write-Host "Bicep already installed."
}
else {
(New-Object Net.WebClient).DownloadFile($bicepUri, $bicep)
}
return $bicep
}
try {
Write-Host "Installing Bicep..."
$bicep = installBicep
Write-Host "Building main Bicep template..."
. $bicep build $here/templates/main.bicep --outdir $here/output
}
catch {
Write-Warning $_.ScriptStackTrace
Write-Warning $_.InvocationInfo.PositionMessage
Write-Error ("Build error: `n{0}" -f $_.Exception.Message)
}