mirror of
https://github.com/nicksherron/bashhub-server.git
synced 2025-10-11 05:15:45 +08:00
version command
This commit is contained in:
parent
376ddc8e1b
commit
225056870a
2 changed files with 4 additions and 5 deletions
5
Makefile
5
Makefile
|
@ -1,8 +1,7 @@
|
||||||
.PHONY: build build-alpine clean test help default docker-build
|
.PHONY: build build-alpine clean test help default docker-build
|
||||||
|
|
||||||
BIN_NAME=bashhub-server
|
BIN_NAME=bashhub-server
|
||||||
|
VERSION=$(shell git tag | sort --version-sort -r | head -1)
|
||||||
VERSION := $(shell grep "const Version " version/version.go | sed -E 's/.*"(.+)"$$/\1/')
|
|
||||||
GIT_COMMIT=$(shell git rev-parse HEAD)
|
GIT_COMMIT=$(shell git rev-parse HEAD)
|
||||||
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
|
||||||
BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
|
BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
|
||||||
|
@ -27,7 +26,7 @@ help:
|
||||||
build:
|
build:
|
||||||
@echo "building ${BIN_NAME} ${VERSION}"
|
@echo "building ${BIN_NAME} ${VERSION}"
|
||||||
@echo "GOPATH=${GOPATH}"
|
@echo "GOPATH=${GOPATH}"
|
||||||
go build -ldflags "-X github.com/nicksherron/bashhub-server/cmd.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X github.com/nicksherron/bashhub-server/cmd.BuildDate=${BUILD_DATE}" -o bin/${BIN_NAME}
|
go build -ldflags "-X github.com/nicksherron/bashhub-server/cmd.Version=${VERSION} -X github.com/nicksherron/bashhub-server/cmd.GitCommit=${GIT_COMMIT} -X github.com/nicksherron/bashhub-server/cmd.BuildDate=${BUILD_DATE}" -o bin/${BIN_NAME}
|
||||||
|
|
||||||
get-deps:
|
get-deps:
|
||||||
dep ensure
|
dep ensure
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
|
|
||||||
// versionCmd represents the version command
|
// versionCmd represents the version command
|
||||||
var (
|
var (
|
||||||
Build string
|
GitCommit string
|
||||||
BuildDate string
|
BuildDate string
|
||||||
Version string
|
Version string
|
||||||
OsArch = fmt.Sprintf("%s %s", runtime.GOOS, runtime.GOARCH)
|
OsArch = fmt.Sprintf("%s %s", runtime.GOOS, runtime.GOARCH)
|
||||||
|
@ -36,7 +36,7 @@ var (
|
||||||
Short: "Print the version number and build info",
|
Short: "Print the version number and build info",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
fmt.Println("Build Date:", BuildDate)
|
fmt.Println("Build Date:", BuildDate)
|
||||||
fmt.Println("Git Commit:", Build)
|
fmt.Println("Git Commit:", GitCommit)
|
||||||
fmt.Println("Version:", Version)
|
fmt.Println("Version:", Version)
|
||||||
fmt.Println("Go Version:", GoVersion)
|
fmt.Println("Go Version:", GoVersion)
|
||||||
fmt.Println("OS / Arch:", OsArch)
|
fmt.Println("OS / Arch:", OsArch)
|
||||||
|
|
Loading…
Add table
Reference in a new issue