Skip to content

Commit d31e915

Browse files
committed
Set main.version through ldflags for release builds
1 parent eb2e1cc commit d31e915

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: Makefile.dist

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ PROJECT := $(CURRENT_DIR:$(GOPATH)/src/%=%)
2323
NAME := $(notdir $(PROJECT))
2424
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
2525
VERSION ?= $(shell git describe --always)
26+
LD_FLAGS := -X main.version=${VERSION}
2627

2728
# Create a cross-compile target for every os-arch pairing. This will generate
2829
# a make target for each os/arch like "make linux/amd64" as well as generate a
@@ -34,11 +35,11 @@ define make-xc-target
3435
else ifeq (${1},windows)
3536
@printf "%s%20s %s\n" "-->" "${1}/${2}:" "${PROJECT} (-w -extldflags "-static" -extld ${WINDOWS_EXTLD_${2}})"
3637
@xgo -go ${GOVERSION} -deps ${LIBTOOL_PATH} -targets '${1}-${WINDOWS_API_LEVEL}/${2}' \
37-
-ldflags '-w -extldflags "-static" -extld ${WINDOWS_EXTLD_${2}}' .
38+
-ldflags '${LD_FLAGS} -w -extldflags "-static" -extld ${WINDOWS_EXTLD_${2}}' .
3839
@mv ghostunnel-${1}-${WINDOWS_API_LEVEL}-${2}.exe dist/ghostunnel-${VERSION}-${1}-${2}-with-pkcs11.exe
3940
else
4041
@printf "%s%20s %s\n" "-->" "${1}/${2}:" "${PROJECT}"
41-
@xgo -go ${GOVERSION} -deps ${LIBTOOL_PATH} -targets '${1}/${2}' .
42+
@xgo -go ${GOVERSION} -deps ${LIBTOOL_PATH} -ldflags "${LD_FLAGS}" -targets '${1}/${2}' .
4243
@mv ghostunnel-${1}*-${2} dist/ghostunnel-${VERSION}-${1}-${2}-with-pkcs11
4344
endif
4445
.PHONY: $1/$2

Diff for: main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
)
4343

4444
var (
45-
version = "v1.2.0-rc.2"
45+
version = "master"
4646
defaultMetricsPrefix = "ghostunnel"
4747
)
4848

0 commit comments

Comments
 (0)