From: Jeff Halter Date: Sat, 27 Jul 2024 22:40:57 +0000 (-0700) Subject: Fix missing version in Docker and Makefile build X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/commitdiff_plain/09261d2b52fa739bb6321c866566223f11061201?hp=117c2040b807dfd3cc578e8b5ba07ce504b102fe Fix missing version in Docker and Makefile build --- diff --git a/Dockerfile b/Dockerfile index ee33b0e..f5b2af6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.22 AS builder WORKDIR /app COPY . . -RUN CGO_ENABLED=0 go build -o /app/server cmd/mobius-hotline-server/main.go && chmod a+x /app/server +RUN CGO_ENABLED=0 go build -ldflags "-X main.version=$(git describe --exact-match --tags)" -o /app/server cmd/mobius-hotline-server/main.go && chmod a+x /app/server FROM scratch diff --git a/Makefile b/Makefile index 2832baa..54a8631 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,2 @@ server: - go build -o mobius-hotline-server cmd/mobius-hotline-server/main.go - -client: - go build -o mobius-hotline-client cmd/mobius-hotline-client/main.go \ No newline at end of file + go build -ldflags "-X main.version=$$(git describe --exact-match --tags || echo "dev" ) -X main.commit=$$(git rev-parse --short HEAD)" -o mobius-hotline-server cmd/mobius-hotline-server/main.go diff --git a/cmd/mobius-hotline-server/main.go b/cmd/mobius-hotline-server/main.go index 1390dda..e4e0954 100644 --- a/cmd/mobius-hotline-server/main.go +++ b/cmd/mobius-hotline-server/main.go @@ -24,7 +24,6 @@ var cfgTemplate embed.FS var ( version = "dev" commit = "none" - date = "unknown" ) func main() { @@ -45,7 +44,7 @@ func main() { flag.Parse() if *printVersion { - fmt.Printf("mobius-hotline-server %s, commit %s, built on %s\n", version, commit, date) + fmt.Printf("mobius-hotline-server version %s, commit %s\n", version, commit) os.Exit(0) }