Skip to content

Use ldflags for build versioning #13

@kernelshard

Description

@kernelshard

Problem

The version information added in #12 currently uses placeholder values. We need to inject version, commit hash, and build date at build time.

Proposed Solution

Use Go's -ldflags during build to inject version information:

go build -ldflags "-X main.Version=${VERSION} -X main.Commit=${COMMIT} -X main.BuildDate=${DATE}"

Implementation Details

  • Update Makefile/build script to use ldflags
  • Extract version from git tags (e.g., git describe --tags)
  • Extract commit hash from git (e.g., git rev-parse HEAD)
  • Generate build date (e.g., date -u +"%Y-%m-%dT%H:%M:%SZ")

Benefits

  • No need to manually update version in code
  • Accurate build metadata for debugging
  • Follows Go best practices for versioning

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions