From 04919ea2083e6b15e4ac5a0bf47324865769295a Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Mon, 12 Jun 2023 20:38:42 -0400 Subject: [PATCH] Finally got versions baked into the builds --- Makefile | 3 ++- cmd/obp/cmd/version.go | 6 ++---- cmd/obp/main.go | 8 ++------ version.go | 5 +++++ 4 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 version.go diff --git a/Makefile b/Makefile index 41ed317..75522ce 100644 --- a/Makefile +++ b/Makefile @@ -82,11 +82,12 @@ BENCHCPUS ?= 1,2,4 # Commands GOCMD = go -ARCHES ?= 386 amd64 +ARCHES ?= amd64 386 OSES ?= windows linux darwin OUTTPL = $(DISTDIR)/$(NAME)-$(VERSION)-{{.OS}}_{{.Arch}}/{{.Dir}} LDFLAGS = -X $(PKG).Version=$(VERSION) -X $(PKG).Build=$(COMMIT_ID) GOBUILD = gox -rebuild -gocmd="$(GOCMD)" -arch="$(ARCHES)" -os="$(OSES)" -output="$(OUTTPL)" -tags "$(BUILD_TAGS)" -ldflags "$(LDFLAGS)" +GOBUILD_SIMPLE = go build -tags "$(BUILD_TAGS)" -ldflags "$(LDFLAGS)" GOCLEAN = $(GOCMD) clean GOINSTALL = $(GOCMD) install -a -tags "$(BUILD_TAGS)" -ldflags "$(LDFLAGS)" GOTEST = $(GOCMD) test -v -tags "$(BUILD_TAGS)" diff --git a/cmd/obp/cmd/version.go b/cmd/obp/cmd/version.go index 8bc1f21..689bca9 100644 --- a/cmd/obp/cmd/version.go +++ b/cmd/obp/cmd/version.go @@ -7,10 +7,8 @@ import ( "fmt" "github.com/spf13/cobra" -) -var ( - Version, Tag string + "code.ndumas.com/ndumas/obsidian-pipeline" ) // rootCmd represents the base command when called without any subcommands @@ -20,7 +18,7 @@ var versionCmd = &cobra.Command{ Long: `displays git tag and sha `, Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("%s %s\n", Version, Tag) + fmt.Printf("Version: %s Build: %s\n", obp.Version, obp.Build) }, } diff --git a/cmd/obp/main.go b/cmd/obp/main.go index cf7dddf..5e29125 100644 --- a/cmd/obp/main.go +++ b/cmd/obp/main.go @@ -3,14 +3,10 @@ Copyright © 2023 NAME HERE */ package main -import "code.ndumas.com/ndumas/obsidian-pipeline/cmd/obp/cmd" - -var ( - Version, Tag string +import ( + "code.ndumas.com/ndumas/obsidian-pipeline/cmd/obp/cmd" ) func main() { - cmd.Version = Version - cmd.Tag = Tag cmd.Execute() } diff --git a/version.go b/version.go new file mode 100644 index 0000000..aeb61f0 --- /dev/null +++ b/version.go @@ -0,0 +1,5 @@ +package obp + +var ( + Version, Build string +)