From 7135fe4c492e645e118460f71d1a528b59faec91 Mon Sep 17 00:00:00 2001 From: Daniel Steigman <35793213+NightTrek@users.noreply.github.com> Date: Mon, 13 Oct 2025 00:18:18 -0700 Subject: [PATCH] feat: Add version information injection to CLI build script (#6780) * feat: add version information injection to CLI build script - Extract version from package.json - Capture git commit hash, build date, and builder info - Inject version info into CLI binaries via Go ldflags - Update both cline and cline-host builds with version data * chore: add changeset for CLI version injection --- .changeset/cli-version-injection.md | 5 +++++ scripts/build-cli.sh | 23 +++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 .changeset/cli-version-injection.md diff --git a/.changeset/cli-version-injection.md b/.changeset/cli-version-injection.md new file mode 100644 index 00000000..768471f1 --- /dev/null +++ b/.changeset/cli-version-injection.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Add version information injection to CLI build script. The CLI binaries now include version, commit hash, build date, and builder information extracted from package.json and git, improving debugging and version tracking capabilities. \ No newline at end of file diff --git a/scripts/build-cli.sh b/scripts/build-cli.sh index f91cdd16..b4314960 100755 --- a/scripts/build-cli.sh +++ b/scripts/build-cli.sh @@ -7,15 +7,26 @@ npm run protos-go mkdir -p dist-standalone/extension cp package.json dist-standalone/extension -cd cli -GO111MODULE=on go build -o bin/cline ./cmd/cline -echo 'cli/bin/cline built' -GO111MODULE=on go build -o bin/cline-host ./cmd/cline-host -echo 'cli/bin/cline-host built' +# Extract version information for ldflags +VERSION=$(node -p "require('./package.json').version") +COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown") +DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ') +BUILT_BY="${USER:-unknown}" +# Build ldflags to inject version info +LDFLAGS="-X 'github.com/cline/cli/pkg/cli.Version=${VERSION}' \ + -X 'github.com/cline/cli/pkg/cli.Commit=${COMMIT}' \ + -X 'github.com/cline/cli/pkg/cli.Date=${DATE}' \ + -X 'github.com/cline/cli/pkg/cli.BuiltBy=${BUILT_BY}'" + +cd cli +GO111MODULE=on go build -ldflags "$LDFLAGS" -o bin/cline ./cmd/cline +echo 'cli/bin/cline built' +GO111MODULE=on go build -ldflags "$LDFLAGS" -o bin/cline-host ./cmd/cline-host +echo 'cli/bin/cline-host built' # Copy binaries to dist-standalone/bin cd .. mkdir -p dist-standalone/bin cp cli/bin/cline dist-standalone/bin/cline cp cli/bin/cline-host dist-standalone/bin/cline-host -echo 'Copied binaries to dist-standalone/bin/' +echo 'Copied binaries to dist-standalone/bin/' \ No newline at end of file