feat: embed build version info in binaries
This commit is contained in:
24
Makefile
Normal file
24
Makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
APP=inps
|
||||
|
||||
VERSION ?= 0.1.0
|
||||
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
BUILD_TIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
|
||||
GO_VERSION := $(shell go env GOVERSION 2>/dev/null || echo unknown)
|
||||
|
||||
LDFLAGS := -s -w \
|
||||
-X 'github.com/openp2p-cn/inp2p/pkg/config.Version=$(VERSION)' \
|
||||
-X 'github.com/openp2p-cn/inp2p/pkg/config.GitCommit=$(GIT_COMMIT)' \
|
||||
-X 'github.com/openp2p-cn/inp2p/pkg/config.BuildTime=$(BUILD_TIME)' \
|
||||
-X 'github.com/openp2p-cn/inp2p/pkg/config.GoVersion=$(GO_VERSION)'
|
||||
|
||||
.PHONY: build build-client build-server
|
||||
|
||||
build: build-client build-server
|
||||
|
||||
build-client:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
|
||||
go build -ldflags "$(LDFLAGS)" -o bin/inp2pc ./cmd/inp2pc
|
||||
|
||||
build-server:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
|
||||
go build -ldflags "$(LDFLAGS)" -o bin/inp2ps ./cmd/inp2ps
|
||||
Reference in New Issue
Block a user