From a806937941f8b2b45b587cf3be7ead980b543e44 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sun, 17 Nov 2019 16:12:12 +0100 Subject: [PATCH] Add version to CLI and write commit sha to release build --- Makefile | 4 ++-- cmd/root.go | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 4a1ca772..6b37b668 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ NAME ?= luet PACKAGE_NAME ?= $(NAME) PACKAGE_CONFLICT ?= $(PACKAGE_NAME)-beta -REVISION := $(shell git rev-parse --short HEAD || echo unknown) -VERSION := $(shell git describe --tags || echo dev) +REVISION := $(shell git rev-parse --short HEAD || echo dev) +VERSION := $(shell git describe --tags || echo $(REVISION)) VERSION := $(shell echo $(VERSION) | sed -e 's/^v//g') ITTERATION := $(shell date +%s) BUILD_PLATFORMS ?= -osarch="linux/amd64" -osarch="linux/386" -osarch="linux/arm" diff --git a/cmd/root.go b/cmd/root.go index 0ae9ee2d..ae577525 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -29,11 +29,14 @@ import ( var cfgFile string var Verbose bool +const LuetCLIVersion = "0.1-dev" + // RootCmd represents the base command when called without any subcommands var RootCmd = &cobra.Command{ - Use: "luet", - Short: "Package manager for the XXth century!", - Long: `Package manager which supports Gentoo and Entropy packages`, + Use: "luet", + Short: "Package manager for the XXth century!", + Long: `Package manager which supports Gentoo and Entropy packages`, + Version: LuetCLIVersion, } // Execute adds all child commands to the root command sets flags appropriately.