From affeb098ad451d9c57090cff0711ba4008cd4419 Mon Sep 17 00:00:00 2001 From: Philip Zeyliger Date: Mon, 19 Jan 2026 20:00:13 -0800 Subject: [PATCH] shelley: add version/tag to build via goreleaser ldflags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Include Version and Tag in `shelley version` output, injected at build time by GoReleaser. Local builds show "dev" for version. Also fix false positive "modified=true" in UI build by filtering out dist/ directory from git status check. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .goreleaser.yml | 2 ++ ui/scripts/build.js | 9 +++++++-- version/version.go | 13 ++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index f6f4817b9f81da72f56002270b4d00f0e2d978b2..65f07c1f88979cdd40a5f086e37d31bf03de2c85 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -18,6 +18,8 @@ builds: - arm64 ldflags: - -s -w + - -X shelley.exe.dev/version.Version={{ .Version }} + - -X shelley.exe.dev/version.Tag={{ .Tag }} archives: - id: shelley diff --git a/ui/scripts/build.js b/ui/scripts/build.js index bca72702ba18fb32ecdfbb8bba0d8db405d4c89f..af46092ca0f381b444d4027df5238eed7583cd1c 100644 --- a/ui/scripts/build.js +++ b/ui/scripts/build.js @@ -81,8 +81,13 @@ async function build() { try { commit = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim(); commitTime = execSync('git log -1 --format=%cI', { encoding: 'utf8' }).trim(); - const status = execSync('git status --porcelain', { encoding: 'utf8' }); - modified = status.length > 0; + // Check for modifications, excluding the dist/ directory (which we're currently building) + const status = execSync('git status --porcelain --ignore-submodules', { encoding: 'utf8' }); + // Filter out dist/ changes since those are expected during build + const significantChanges = status.split('\n').filter(line => + line.trim() && !line.includes('dist/') + ); + modified = significantChanges.length > 0; } catch (e) { // Git not available or not a git repo } diff --git a/version/version.go b/version/version.go index cea0c08e25c0ae7e04e0930aa3335658f5f4fbb1..618ca17155d5f08a2d8c0ab0a6a70d050b0ceb38 100644 --- a/version/version.go +++ b/version/version.go @@ -8,8 +8,16 @@ import ( "shelley.exe.dev/ui" ) +// Version and Tag are set at build time via ldflags +var ( + Version = "dev" + Tag = "" +) + // Info holds build information from runtime/debug.ReadBuildInfo type Info struct { + Version string `json:"version,omitempty"` + Tag string `json:"tag,omitempty"` Commit string `json:"commit,omitempty"` CommitTime string `json:"commit_time,omitempty"` Modified bool `json:"modified,omitempty"` @@ -18,7 +26,10 @@ type Info struct { // GetInfo returns build information using runtime/debug.ReadBuildInfo, // falling back to the embedded build-info.json from the UI build. func GetInfo() Info { - var info Info + info := Info{ + Version: Version, + Tag: Tag, + } buildInfo, ok := debug.ReadBuildInfo() if ok {