Skip to content

[BUG] Build metadata stamping defects: empty BuildDate on Windows release binaries; stray brace in goreleaser BuildMinorVersion ldflag #704

Closed

Description

@jeffreyaven

Summary

Two related defects in build metadata stamping:

  1. Windows release binaries ship with an empty BuildDate. This surfaces as a
    blank build_date field in the MCP server_info tool response and in
    stackql --version output for Windows builds (including the windows-x64
    MCPB bundle, which repackages the signed release exe).
  2. All three goreleaser configs contain a stray closing brace in the
    BuildMinorVersion ldflag ({{.Minor}}}), which would stamp a corrupted
    minor version (e.g. 10}) in any goreleaser-built binary.

Observed

server_info from the windows-x64 MCPB bundle (v0.10.582, commit c926a33):

build_date:        (empty)
version:           0.10.582
commit:            c926a33
platform:          Windows

Root cause

Defect 1: cicd/python/build.py stamps the build date from the
BUILDDATE environment variable, defaulting to empty string:

-X 'github.com/stackql/stackql/internal/stackql/cmd.BuildDate={os.environ.get('BUILDDATE', '')}'

The Linux and macOS jobs in .github/workflows/build.yml set
BUILDDATE="$(date)" before invoking build.py. The winbuild job's
"Generate Build Flags and Build" step sets BUILDCOMMITSHA, BUILDPLATFORM
and BUILDPATCHVERSION but never sets BUILDDATE, so the ldflag resolves to
empty on Windows.

Defect 2: In .github/goreleaser/.goreleaser-for-windows.yaml,
.goreleaser-for-darwin.yaml and .goreleaser-for-linux.yaml:

-X github.com/stackql/stackql/internal/stackql/cmd.BuildMinorVersion={{.Minor}}}

The trailing } is passed through into the stamped value. Currently latent
(release binaries are produced by build.yml, not goreleaser) but will bite
if the goreleaser path is ever used.

Proposed resolution

  1. In the winbuild job, set BUILDDATE in the "Generate Build Flags and
    Build" step, e.g.:

    $env:BUILDDATE = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
    
  2. While here, consider standardising the Linux/macOS jobs on the same
    ISO-8601 UTC format (date -u +%Y-%m-%dT%H:%M:%SZ) rather than the
    locale-dependent $(date), so build_date is consistent and parseable
    across platforms.

  3. Fix {{.Minor}}} -> {{.Minor}} in all three goreleaser configs.

  4. Optional hardening: fall back to debug.ReadBuildInfo() vcs.time in
    buildinfo when the ldflag is empty, so locally-built binaries also report
    a build date; alternatively have RenderKV omit empty fields in the MCP
    markdown render (the DTO already has omitempty for JSON, but the
    markdown path prints blanks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions