Skip to content

build/cli: inject Version from nightly tag, plus show help on bare ehco - #441

Merged
Ehco1996 merged 3 commits into
masterfrom
fix/version-injection-from-git
May 2, 2026
Merged

build/cli: inject Version from nightly tag, plus show help on bare ehco#441
Ehco1996 merged 3 commits into
masterfrom
fix/version-injection-from-git

Conversation

@Ehco1996

@Ehco1996 Ehco1996 commented May 1, 2026

Copy link
Copy Markdown
Owner

Two small follow-ups to #440 in one PR.

1. Inject Version for non-goreleaser builds

The Makefile ldflags injected GitBranch / GitRevision / BuildTime but not Version, so any binary produced by make build (Docker images included) self-reported as the literal "1.1.6" baked into internal/constant/constant.go. That defeats the update command's nightly auto-detection: a post-1.1.6 master binary looked identical to released v1.1.6 and would either silently no-op or get rolled backward.

Pin the injected Version to the most recent reachable nightly tag so make build matches the convention enforced by .github/workflows/nightly.yml (master between v1.1.6 and v1.1.7 → reports 1.1.7-next, matching the rolling nightly artifact).

Resolution order:

  1. nearest reachable v*-next tag (normal case → 1.1.7-next)
  2. nearest reachable stable tag (the brief window between a release and the next nightly cron)
  3. empty → falls back to the constant.Version source default

goreleaser paths are unaffected — they keep injecting their own GORELEASER_CURRENT_TAG.

Source-default Version also bumped from 1.1.6 to 1.1.7-next so raw go build cmd/ehco/main.go (no Makefile, no goreleaser) on master still self-identifies as the current nightly line.

2. ehco with no args prints help instead of fataling

Running bare ehco (no -c, no -l, no env) used to fall through to startAction -> InitConfigAndComponents -> Fatalf("invalid listen"). Confusing for a first-time user. Detect "no config source given" up front and print app help instead.

Test plan

  • make build on this branch reports Version=1.1.7-next (verified locally)
  • ./dist/ehco with no args prints app help and exits 0 (verified locally)
  • All generated version strings pass golang.org/x/mod/semver.IsValid
  • go vet ./... clean
  • On a server, make build + ./dist/ehco update should: auto-detect nightly channel, fetch latest v*-next release, semver-compare and either upgrade or report "already up to date"
  • Existing flows unchanged: ehco -c <path>, ehco -l ... -r ..., env-var-only invocation

🤖 Generated with Claude Code

Ehco1996 and others added 2 commits May 2, 2026 07:31
The Makefile only injected GitBranch/GitRevision/BuildTime via ldflags;
Version came from the hardcoded "1.1.6" literal in
internal/constant/constant.go, last bumped at the v1.1.6 release. Any
master binary produced via `make build` (or anything that shells out to
the Makefile) self-reported as 1.1.6 even when it was several commits
ahead. That defeated the update command's nightly auto-detection: a
post-1.1.6 master binary looked identical to released 1.1.6 and would
either silently no-op or, in combination with the prerelease bug fixed
in #440, get rolled backward.

Compute a semver-valid VERSION from `git describe`:
  - on a stable tag exactly        -> X.Y.Z
  - N commits past last stable tag -> X.Y.Z-dev.N+gSHA
  - no stable tag reachable        -> falls back to the source default

The output is valid semver (verified against golang.org/x/mod/semver),
so the update command's compareVersions / channel detection treat it
correctly: any -dev build auto-routes to the nightly channel and never
gets downgraded to a strictly older stable.

Also bump the source-default Version from 1.1.6 to 1.1.7-next so raw
`go build cmd/ehco/main.go` (no Makefile, no goreleaser) on master still
self-identifies as a nightly-channel build, matching the existing tag
naming convention.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous approach derived VERSION as `X.Y.Z-dev.N+gSHA` from the
last stable tag. That doesn't match the project's nightly convention:
master between v1.1.6 and v1.1.7 should self-report as `1.1.7-next`
(matching the rolling nightly tag created by .github/workflows/nightly.yml),
not `1.1.6-dev.8+g...`.

Switch to: take the most recent reachable v*-next tag verbatim, fall
back to the latest stable tag for the brief window between a release
and the next nightly cron, then to the source default if no tags exist.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Ehco1996 Ehco1996 changed the title build: derive Version from git in Makefile so master builds aren't stale build: inject Version from latest nightly tag for non-goreleaser builds May 1, 2026
Running \`ehco\` with no args, no -c config path, and no -l listen
address used to fall through to startAction -> InitConfigAndComponents
-> Fatalf("invalid listen"). Confusing for first-time users.

Detect "no config source given" up front and print app help instead.
Existing flows (-c config_file, -l/-r inline relay, env vars) are
unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Ehco1996 Ehco1996 changed the title build: inject Version from latest nightly tag for non-goreleaser builds build/cli: inject Version from nightly tag, plus show help on bare ehco May 1, 2026
@Ehco1996
Ehco1996 merged commit c5e2302 into master May 2, 2026
1 check passed
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