From d61f5d6628b788acb6dcd4df67662636ab4894ac Mon Sep 17 00:00:00 2001 From: Kevin Tang <73975146+vt128@users.noreply.github.com> Date: Tue, 23 Jun 2026 11:47:59 +0800 Subject: [PATCH] [fix] release banner: restore colorlogo (random gradient) + correct version fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The goreleaser-built binaries had a regressed --version banner. Fix the fields and restore the logo colouring: - config/build.go: bring colorlogo back (a deliberate keep — it adds real cosmetic value, unlike the dead hlog/winornot/gut) and pick one of several presets at random each run, so the banner varies on every launch. - .goreleaser.yaml: GitSummary now uses the full tag ({{ .Tag }} -> v0.1.2, matching `git describe`) instead of the v-stripped {{ .Version }}; inject GoVersion via a GOVERSION env (no built-in template var, and it must be a single token — `go version ...` has spaces that break linking, so use `go env GOVERSION`); drop GitBranch (a tag build is a detached HEAD, so it only ever showed "HEAD"). - release.yml: export GOVERSION before GoReleaser. The Makefile's own ldflags (used by `make build` and the Docker image) are unchanged and still inject the full set. Verified with a local `goreleaser build --snapshot`: GoVersion present, GitSummary=v0.1.2, no stray branch. No new release cut — this rides the next tag. --- .github/workflows/release.yml | 5 +++++ .goreleaser.yaml | 13 +++++++++++-- config/build.go | 31 +++++++++++++++++++------------ go.mod | 2 +- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b231934..9d699b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,11 @@ jobs: - uses: actions/setup-go@v6 with: go-version: "1.25.x" + - name: Capture Go version + # GoReleaser has no built-in go-version var; expose it for the ldflags. + # Use `go env GOVERSION` (e.g. go1.25.9) — a single token, since ldflag + # values must not contain spaces (`go version ...` would break linking). + run: echo "GOVERSION=$(go env GOVERSION)" >> "$GITHUB_ENV" - name: Run GoReleaser # Third-party action pinned to a full commit SHA (supply-chain policy). uses: goreleaser/goreleaser-action@5daf1e915a5f0af01ddbcd89a43b8061ff4f1a89 # v7.2.2 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index bc75ba0..03f20c7 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -7,6 +7,12 @@ version: 2 project_name: starcli +# GoVersion isn't a built-in GoReleaser template var, so the release workflow +# exports `GOVERSION=$(go version)` into the env; this entry surfaces it (and +# stays empty for a local `--snapshot` where it isn't set, rather than erroring). +env: + - GOVERSION={{ if index .Env "GOVERSION" }}{{ .Env.GOVERSION }}{{ end }} + before: hooks: - go mod download @@ -33,9 +39,12 @@ builds: ldflags: - -s -w - -X github.com/1set/starcli/config.AppName=starcli - - -X github.com/1set/starcli/config.GitSummary={{ .Version }} + # GitSummary uses the full tag (e.g. v0.1.2), matching `git describe`; the + # GitBranch field is intentionally omitted — a tag build is on a detached + # HEAD, so a "branch" is meaningless there. + - -X github.com/1set/starcli/config.GitSummary={{ .Tag }} - -X github.com/1set/starcli/config.GitCommit={{ .ShortCommit }} - - -X github.com/1set/starcli/config.GitBranch={{ .Branch }} + - -X github.com/1set/starcli/config.GoVersion={{ .Env.GOVERSION }} - -X github.com/1set/starcli/config.BuildDate={{ .Date }} archives: diff --git a/config/build.go b/config/build.go index a6c128a..6d266a9 100644 --- a/config/build.go +++ b/config/build.go @@ -3,8 +3,11 @@ package config import ( _ "embed" "fmt" + "math/rand" "runtime" "strings" + + cl "bitbucket.org/ai69/colorlogo" ) // revive:disable:exported @@ -24,11 +27,25 @@ var ( logoArt string ) +// logoGradients is a set of colorlogo colour-scheme presets; DisplayBuildInfo +// picks one at random each run, so the banner shows a different palette on every +// launch. +var logoGradients = []func(string) string{ + cl.OceanSandByColumn, + cl.AnamnisarByColumn, + cl.IbizaSunsetByColumn, + cl.PurpleParadiseByColumn, + cl.RainbowBlueByColumn, + cl.EveningNightByColumn, + cl.SublimeVividByColumn, + cl.CherryBlossomsByColumn, +} + // DisplayBuildInfo prints the build information to the console. func DisplayBuildInfo() { - // write logo + // write the logo with a randomly chosen colour scheme var sb strings.Builder - sb.WriteString(colorizeLogo(logoArt)) + sb.WriteString(logoGradients[rand.Intn(len(logoGradients))](logoArt)) sb.WriteString("\n") // inline helpers @@ -52,13 +69,3 @@ func DisplayBuildInfo() { fmt.Println(sb.String()) } - -// colorizeLogo renders the logo art with a per-line ANSI 256-colour gradient. -func colorizeLogo(art string) string { - palette := []int{45, 44, 43, 49, 48, 84, 78, 79} // teal → green gradient - var sb strings.Builder - for i, line := range strings.Split(strings.TrimRight(art, "\n"), "\n") { - fmt.Fprintf(&sb, "\x1b[38;5;%dm%s\x1b[0m\n", palette[i%len(palette)], line) - } - return sb.String() -} diff --git a/go.mod b/go.mod index 0cadb88..bda795c 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/1set/starcli go 1.25.8 require ( + bitbucket.org/ai69/colorlogo v0.1.3 github.com/1set/starbox v0.2.0 github.com/1set/starlet v0.2.2 github.com/kyokomi/emoji/v2 v2.2.13 @@ -31,7 +32,6 @@ require ( ) require ( - bitbucket.org/ai69/colorlogo v0.1.3 // indirect bitbucket.org/creachadair/shell v0.0.8 // indirect charm.land/bubbles/v2 v2.0.0 // indirect charm.land/bubbletea/v2 v2.0.2 // indirect