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