diff --git a/Makefile b/Makefile index 96366f7..d8fabf9 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,9 @@ GO_BUILD_OUT_FILE ?= build/backpack .DEFAULT_GOAL := build ifneq (${VERSION},) -BUILD_LDFLAGS := -X ${_GO_PACKAGE}/cmd.version=${VERSION} -X ${_GO_PACKAGE}/cmd.versionTag=${GIT_COMMIT_SHORT} +BUILD_LDFLAGS := -X ${_GO_PACKAGE}/cmd.version=${VERSION} -X ${_GO_PACKAGE}/cmd.versionGitHash=${GIT_COMMIT_SHORT} endif -BUILD_LDFLAGS ?= -X ${_GO_PACKAGE}/cmd.versionTag=${GIT_COMMIT_SHORT} +BUILD_LDFLAGS ?= -X ${_GO_PACKAGE}/cmd.versionGitHash=${GIT_COMMIT_SHORT} clean: rm -rf vendor diff --git a/cmd/root.go b/cmd/root.go index 858ada5..cdfd2aa 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -8,9 +8,6 @@ import ( ) var ( - // Specify a version and versionTag - version = "unstable" - versionTag = "HEAD" // rootCmd represents the base command when called without any subcommands rootCmd = &cobra.Command{ Use: "backpack", diff --git a/cmd/version.go b/cmd/version.go index f23ffc5..4d59f5f 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -6,6 +6,12 @@ import ( "github.com/spf13/cobra" ) +var ( + // Specify a version and versionTag + version = "unstable" + versionGitHash = "HEAD" +) + // versionCmd represents the version command var versionCmd = &cobra.Command{ Use: "version", @@ -18,6 +24,6 @@ func init() { } func versionRun(cmd *cobra.Command, args []string) { - fmt.Printf("Backpack version: %s (%s)\n", version, versionTag) + fmt.Printf("Backpack version: %s (%s)\n", version, versionGitHash) fmt.Println("More info: https://backpack.qm64.tech") }