Skip to content

Commit 63f0999

Browse files
committed
chore(release): Prepare for release v1.2.1
- Update CHANGELOG.md with details of the fix. - Refactor version handling to be managed in the main package. - Correct Makefile linker flags to properly embed version information.
1 parent 6cce299 commit 63f0999

4 files changed

Lines changed: 41 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.2.1] - 2025-08-18
9+
10+
### Fixed
11+
12+
- Fixed an issue where the version information was not correctly embedded in the binary during the `make` build process. The build script now correctly links the Git tag, commit hash, and build date.
13+
814
## [1.2.0] - 2025-08-14
915

1016
### Changed
@@ -43,4 +49,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4349

4450
### Fixed
4551

46-
- N/A (Initial Release)
52+
- N/A (Initial Release)

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ package: clean build
4848
build-macos:
4949
@echo "📦 Building for macOS (Universal)..."
5050
@mkdir -p ./${DIST_DIR}/macos
51-
@GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags="-X 'main.version=${VERSION}' -X 'main.commit=${GIT_COMMIT}' -X 'main.date=${BUILD_DATE}'" -o ./${DIST_DIR}/macos/${OUTPUT_NAME}_amd64 ./${SOURCE_FILE}
52-
@GOOS=darwin GOARCH=arm64 $(GOBUILD) -ldflags="-X 'main.version=${VERSION}' -X 'main.commit=${GIT_COMMIT}' -X 'main.date=${BUILD_DATE}'" -o ./${DIST_DIR}/macos/${OUTPUT_NAME}_arm64 ./${SOURCE_FILE}
51+
@GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags="-X 'main.Version=${VERSION}' -X 'main.Commit=${GIT_COMMIT}' -X 'main.Date=${BUILD_DATE}'" -o ./${DIST_DIR}/macos/${OUTPUT_NAME}_amd64 ./${SOURCE_FILE}
52+
@GOOS=darwin GOARCH=arm64 $(GOBUILD) -ldflags="-X 'main.Version=${VERSION}' -X 'main.Commit=${GIT_COMMIT}' -X 'main.Date=${BUILD_DATE}'" -o ./${DIST_DIR}/macos/${OUTPUT_NAME}_arm64 ./${SOURCE_FILE}
5353
@lipo -create -output ./${DIST_DIR}/macos/${OUTPUT_NAME} ./${DIST_DIR}/macos/${OUTPUT_NAME}_amd64 ./${DIST_DIR}/macos/${OUTPUT_NAME}_arm64
5454
@rm ./${DIST_DIR}/macos/${OUTPUT_NAME}_amd64 ./${DIST_DIR}/macos/${OUTPUT_NAME}_arm64
5555
@echo "🍏 macOS build complete: ./${DIST_DIR}/macos/${OUTPUT_NAME}"
@@ -58,14 +58,14 @@ build-macos:
5858
build-linux:
5959
@echo "📦 Building for Linux (amd64)..."
6060
@mkdir -p ./${DIST_DIR}/linux
61-
@GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags="-X 'main.version=${VERSION}' -X 'main.commit=${GIT_COMMIT}' -X 'main.date=${BUILD_DATE}'" -o ./${DIST_DIR}/linux/${OUTPUT_NAME} ./${SOURCE_FILE}
61+
@GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags="-X 'main.Version=${VERSION}' -X 'main.Commit=${GIT_COMMIT}' -X 'main.Date=${BUILD_DATE}'" -o ./${DIST_DIR}/linux/${OUTPUT_NAME} ./${SOURCE_FILE}
6262
@echo "🐧 Linux build complete: ./${DIST_DIR}/linux/${OUTPUT_NAME}"
6363

6464
# Build for Windows (amd64)
6565
build-windows:
6666
@echo "📦 Building for Windows (amd64)..."
6767
@mkdir -p ./${DIST_DIR}/windows
68-
@GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags="-X 'main.version=${VERSION}' -X 'main.commit=${GIT_COMMIT}' -X 'main.date=${BUILD_DATE}'" -o ./${DIST_DIR}/windows/${OUTPUT_NAME}.exe ./${SOURCE_FILE}
68+
@GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags="-X 'main.Version=${VERSION}' -X 'main.Commit=${GIT_COMMIT}' -X 'main.Date=${BUILD_DATE}'" -o ./${DIST_DIR}/windows/${OUTPUT_NAME}.exe ./${SOURCE_FILE}
6969
@echo "🪟 Windows build complete: ./${DIST_DIR}/windows/${OUTPUT_NAME}.exe"
7070

7171
# --- Quality & Verification ---

cmd/root.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cmd
22

33
import (
44
"errors"
5-
"flag"
65
"fmt"
76
"os"
87
"strings"
@@ -11,26 +10,22 @@ import (
1110
"splunk_cli/splunk"
1211
)
1312

14-
// These variables are set by the linker.
15-
var (
16-
Version = "dev"
17-
Commit = "none"
18-
Date = "unknown"
19-
)
20-
2113
func Execute() {
22-
var showVersion bool
2314
var configPath string
2415

25-
flag.BoolVar(&showVersion, "version", false, "Print version information and exit")
26-
flag.StringVar(&configPath, "config", "", "Path to a custom configuration file")
27-
flag.Parse()
28-
29-
if showVersion {
30-
fmt.Printf("splunk-cli version %s\ncommit %s\nbuilt at %s", Version, Commit, Date)
31-
os.Exit(0)
16+
// NOTE: We are not using flag.Parse() here at the top level anymore.
17+
// Each command will be responsible for parsing its own flags.
18+
// We manually check for the config flag.
19+
for i, arg := range os.Args {
20+
if (arg == "--config" || arg == "-config") && i+1 < len(os.Args) {
21+
configPath = os.Args[i+1]
22+
// Remove the flag and its value from os.Args so subcommands don't see it.
23+
os.Args = append(os.Args[:i], os.Args[i+2:]...)
24+
break
25+
}
3226
}
3327

28+
3429
if len(os.Args) < 2 {
3530
printUsage()
3631
os.Exit(1)
@@ -75,4 +70,4 @@ func Execute() {
7570
fmt.Fprintf(os.Stderr, "Error: %v", cmdErr)
7671
os.Exit(1)
7772
}
78-
}
73+
}

splunk-cli.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
package main
22

33
import (
4+
"fmt"
5+
"os"
46
"splunk_cli/cmd"
57
)
68

9+
// These variables are set by the linker.
10+
var (
11+
Version = "dev"
12+
Commit = "none"
13+
Date = "unknown"
14+
)
15+
716
func main() {
17+
// Manual check for the --version flag
18+
for _, arg := range os.Args {
19+
if arg == "--version" {
20+
fmt.Printf("splunk-cli version %s\ncommit %s\nbuilt at %s\n", Version, Commit, Date)
21+
os.Exit(0)
22+
}
23+
}
24+
825
cmd.Execute()
9-
}
26+
}

0 commit comments

Comments
 (0)