Skip to content

Commit

Permalink
add -v and Makefile to build releases
Browse files Browse the repository at this point in the history
  • Loading branch information
mgumz committed Jul 9, 2017
1 parent 7fea689 commit b372c74
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
VERSION=0.5.0
BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
GIT_HASH=$(shell git rev-parse HEAD)

RELEASES=bin/vopher-$(VERSION).linux.amd64 \
bin/vopher-$(VERSION).linux.arm64 \
bin/vopher-$(VERSION).linux.mips64 \
bin/vopher-$(VERSION).windows.amd64.exe \
bin/vopher-$(VERSION).freebsd.amd64 \
bin/vopher-$(VERSION).darwin.amd64


LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildDate=$(BUILD_DATE) -X main.GitHash=$(GIT_HASH)"


releases: $(RELEASES)

bin/vopher-$(VERSION).linux.mips64: bin
env GOOS=linux GOARCH=mips64 CGO_ENABLED=0 go build $(LDFLAGS) -o $@

bin/vopher-$(VERSION).linux.amd64: bin
env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o $@

bin/vopher-$(VERSION).linux.arm64: bin
env GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(LDFLAGS) -o $@

bin/vopher-$(VERSION).windows.amd64.exe: bin
env GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o $@

bin/vopher-$(VERSION).darwin.amd64: bin
env GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o $@

bin/vopher-$(VERSION).freebsd.amd64: bin
env GOOS=freebsd GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o $@

bin:
mkdir $@
19 changes: 19 additions & 0 deletions vopher.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import (
"time"
)

var (
Version = "0.5"
GitHash = ""
BuildDate = ""
)

var allowed_actions = []string{
"u",
"up",
Expand Down Expand Up @@ -73,12 +79,14 @@ func main() {
ui string
filter stringList
supported bool
version bool
}{action: "update", dir: "."}

flag.BoolVar(&cli.force, "force", cli.force, "force certain actions [prune, clean]")
flag.BoolVar(&cli.dry, "dry", cli.dry, "dry-run, show what would happen [prune, clean]")
flag.BoolVar(&cli.all, "all", cli.force, "don't keep <plugin>.zip around [prune]")
flag.BoolVar(&cli.supported, "list-supported-archives", false, "list all supported archive types")
flag.BoolVar(&cli.version, "v", false, "show version")
flag.StringVar(&cli.file, "f", cli.file, "path to list of plugins")
flag.StringVar(&cli.dir, "dir", cli.dir, "directory to extract the plugins to")
flag.StringVar(&cli.ui, "ui", cli.ui, "ui mode ('simple' or 'oneline', works with `update` action)")
Expand All @@ -87,6 +95,17 @@ func main() {
flag.Usage = usage
flag.Parse()

if cli.version {
fmt.Println("vopher:\t" + Version)
if GitHash != "" {
fmt.Println("git:\t" + GitHash)
}
if BuildDate != "" {
fmt.Println("build-date:\t" + BuildDate)
}
return
}

if cli.supported {
for _, suf := range supported_archives {
fmt.Println(suf)
Expand Down

0 comments on commit b372c74

Please sign in to comment.