Skip to content

fix(server): stamp BuildDate in release builds and fall back to vcs.time - #494

Open
mh254 wants to merge 1 commit into
UNITRONIX:devfrom
mh254:fix/server-builddate
Open

mh254 wants to merge 1 commit into
UNITRONIX:devfrom
mh254:fix/server-builddate

Conversation

@mh254

@mh254 mh254 commented Nov 9, 2026

Copy link
Copy Markdown

Summary

betterdesk-server --version and the startup banner print built unknown for every released server asset. Cause: .github/workflows/release-server.yml builds with -ldflags="-s -w -X main.Version=${VERSION}" only, so BuildDate in betterdesk-server/main.go keeps its compile-time default "unknown". The repository's own documented build command (.github/go-server-context.md → "Build Commands") does pass -X main.BuildDate, and init() already resolves Version at runtime via productversion.Product() when the flag is missing — this PR does the same for the build date.

Changes:

  • .github/workflows/release-server.yml: pass -X main.BuildDate=<UTC timestamp> in the release build.
  • betterdesk-server/main.go: if BuildDate is empty or "unknown", fall back to the vcs.time setting Go stamps into binaries built from a Git checkout (buildvcs, on by default). Installer, Docker and local builds therefore report a real date too.

Before: betterdesk-server 3.5.221 (built unknown)
After: betterdesk-server 3.5.221 (built 2026-11-09T08:58:12Z)

The change only affects the printed string; no code path, flag or protocol behaviour changes.

Target branch

  • This pull request targets dev, unless it is an explicitly approved dev → main release.

Security and provenance

  • No credentials, private keys, deployment-specific hostnames, IPs, paths, or private configuration are included.
  • I did not add a workflow that executes fork-controlled code with repository secrets. (Only one -ldflags value is added to an existing build step; no new workflow, no new secret, no pull_request_target.)
  • External code, generated artifacts, protocol compatibility code, and upstream-derived material have documented provenance. (Not applicable — standard library only: runtime/debug.)
  • Security-sensitive changes explain the trust boundary, authorization behavior, limits, and failure mode. (Not applicable — the diff adds a build stamp and a read-only lookup in the binary's own build info.)

Deployment and compatibility

  • The change is deployable through the panel updater, installer scripts, or the documented Docker image path. (No deployment files touched. Release builds get the date from the new flag; installer/local builds get it from the vcs.time fallback. Nothing to migrate.)
  • Database changes are additive and safe on both SQLite and PostgreSQL, or the manual migration step is documented. (No database changes.)
  • .env changes append missing keys without overwriting operator secrets. (No .env changes.)
  • Update/restart and rollback behavior was checked when deployment files or the Go server changed. (Behaviour unchanged apart from the banner string; rollback is a plain revert of this commit.)

Tests

Run locally against dev (94757a1) with Go 1.26.10, matching go.mod's toolchain go1.26.10.

  • Commands:
# 1) fallback path: build like the installer does (no -X main.BuildDate)
go build -trimpath -ldflags="-s -w -X main.Version=3.5.221" -o /tmp/bd-fallback .
/tmp/bd-fallback -version

# 2) release path: build exactly like release-server.yml
VERSION="$(tr -d '\r\n' < ../VERSION)"
BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
go build -trimpath -ldflags="-s -w -X main.Version=${VERSION} -X main.BuildDate=${BUILD_DATE}" -o /tmp/bd-ldflags .
/tmp/bd-ldflags -version

go vet ./...
go test -count=1 .
  • Results:

    1. Installer-style build (no -X main.BuildDate): betterdesk-server 3.5.221 (built 2026-11-09T07:53:00Z) — the vcs.time fallback replaces unknown.
    2. Release-style build (flags identical to release-server.yml): betterdesk-server 3.5.221 (built 2026-11-09T07:56:53Z) — matches the injected BUILD_DATE.
    3. go vet ./... → clean, no findings.
    4. go test -count=1 . → ok github.com/unitronix/betterdesk-server 2.702s.

    Note: only the main package was tested locally; the full go test -race ./... sweep is left to CI.

Console translations

  • No user-visible strings changed. (CLI --version output and the server log banner only; nothing under web-nodejs/lang/.)
  • All new or changed keys exist in every web-nodejs/lang/*.json locale with proper translations.

Attribution

  • Contributions and design/reporting sources are credited accurately. (Reported from operating a RustDesk-compatible BetterDesk deployment; no external code reused.)
  • If code was directly reused, author/licence attribution is preserved. (No code reused.)

release-server.yml builds with only `-X main.Version`, so `--version` and
the startup banner printed "built unknown" for every released asset even
though the repository's documented build command sets `main.BuildDate`.

Pass `-X main.BuildDate=<utc timestamp>` in the release build and fall
back to the embedded `vcs.time` in init(), so builds that do not pass the
flag (installer, local builds, other CI) report a real date as well.
@mh254
mh254 requested a review from UNITRONIX as a code owner November 9, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant