chore: cleanup version
parent
0f8084b13c
commit
f7fe5a896c
12
Makefile
12
Makefile
|
@ -1,17 +1,19 @@
|
|||
CLI_BIN := ./bin/doggo.bin
|
||||
API_BIN := ./bin/doggo-api.bin
|
||||
|
||||
HASH := $(shell git rev-parse --short HEAD)
|
||||
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
|
||||
VERSION := ${HASH}
|
||||
LAST_COMMIT := $(shell git rev-parse --short HEAD)
|
||||
LAST_COMMIT_DATE := $(shell git show -s --format=%cI ${LAST_COMMIT})
|
||||
VERSION := $(shell git describe --tags)
|
||||
BUILDSTR := ${VERSION} | Commit ${LAST_COMMIT_DATE}-${LAST_COMMIT} | Build $(shell date --iso-8601=seconds)
|
||||
|
||||
|
||||
.PHONY: build-cli
|
||||
build-cli:
|
||||
go build -o ${CLI_BIN} -ldflags="-X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'" ./cmd/doggo/
|
||||
go build -o ${CLI_BIN} -ldflags="-X 'main.buildString=${BUILDSTR}'" ./cmd/doggo/
|
||||
|
||||
.PHONY: build-api
|
||||
build-api:
|
||||
go build -o ${API_BIN} -ldflags="-X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'" ./cmd/api/
|
||||
go build -o ${API_BIN} -ldflags="-X 'main.buildString=${BUILDSTR}'" ./cmd/api/
|
||||
|
||||
.PHONY: build
|
||||
build: build-api build-cli
|
||||
|
|
|
@ -16,11 +16,11 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// Version of the build. This is injected at build-time.
|
||||
buildString = "unknown"
|
||||
|
||||
logger = utils.InitLogger()
|
||||
ko = koanf.New(".")
|
||||
// Version and date of the build. This is injected at build-time.
|
||||
buildVersion = "unknown"
|
||||
buildDate = "unknown"
|
||||
//go:embed assets/*
|
||||
assetsDir embed.FS
|
||||
//go:embed index.html
|
||||
|
@ -31,7 +31,7 @@ func main() {
|
|||
initConfig()
|
||||
|
||||
// Initialize app.
|
||||
app := app.New(logger, buildVersion)
|
||||
app := app.New(logger, buildString)
|
||||
|
||||
// Register router instance.
|
||||
r := chi.NewRouter()
|
||||
|
@ -69,6 +69,7 @@ func main() {
|
|||
|
||||
logger.WithFields(logf.Fields{
|
||||
"address": srv.Addr,
|
||||
"version": buildString,
|
||||
}).Info("starting server")
|
||||
|
||||
if err := srv.ListenAndServe(); err != nil {
|
||||
|
|
|
@ -34,7 +34,7 @@ func initConfig() {
|
|||
f.Parse(os.Args[1:])
|
||||
// Display version.
|
||||
if ok, _ := f.GetBool("version"); ok {
|
||||
fmt.Println(buildVersion, buildDate)
|
||||
fmt.Println(buildString)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,16 +15,15 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
// Version and date of the build. This is injected at build-time.
|
||||
buildVersion = "unknown"
|
||||
buildDate = "unknown"
|
||||
// Version of the build. This is injected at build-time.
|
||||
buildString = "unknown"
|
||||
logger = utils.InitLogger()
|
||||
k = koanf.New(".")
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Initialize app.
|
||||
app := app.New(logger, buildVersion)
|
||||
app := app.New(logger, buildString)
|
||||
|
||||
// Configure Flags.
|
||||
f := flag.NewFlagSet("config", flag.ContinueOnError)
|
||||
|
@ -70,7 +69,7 @@ func main() {
|
|||
|
||||
// If version flag is set, output version and quit.
|
||||
if k.Bool("version") {
|
||||
fmt.Printf("%s - %s\n", buildVersion, buildDate)
|
||||
fmt.Println(buildString)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ var appHelpTextTemplate = `{{ "NAME" | color "" "heading" }}:
|
|||
{{ .Name | color "green" "bold" }} [--] {{ "[query options]" | color "yellow" "" }} {{ "[arguments...]" | color "cyan" "" }}
|
||||
|
||||
{{ "VERSION" | color "" "heading" }}:
|
||||
{{.Version | color "red" "" }} - {{.Date | color "red" ""}}
|
||||
{{.Version | color "red" "" }}
|
||||
|
||||
{{ "EXAMPLES" | color "" "heading" }}:
|
||||
{{ .Name | color "green" "bold" }} {{ "mrkaran.dev" | color "cyan" "" }} Query a domain using defaults.
|
||||
|
@ -69,8 +69,7 @@ func renderCustomHelp() {
|
|||
helpTmplVars := map[string]string{
|
||||
"Name": "doggo",
|
||||
"Description": "DNS Client for Humans",
|
||||
"Version": buildVersion,
|
||||
"Date": buildDate,
|
||||
"Version": buildString,
|
||||
}
|
||||
tmpl, err := template.New("test").Funcs(template.FuncMap{
|
||||
"color": func(clr string, format string, str string) string {
|
||||
|
|
Loading…
Reference in New Issue