Skip to content

cli: add lightchain-worker version and stamp the release tag into builds - #33

Open
draevik wants to merge 1 commit into
lightchain-protocol:mainfrom
draevik:cli-version-command
Open

draevik wants to merge 1 commit into
lightchain-protocol:mainfrom
draevik:cli-version-command

Conversation

@draevik

@draevik draevik commented Oct 20, 2026

Copy link
Copy Markdown

Why

There is no way to tell which build a worker host is running. The CLI has no version command, make release builds with -ldflags="-s -w" only, and the Docker image stamps nothing. An operator asking for help, or anyone checking that hosts are on the current release, has to guess from install dates.

This is also the first step toward deliverable D6 in the compute grants proposal (draft v4.1, section 3.3, item 4), which makes "a worker version string" a condition for paid slots and notes that no current build sends one today. This PR gives the binary a version to report; sending it in the heartbeat is the follow-up described below.

Proposal: https://github.com/lightchain-protocol/lightchain-dao-proposals/tree/main/proposals/2026-10-compute-grants

What

  • internal/buildinfo: Version (set with -X, default dev), plus the commit and dirty flag the Go toolchain records, the Go version and the platform.
  • lightchain-worker version (and --version) prints one line, for example lightchain-worker v1.2.3 (commit 1a2b3c4d5e6f, go1.26.0, linux/amd64). Added to the usage text.
  • The sidecar logs the build on start, so it appears in journalctl and container logs.
  • Makefile: VERSION is the tag on a CI tag build (GITHUB_REF_TYPE/GITHUB_REF_NAME), otherwise git describe --tags --always --dirty, otherwise dev. It can be overridden with make release VERSION=….
  • Dockerfile: ARG VERSION=dev passed to both builds. CI passes steps.meta.outputs.version, so the image reports the tag, branch or commit it is published as.
  • README: one line under Releases.

Not in this PR

The heartbeat payloads are unchanged. The gateway that reads them is not in this repository, so I didn't want to add a field it might reject. If the gateway accepts an extra field, I can follow up with a workerVersion field in the heartbeat.

Testing

  • go test ./internal/buildinfo/ covers four cases: a release with a commit, a dirty local build, no VCS data (as in the image), and build info being unavailable.
  • go test ./... with the shared package (testnet): all pass
  • make release VERSION=v0.0.0-test then ./dist/lightchain-worker-linux-amd64 version prints lightchain-worker v0.0.0-test (commit d371cd2f7f3b-dirty, go1.27.1, linux/amd64)
  • docker build --build-arg VERSION=v0.0.0-test -f worker/Dockerfile . then docker run --rm --entrypoint /bin/lightchain-worker <image> version. CI builds the image on this PR.

The patch applies cleanly on main and on top of #31.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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