-
Notifications
You must be signed in to change notification settings - Fork 0
/
resgen.ps1
executable file
·39 lines (31 loc) · 1.34 KB
/
resgen.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
#!/usr/bin/env pwsh
Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"
# Generate image and container names using the data in the "component.json" file
$component = Get-Content -Path "component.json" | ConvertFrom-Json
$resImage = "$($component.registry)/$($component.name):$($component.version)-$($component.build)-res"
$container = $component.name
# Remove build files
if (Test-Path "$PSScriptRoot/resources") {
Remove-Item -Recurse -Force -Path "$PSScriptRoot/resources/*"
} else {
$null = New-Item -ItemType Directory -Force -Path "$PSScriptRoot/resources"
}
if (Test-Path "$PSScriptRoot/example/resources") {
Remove-Item -Recurse -Force -Path "$PSScriptRoot/example/resources/*"
} else {
$null = New-Item -ItemType Directory -Force -Path "$PSScriptRoot/example/resources"
}
# Build docker image
docker build -f "$PSScriptRoot/docker/Dockerfile.resgen" -t $resImage "$PSScriptRoot/."
# Run resgen container
docker run -d --name $container $resImage
# Copy resources from container
docker cp "$($container):/app/src/example/resources" "$PSScriptRoot/example"
docker cp "$($container):/app/src/resources" "$PSScriptRoot/."
# Remove docgen container
docker rm $container --force
# Verify resources
if (-not (Test-Path "$PSScriptRoot/resources/*.go")) {
Write-Error "resources folder doesn't exist in root dir. Watch logs above."
}