Skip to content

Commit

Permalink
Set version dynamically
Browse files Browse the repository at this point in the history
Also, add -version command
  • Loading branch information
mpchadwick committed Nov 2, 2020
1 parent 8fdbf0d commit 885f50d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
LDFLAGS = -X main.version=$(VERSION)

build:
go get -u github.com/shuLhan/go-bindata/...
$$GOPATH/bin/go-bindata -pkg dbanon -o src/bindata.go etc/*
GO111MODULE=on go get ./...
GO111MODULE=on go test $$GOPATH/src/github.com/mpchadwick/dbanon/src
GO111MODULE=on go build -o dbanon main.go
GO111MODULE=on go build -ldflags "$(LDFLAGS)" -o dbanon main.go
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"os"
)

const version = "0.2.2"
var version string

const slug = "mpchadwick/dbanon"

Expand All @@ -35,9 +35,15 @@ func selfUpdate() error {
func main() {
requested := flag.String("config", "", "Configuration to use. magento2 is included out-of-box. Alternately, supply path to file")
update := flag.Bool("update", false, "Auto update dbanon to the newest version")
ver := flag.Bool("version", false, "Get current version")

flag.Parse()

if *ver {
fmt.Println(version)
os.Exit(0)
}

if *update {
if err := selfUpdate(); err != nil {
fmt.Fprintln(os.Stderr, err)
Expand Down

0 comments on commit 885f50d

Please sign in to comment.