Release: weekly deploy

This commit is contained in:
Danila Khodjaef
2026-07-09 16:03:48 +03:00
parent 0ceb1c1c8c
commit 62096e8210
16 changed files with 169 additions and 38 deletions
+38 -5
View File
@@ -1,15 +1,17 @@
# Build and push the production web image to Gitea over LAN (fast path).
param(
[string]$Tag = "latest",
[string]$Tag = '',
[switch]$SkipHosts,
[switch]$SkipBuild
)
$ErrorActionPreference = "Stop"
. (Join-Path $PSScriptRoot "..\scripts\lib\Deploy-CliResult.ps1")
. (Join-Path $PSScriptRoot "..\scripts\lib\Build-ReleaseTag.ps1")
$Registry = "gitea.mysuperlab.netcraze.pro"
$Image = "$Registry/danilka/gallery-web"
$RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path
function Test-DockerRunning {
$prevEap = $ErrorActionPreference
@@ -27,10 +29,24 @@ if (-not (Test-DockerRunning)) {
exit 1
}
$meta = Get-BuildMetadata -RepoRoot $RepoRoot
$releaseTag = if ($Tag -and $Tag.Trim()) { $Tag.Trim() } else { $meta.ReleaseTag }
$meta.ReleaseTag = $releaseTag
Write-Host "Release tag: $releaseTag"
Write-Host "Build metadata: app_version=$($meta.AppVersion), git_sha=$($meta.GitSha), built_at=$($meta.BuildTimeUtc)"
if (-not $SkipBuild) {
Write-Host ""
Write-Host "Building ${Image}:${Tag} ..."
docker build -f infra/docker/Dockerfile -t "${Image}:${Tag}" .
Write-Host "Building ${Image}:$releaseTag and ${Image}:latest ..."
docker build -f infra/docker/Dockerfile `
--build-arg "APP_VERSION=$($meta.AppVersion)" `
--build-arg "GIT_SHA=$($meta.GitSha)" `
--build-arg "IMAGE_TAG=$releaseTag" `
--build-arg "BUILD_TIME=$($meta.BuildTimeUtc)" `
-t "${Image}:$releaseTag" `
-t "${Image}:latest" `
$RepoRoot
if ($LASTEXITCODE -ne 0) {
Write-DeployCliResult -Script 'build-push-lan' -Success $false -Summary "Docker build failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
@@ -41,11 +57,28 @@ if (-not $SkipBuild) {
}
Write-Host ""
& "$PSScriptRoot/push-lan.ps1" -Tag $Tag -SkipHosts:$SkipHosts
if ($SkipBuild) {
$pushTags = @('latest')
if ($Tag -and $Tag.Trim()) {
$pushTags = @($Tag.Trim(), 'latest') | Select-Object -Unique
}
} else {
$pushTags = @($releaseTag, 'latest') | Select-Object -Unique
}
& "$PSScriptRoot/push-lan.ps1" -Tags $pushTags -SkipHosts:$SkipHosts
if ($LASTEXITCODE -ne 0) {
Write-DeployCliResult -Script 'build-push-lan' -Success $false -Summary "Docker push failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
Write-DeployCliResult -Script 'build-push-lan' -Success $true -Summary 'Docker image built and pushed to Gitea.' -Details @("Image: ${Image}:${Tag}")
$manifestPath = Write-LastDockerRelease -RepoRoot $RepoRoot -Metadata $meta -Image "${Image}:$releaseTag"
Write-DeployCliResult -Script 'build-push-lan' -Success $true -Summary 'Docker image built and pushed to Gitea.' -Details @(
"Release tag: $releaseTag",
"Also pushed as: latest",
"Git commit: $($meta.GitSha)",
"Built at: $($meta.BuildTimeUtc)",
"Manifest: $manifestPath",
"TrueNAS: restart gallery-web (pull_policy: always uses latest)."
)
exit 0