Release: weekly deploy
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
function Get-BuildMetadata {
|
||||
param([string]$RepoRoot)
|
||||
|
||||
$gitSha = ''
|
||||
$appVersion = '0.0.0'
|
||||
try {
|
||||
Push-Location $RepoRoot
|
||||
$gitSha = (git rev-parse --short HEAD 2>$null).Trim()
|
||||
$appVersion = (node -p "require('./package.json').version" 2>$null).Trim()
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
if (-not $gitSha) { $gitSha = 'unknown' }
|
||||
if (-not $appVersion) { $appVersion = '0.0.0' }
|
||||
|
||||
$buildTime = Get-Date
|
||||
$buildTimeUtc = $buildTime.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||
|
||||
return @{
|
||||
GitSha = $gitSha
|
||||
AppVersion = $appVersion
|
||||
BuildTimeUtc = $buildTimeUtc
|
||||
ReleaseTag = New-ReleaseImageTag -GitSha $gitSha -BuildTime $buildTime
|
||||
}
|
||||
}
|
||||
|
||||
function New-ReleaseImageTag {
|
||||
param(
|
||||
[string]$GitSha,
|
||||
[datetime]$BuildTime
|
||||
)
|
||||
|
||||
if (-not $BuildTime) { $BuildTime = Get-Date }
|
||||
if (-not $GitSha) { $GitSha = 'unknown' }
|
||||
|
||||
$stamp = $BuildTime.ToString('yyyyMMdd-HHmmss')
|
||||
return "$stamp-$GitSha"
|
||||
}
|
||||
|
||||
function Write-LastDockerRelease {
|
||||
param(
|
||||
[string]$RepoRoot,
|
||||
[hashtable]$Metadata,
|
||||
[string]$Image
|
||||
)
|
||||
|
||||
$manifestPath = Join-Path $RepoRoot 'infra\deploy\last-docker-release.json'
|
||||
$manifest = @{
|
||||
image = $Image
|
||||
release_tag = $Metadata.ReleaseTag
|
||||
git_sha = $Metadata.GitSha
|
||||
app_version = $Metadata.AppVersion
|
||||
built_at = $Metadata.BuildTimeUtc
|
||||
pushed_at = (Get-Date).ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||
}
|
||||
$manifest | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $manifestPath -Encoding UTF8
|
||||
return $manifestPath
|
||||
}
|
||||
Reference in New Issue
Block a user