Skip to content

Commit

Permalink
Improve versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
rjuer committed Sep 13, 2024
1 parent c545307 commit fc0a46e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DEFAULT_GOAL:=help
VERSION=$(shell git describe --tags --abbrev=0)

help:
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
Expand All @@ -12,7 +13,8 @@ vet: ## Vet to find also sublte issues in the code

##@ Build
build: ## Build application
go build -ldflags "-s -w" -o dist/
go build -ldflags="-s -w -X 'github.com/rjuer/cidr/cmd.version=$(VERSION)'" -o dist/
@# go build -ldflags "-s -w" -o dist/

##@ Test
test: ## Run tests in all packages and generate coverage report
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (
"github.com/spf13/cobra"
)

var version string

var rootCmd = &cobra.Command{
Use: "cidr",
Short: "Application to operate with CIDR blocks",
Long: `Handles basic operations related to CIDR blocks.`,
Version: "v0.1.0",
Version: version,
}

func Execute() {
Expand Down

0 comments on commit fc0a46e

Please sign in to comment.