build/cli: inject Version from nightly tag, plus show help on bare ehco - #441
Merged
Conversation
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>
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>
ehco
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small follow-ups to #440 in one PR.
1. Inject
Versionfor non-goreleaser buildsThe
Makefileldflags injectedGitBranch / GitRevision / BuildTimebut notVersion, so any binary produced bymake build(Docker images included) self-reported as the literal"1.1.6"baked intointernal/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
Versionto the most recent reachable nightly tag somake buildmatches the convention enforced by.github/workflows/nightly.yml(master between v1.1.6 and v1.1.7 → reports1.1.7-next, matching the rolling nightly artifact).Resolution order:
v*-nexttag (normal case →1.1.7-next)constant.Versionsource defaultgoreleaserpaths are unaffected — they keep injecting their ownGORELEASER_CURRENT_TAG.Source-default
Versionalso bumped from1.1.6to1.1.7-nextso rawgo build cmd/ehco/main.go(no Makefile, no goreleaser) on master still self-identifies as the current nightly line.2.
ehcowith no args prints help instead of fatalingRunning bare
ehco(no-c, no-l, no env) used to fall through tostartAction->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 buildon this branch reportsVersion=1.1.7-next(verified locally)./dist/ehcowith no args prints app help and exits 0 (verified locally)golang.org/x/mod/semver.IsValidgo vet ./...cleanmake build+./dist/ehco updateshould: auto-detect nightly channel, fetch latestv*-nextrelease, semver-compare and either upgrade or report "already up to date"ehco -c <path>,ehco -l ... -r ..., env-var-only invocation🤖 Generated with Claude Code