optimize Makefile

pull/393/head
Michael Li 9 months ago
parent 2c353ca9ad
commit dcc10ee87d
No known key found for this signature in database

@ -18,15 +18,16 @@ RELEASE_DARWIN_AMD64 = $(RELEASE_ROOT)/darwin-amd64/$(PROJECT)
RELEASE_DARWIN_ARM64 = $(RELEASE_ROOT)/darwin-arm64/$(PROJECT)
RELEASE_WINDOWS_AMD64 = $(RELEASE_ROOT)/windows-amd64/$(PROJECT)
BUILD_VERSION := $(shell git describe --tags --always | cut -f 1 -f 2 -d "-")
BUILD_DATE := $(shell date +'%Y-%m-%d %H:%M:%S')
BUILD_VERSION := $(shell git describe --tags --always)
BUILD_DATE := $(shell date +'%Y-%m-%d %H:%M:%S %Z')
SHA_SHORT := $(shell git rev-parse --short HEAD)
TAGS = ""
MOD_NAME = github.com/rocboss/paopao-ce
LDFLAGS = -X "${MOD_NAME}/pkg/version.version=${BUILD_VERSION}" \
-X "${MOD_NAME}/pkg/version.buildDate=${BUILD_DATE}" \
-X "${MOD_NAME}/pkg/version.commitID=${SHA_SHORT}" -w -s
-X "${MOD_NAME}/pkg/version.commitID=${SHA_SHORT}" \
-X "${MOD_NAME}/pkg/version.buildTags=${TAGS}" \
-w -s
all: fmt build

@ -2,7 +2,7 @@
# eg.1 : sh build-image.sh
# eg.2, set image: sh build-image.sh bitbus/paopao-ce
VERSION=`git describe --tags --always | cut -f1 -f2 -d "-"` # eg.: 0.2.5
VERSION=`git describe --tags --always | cut -f1,2 -d "-"` # eg.: 0.2.5
IMAGE="bitbus/paopao-ce"
if [ -n "$1" ]; then

@ -8,25 +8,35 @@ import (
"fmt"
)
var version, commitID, buildDate string
const (
series = "v0.5.0-dev"
)
var (
version = "unknown"
commitID = "unknown"
buildDate = "unknown"
buildTags = "unknown"
)
type BuildInfo struct {
Series string `json:"series"`
Version string `json:"version"`
Sum string `json:"sum"`
BuildDate string `json:"build_date"`
BuildTags string `json:"build_tags"`
}
func VersionInfo() string {
return fmt.Sprintf("paopao %s (build:%s %s)", version, commitID, buildDate)
return fmt.Sprintf("paopao %s (build:%s %s)", series, commitID, buildDate)
}
func ReadBuildInfo() *BuildInfo {
if version == "" {
version = "unknow"
}
return &BuildInfo{
Series: series,
Version: version,
Sum: commitID,
BuildDate: buildDate,
BuildTags: buildTags,
}
}

Loading…
Cancel
Save