-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdocker_build_and_push.ps1
executable file
·76 lines (57 loc) · 1.85 KB
/
docker_build_and_push.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
#!/usr/bin/env pwsh
param(
$next_version
)
function script:exec {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory = 1)][scriptblock]$cmd,
[Parameter(Position = 1, Mandatory = 0)][string]$errorMessage,
[switch]$WhatIf = $false
)
if ($WhatIf) {
$InformationPreference = 'Continue'
Write-Information "Would execute `"$cmd`""
return;
}
Write-Information "Executing `"$cmd`""
& $cmd
if ($LASTEXITCODE -ne 0) {
throw ("Error ($LASTEXITCODE) executing command: {0}" -f $cmd) + ($errorMessage ?? "")
}
}
$ErrorActionPreference = 'Stop'
$InformationPreference = 'Continue'
$env:NEXT_VERSION = $next_version
if ($null -eq $env:CHANGELOG_GITHUB_TOKEN) {
Write-Error "Cannot generate change log unless CHANGELOG_GITHUB_TOKEN environment variable is set"
}
if ($null -eq $next_version -or '' -eq $next_version ) {
Write-Error "Next version variable is required"
exit 1
}
Write-Output "Generate changelog"
exec { docker-compose run web rake changelog }
Write-Output "Generate API docs"
exec { docker-compose run web generate_docs.sh }
Write-Output "Set VERSION $next_version"
exec { Write-Output $next_version > VERSION }
exec {
git add -A && git commit -m "Generated changelog and API docs for version $next_version" -m "[skip ci]"
}
Write-Output "Creating tag $next_version"
exec { git tag -a -m "Version $next_version" $next_version }
exec { git push --follow-tags }
$short = exec { git describe }
$long = exec { git describe --long }
Write-Output "Building docker file"
exec {
docker build --build-arg version=$short --build-arg trimmed=true `
--label version=$long `
--tag qutecoacoustics/workbench-server:latest --tag qutecoacoustics/workbench-server:$long `
.
}
Write-Output "Pushing dockerfile"
exec {
docker push -a qutecoacoustics/workbench-server
}