change llama-swap to use goreleaser default ldflag values

This commit is contained in:
Benson Wong
2024-12-14 10:29:57 -08:00
parent d4e22cceaa
commit 27302c0c02
2 changed files with 9 additions and 6 deletions

View File

@@ -12,6 +12,9 @@ endif
# Get the build number from the commit count on the main branch # Get the build number from the commit count on the main branch
COMMIT_COUNT := $(shell git rev-list --count HEAD) COMMIT_COUNT := $(shell git rev-list --count HEAD)
# Capture the current build date in RFC3339 format
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# Default target: Builds binaries for both OSX and Linux # Default target: Builds binaries for both OSX and Linux
all: mac linux simple-responder all: mac linux simple-responder
@@ -28,12 +31,12 @@ test-all:
# Build OSX binary # Build OSX binary
mac: mac:
@echo "Building Mac binary..." @echo "Building Mac binary..."
GOOS=darwin GOARCH=arm64 go build -ldflags="-X main.GIT_HASH=${GIT_HASH} -X main.COMMIT_COUNT=${COMMIT_COUNT}" -o $(BUILD_DIR)/$(APP_NAME)-darwin-arm64 GOOS=darwin GOARCH=arm64 go build -ldflags="-X main.commit=${GIT_HASH} -X main.version=${COMMIT_COUNT} -X main.date=${BUILD_DATE}" -o $(BUILD_DIR)/$(APP_NAME)-darwin-arm64
# Build Linux binary # Build Linux binary
linux: linux:
@echo "Building Linux binary..." @echo "Building Linux binary..."
GOOS=linux GOARCH=amd64 go build -ldflags="-X main.GIT_HASH=${GIT_HASH} -X main.COMMIT_COUNT=${COMMIT_COUNT}" -o $(BUILD_DIR)/$(APP_NAME)-linux-amd64 GOOS=linux GOARCH=amd64 go build -ldflags="-X main.commit=${GIT_HASH} -X main.version=${COMMIT_COUNT} -X main.date=${BUILD_DATE}" -o $(BUILD_DIR)/$(APP_NAME)-linux-amd64
# for testing proxy.Process # for testing proxy.Process
simple-responder: simple-responder:

View File

@@ -9,9 +9,9 @@ import (
"github.com/mostlygeek/llama-swap/proxy" "github.com/mostlygeek/llama-swap/proxy"
) )
// see Makefile which injects new values at build time var version string = "0"
var GIT_HASH string = "abcd1234" var commit string = "abcd1234"
var COMMIT_COUNT string = "0-dev" var date = "unknown"
func main() { func main() {
// Define a command-line flag for the port // Define a command-line flag for the port
@@ -22,7 +22,7 @@ func main() {
flag.Parse() // Parse the command-line flags flag.Parse() // Parse the command-line flags
if *showVersion { if *showVersion {
fmt.Printf("version: v%s (%s)\n", COMMIT_COUNT, GIT_HASH) fmt.Printf("version: v%s (%s), built at %s\n", version, commit, date)
os.Exit(0) os.Exit(0)
} }