This repository was archived by the owner on Feb 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.ps1
More file actions
68 lines (58 loc) · 2.18 KB
/
Copy pathbuild.ps1
File metadata and controls
68 lines (58 loc) · 2.18 KB
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
function Test-PullRequest {
($env:APPVEYOR_REPO_BRANCH -like 'master') -and
(test-path env:/APPVEYOR_PULL_REQUEST_NUMBER) -and
(-not [string]::IsNullOrEmpty($env:APPVEYOR_PULL_REQUEST_NUMBER))
}
if(Test-PullRequest) {
$channel = "unstable"
}
else {
$channel = "stable"
}
$bootstrapDir = "c:\habitat"
$url = "https://api.bintray.com/content/habitat/stable/windows/x86_64/hab-$($env:hab_exe_version)-x86_64-windows.zip?bt_package=hab-x86_64-windows"
mkdir $bootstrapDir -Force
Write-Host "Download and install latest release of hab.exe from $url"
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile hab.zip
Expand-Archive -Path hab.zip -DestinationPath $bootstrapDir -Force
Remove-Item hab.zip -Force
$habExe = (Get-Item "$bootstrapDir/*/hab.exe").FullName
$env:HAB_ORIGIN="core"
if($env:ORIGIN_KEY) {
"SIG-SEC-1`ncore-20170318210306`n`n$($env:ORIGIN_KEY)" | & $habExe origin key import
}
else {
Write-Host "Generating fake secret origin key for core..."
& $habExe origin key generate core
}
if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
& $habExe pkg build . -w
if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
$hart = (Get-Item "results\*.hart")[-1]
& $habExe pkg install $hart.FullName
if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
$binPath = (Resolve-Path "/hab/pkgs/core/windows-service/*/*/bin").Path
$pathParts = $binPath.Split("\")
$versionStamp = "$($pathParts[-3])-$($pathParts[-2])"
Update-AppveyorBuild -Version $versionStamp
& $habExe pkg exec core/windows-service install
if(!(Get-Service Habitat -ErrorAction SilentlyContinue)) {
Throw "The Habitat service was not installed!"
}
Start-Service Habitat
if((Get-Service Habitat).Status -ne "Running") {
Throw "The Habitat service was unable to start!"
}
$retry = 0
while ($retry -lt 10 -and !((Test-NetConnection localhost -Port 9632).TcpTestSucceeded)) {
Write-Host "Waiting for Supervisor to listen on 9632..."
Start-Sleep -Seconds 1
$retry += 1
}
Write-Host "Validating we can talk to a running supervisor"
& $habExe svc status
if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
if($env:HAB_AUTH_TOKEN) {
& $habExe pkg upload $hart --channel $channel
if ($LASTEXITCODE -ne 0) {exit $LASTEXITCODE}
}