diff --git a/Makefile b/Makefile index f71fed7..e0986ad 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ TEST?=$(shell GO15VENDOREXPERIMENT=1 go list -f '{{.ImportPath}}/...' ./... | grep -v /vendor/ | sed "s|$(shell go list -f '{{.ImportPath}}' .)|.|g" | sed "s/\.\/\.\.\./\.\//g") VET?=$(shell echo ${TEST} | sed "s/\.\.\.//g" | sed "s/\.\/ //g") VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr +NAME=$(shell awk -F\" '/^const Name/ { print $$2 }' cmd/version.go) +VERSION=$(shell awk -F\" '/^const Version/ { print $$2 }' cmd/version.go) all: test vaultfs @@ -58,4 +60,25 @@ fmt: fmtcheck: @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" +xcompile: test + @rm -rf build/ + @mkdir -p build + gox \ + -os="darwin" \ + -os="dragonfly" \ + -os="freebsd" \ + -os="linux" \ + -os="openbsd" \ + -os="solaris" \ + -os="windows" \ + -output="build/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)" + +package: xcompile + $(eval FILES := $(shell ls build)) + @mkdir -p build/tgz + for f in $(FILES); do \ + (cd $(shell pwd)/build && tar -zcvf tgz/$$f.tar.gz $$f); \ + echo $$f; \ + done + .PHONY: all test vet fmt fmtcheck lint diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..1c10fc4 --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,40 @@ +// Copyright © 2016 Asteris +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// Name describes the name of this tool +const Name = "vaultfs" + +// Version describes the version of this tool +const Version = "1.0.0" + +// versionCmd represents the version command +var versionCmd = &cobra.Command{ + Use: "version", + Short: "A brief description of your command", + Run: func(cmd *cobra.Command, args []string) { + fmt.Printf("%s %s", Name, Version) + }, +} + +func init() { + RootCmd.AddCommand(versionCmd) +}