From 1e16650369913e432bdc215f96105338bbf478a5 Mon Sep 17 00:00:00 2001 From: Max Schmitt <max@schmitt.mx> Date: Thu, 25 Oct 2018 21:42:38 +0200 Subject: [PATCH] added version flag (fix: #25) (#26) --- .travis.yml | 2 +- main.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7aca9fa..a52d863 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,7 @@ before_deploy: # they failed to build. - go get github.com/mitchellh/gox - mkdir releases - - gox -osarch='!netbsd/arm !openbsd/386 !openbsd/amd64 !netbsd/386 !netbsd/amd64' -output="releases/{{.Dir}}_`git describe --tags --abbrev=0`_{{.OS}}_{{.Arch}}/{{.Dir}}" + - gox -osarch='!netbsd/arm !openbsd/386 !openbsd/amd64 !netbsd/386 !netbsd/amd64' -output="releases/{{.Dir}}_`git describe --tags --abbrev=0`_{{.OS}}_{{.Arch}}/{{.Dir}}" -ldflags "-X main.Version=`git describe --tags --abbrev=0`" # Loop through the built architecture directories and create their corresponding tar.gz archives with the binary in it. - find releases -maxdepth 2 -mindepth 2 -type f -exec bash -c 'tar -cvzf "$(dirname {}).tar.gz" -C "$(dirname {})" $(basename {})' \; diff --git a/main.go b/main.go index 521ee7b..13a7da1 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,22 @@ package main import ( + "flag" + "fmt" + "os" + "github.com/docker/machine/libmachine/drivers/plugin" ) +// Version will be added once we start the build process via travis-ci +var Version string + func main() { + version := flag.Bool("v", false, "prints current docker-machine-driver-hetzner version") + flag.Parse() + if *version { + fmt.Printf("Version: %s\n", Version) + os.Exit(0) + } plugin.RegisterDriver(NewDriver()) } -- GitLab