Skip to content

Commit

Permalink
added version information to the binary
Browse files Browse the repository at this point in the history
  • Loading branch information
spy16 committed Sep 23, 2018
1 parent 5c06ab5 commit ef93dd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
VERSION:=$(shell git describe --abbrev=0 --tags)
COMMIT:=$(shell git rev-parse HEAD)

all: clean setup install

setup-deps:
go get -u github.com/golang/dep/cmd/dep
dep ensure -v

build:
go build -o ./bin/radium ./cmd/radium/*.go
go build -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT)" -o ./bin/radium ./cmd/radium/*.go

install:
go install ./cmd/radium/
go install -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT)" ./cmd/radium/

setup:
mkdir -p ./bin
Expand Down
8 changes: 8 additions & 0 deletions cmd/radium/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package main

import "fmt"

var (
version = "n/a"
commit = "n/a"
)

func main() {
cli := newCLI()
cli.Version = fmt.Sprintf("%s (commit: %s)", version, commit)
cli.Execute()
}

0 comments on commit ef93dd8

Please sign in to comment.