Reconcile dev after direct CI version-drift fix #16
@@ -35,6 +35,10 @@ jobs:
|
||||
# Windows is required to build/test the agent (CIM, ConPTY, DPAPI, service).
|
||||
# Label must match a registered runner: windows-host.
|
||||
runs-on: windows-host
|
||||
# Single source of truth for the version: the images job consumes this
|
||||
# instead of recomputing, so binaries and container images never drift.
|
||||
outputs:
|
||||
version: ${{ steps.ver.outputs.version }}
|
||||
steps:
|
||||
# This repository uses the SHA-256 object format. actions/checkout
|
||||
# cannot clone it (it inits a SHA-1 repo then fetches: "mismatched
|
||||
@@ -187,12 +191,13 @@ jobs:
|
||||
git clone --depth 1 --branch "$REF" "$URL" .
|
||||
git log -1 --format='%H %s'
|
||||
|
||||
- name: Resolve version and registry target
|
||||
- name: Resolve registry target
|
||||
id: ver
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
echo "version=$(date -u +%Y.%m.%d.%H%M)" >> "$GITHUB_OUTPUT"
|
||||
# The version is NOT recomputed here — it comes from build-test's
|
||||
# output (needs.build-test.outputs.version) so images match the binaries.
|
||||
|
||||
# Default to Gitea's own registry on this instance; fall back to the
|
||||
# REGISTRY_* secrets only when an external registry is configured.
|
||||
@@ -239,7 +244,7 @@ jobs:
|
||||
|
||||
- name: Build images
|
||||
env:
|
||||
VERSION: ${{ steps.ver.outputs.version }}
|
||||
VERSION: ${{ needs.build-test.outputs.version }}
|
||||
PREFIX: ${{ steps.ver.outputs.prefix }}
|
||||
SOURCE_URL: ${{ github.server_url }}/${{ github.repository }}
|
||||
run: |
|
||||
@@ -259,7 +264,7 @@ jobs:
|
||||
|
||||
- name: Tag and push
|
||||
env:
|
||||
VERSION: ${{ steps.ver.outputs.version }}
|
||||
VERSION: ${{ needs.build-test.outputs.version }}
|
||||
PREFIX: ${{ steps.ver.outputs.prefix }}
|
||||
REF_NAME: ${{ github.ref_name }}
|
||||
run: |
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Computes the unified build version (yyyy.MM.dd.HHmm, UTC) exactly once per build.
|
||||
Computes the unified build version (yyyy.MM.dd.HHmm, UTC).
|
||||
Honors an explicit -Version argument or the UNIFIED_VERSION environment variable
|
||||
(as set by CI) so every artifact in one pipeline shares the same version.
|
||||
first. Otherwise it derives the version from the HEAD commit's committer time, so
|
||||
every job and workflow building the same commit lands on the same version — no
|
||||
drift between the binaries and the container images. Falls back to the current
|
||||
time only when git is unavailable.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
@@ -12,7 +15,15 @@ param(
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not $Version) { $Version = $env:UNIFIED_VERSION }
|
||||
if (-not $Version) { $Version = [DateTime]::UtcNow.ToString('yyyy.MM.dd.HHmm') }
|
||||
if (-not $Version) {
|
||||
$epoch = "$(git show -s --format=%ct HEAD 2>$null)".Trim()
|
||||
if ($epoch -match '^\d+$') {
|
||||
$Version = [DateTimeOffset]::FromUnixTimeSeconds([long]$epoch).UtcDateTime.ToString('yyyy.MM.dd.HHmm')
|
||||
}
|
||||
else {
|
||||
$Version = [DateTime]::UtcNow.ToString('yyyy.MM.dd.HHmm')
|
||||
}
|
||||
}
|
||||
|
||||
if ($Version -notmatch '^\d{4}\.\d{2}\.\d{2}\.\d{4}$') {
|
||||
throw "Unified version '$Version' does not match yyyy.MM.dd.HHmm."
|
||||
|
||||
Reference in New Issue
Block a user