From 8df21e59b0aab904411ae97c42e2a747cd9ca0ee Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Thu, 18 Mar 2021 20:50:54 +0000 Subject: [PATCH 1/3] updated sum --- go.sum | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go.sum b/go.sum index 9ed17ba..bc154d1 100644 --- a/go.sum +++ b/go.sum @@ -8,7 +8,9 @@ github.com/dixonwille/wlog/v3 v3.0.1 h1:ViTSsNNndHlKW5S89x5O0KSTpTT9zdPqrkA/TZYY github.com/dixonwille/wlog/v3 v3.0.1/go.mod h1:fPYZR9Ne5gFh3N8b3CuXVWHWxkY6Yg1wCeS3Km6Nc0I= github.com/dixonwille/wmenu/v5 v5.1.0 h1:sKBHDoQ945NRvK0Eitd0kHDYHl1IYOSr1sdCK9c+Qr0= github.com/dixonwille/wmenu/v5 v5.1.0/go.mod h1:l6EGfXHaN6DPgv5+V5RY+cydAXJsj/oDZVczcdukPzc= +github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 h1:7xqw01UYS+KCI25bMrPxwNYkSns2Db1ziQPpVq99FpE= github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho= +github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 h1:f5gsjBiF9tRRVomCvrkGMMWI8W1f2OBFar2c5oakAP0= github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995/go.mod h1:lJgMEyOkYFkPcDKwRXegd+iM6E7matEszMG5HhwytU8= github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e h1:KhcknUwkWHKZPbFy2P7jH5LKJ3La+0ZeknkkmrSgqb0= github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk= @@ -21,6 +23,7 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 702edbc7a4e57b2f483ecb81e3dafd07f258f4ed Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Thu, 18 Mar 2021 21:14:53 +0000 Subject: [PATCH 2/3] add a makeshift versioning for the executable to distinguish each build --- VERSION | 1 + build.sh | 10 ++++++++++ stations.go | 16 +++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 VERSION create mode 100644 build.sh diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..2f45361 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.2 \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..0b7d4ea --- /dev/null +++ b/build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# shellcheck disable=SC2155 +export GIT_COMMIT=$(git rev-list -1 HEAD) +CANONICAL_VERSION=$(cat ./VERSION) +VERSION_STRING="$CANONICAL_VERSION ($GIT_COMMIT)" + +go mod vendor +go mod tidy +go build -o build/gostations -ldflags "-X main.version=$VERSION_STRING" diff --git a/stations.go b/stations.go index 5955789..f4d8877 100644 --- a/stations.go +++ b/stations.go @@ -6,6 +6,12 @@ import ( "os" ) +var version float32 + +func showVersion(){ + fmt.Println(version) +} + func precheck(){ if !isInstalled(player()){ fmt.Printf("%s is either not installed, or not on your $PATH. Cannot continue.\n", player()) @@ -22,11 +28,12 @@ func main(){ state string tags string notok bool + version bool ) flag.Usage = func() { fmt.Printf("Usage: \n") fmt.Printf(" gostations ") - fmt.Printf(" [-n \"name\"] [-c \"home country\"] [-s \"home state\"] [-t \"ordered,tag,list\"] [-x]\n") + fmt.Printf(" [-n \"name\"] [-c \"home country\"] [-s \"home state\"] [-t \"ordered,tag,list\"] [-x] [-v]\n") flag.PrintDefaults() fmt.Printf(" -h (or none)\n") fmt.Printf("\tThis help message\n") @@ -36,12 +43,19 @@ func main(){ flag.StringVar(&state, "s", "", "Home state (if in the United States).") flag.StringVar(&tags, "t", "", "Tag (or comma-separated tag list)") flag.BoolVar(¬ok, "x", false,"If toggled, will show stations that are down") + flag.BoolVar(&version, "v", false, "Show version.") flag.Parse() if argCount == 0 { flag.Usage() os.Exit(0) } + + if version { + showVersion() + os.Exit(0) + } + precheck() stations, _ := StationSearch(name, country, state, tags, notok) From 1cbf1c542e0c0c8fe74a52053a57b048eeda538d Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Thu, 18 Mar 2021 22:24:46 +0000 Subject: [PATCH 3/3] add build script with versioning --- build.sh | 12 +++++++++--- stations.go | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) mode change 100644 => 100755 build.sh diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 index 0b7d4ea..739b524 --- a/build.sh +++ b/build.sh @@ -1,10 +1,16 @@ #!/usr/bin/env sh -# shellcheck disable=SC2155 -export GIT_COMMIT=$(git rev-list -1 HEAD) +GOPATH=$GOPATH:$(pwd) +export GOPATH + +GIT_COMMIT=$(git rev-list -1 HEAD) +export GIT_COMMIT CANONICAL_VERSION=$(cat ./VERSION) -VERSION_STRING="$CANONICAL_VERSION ($GIT_COMMIT)" +export CANONICAL_VERSION +VERSION_STRING="$CANONICAL_VERSION-$GIT_COMMIT" +export VERSION_STRING go mod vendor go mod tidy + go build -o build/gostations -ldflags "-X main.version=$VERSION_STRING" diff --git a/stations.go b/stations.go index f4d8877..4accb94 100644 --- a/stations.go +++ b/stations.go @@ -6,7 +6,7 @@ import ( "os" ) -var version float32 +var version string func showVersion(){ fmt.Println(version)