forked from datalust/seqcli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.Docker.ps1
55 lines (41 loc) · 1.5 KB
/
Build.Docker.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
$IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "main" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH
$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
$framework = "net5.0"
$rid = "linux-x64"
$tag = "datalust/seqcli-ci:$version"
function Execute-Tests
{
& dotnet test ./test/SeqCli.Tests/SeqCli.Tests.csproj -c Release -f $framework /p:Configuration=Release /p:Platform=x64 /p:VersionPrefix=$version
if ($LASTEXITCODE -ne 0) { exit 1 }
cd ./test/SeqCli.EndToEnd/
docker pull datalust/seq:latest
& dotnet run -f $framework -- --docker-server
if ($LASTEXITCODE -ne 0) { exit 1 }
cd ../..
}
function Build-DockerImage
{
& dotnet publish src/SeqCli/SeqCli.csproj -c Release -f $framework -r $rid /p:VersionPrefix=$version
if($LASTEXITCODE -ne 0) { exit 2 }
& docker build -f dockerfiles/seqcli/Dockerfile -t $tag .
if($LASTEXITCODE -ne 0) { exit 3 }
}
function Publish-DockerImage
{
$ErrorActionPreference = "SilentlyContinue"
if ($IsCIBuild) {
Write-Output "$env:DOCKER_TOKEN" | docker login -u $env:DOCKER_USER --password-stdin
if ($LASTEXITCODE) { exit 3 }
}
& docker push $tag
if($LASTEXITCODE -ne 0) { exit 3 }
$ErrorActionPreference = "Stop"
}
Push-Location $PSScriptRoot
Execute-Tests
Build-DockerImage
if ($IsPublishedBuild) {
Publish-DockerImage
}
Pop-Location