Skip to content

Commit

Permalink
Merge pull request #4 from pbs/feature/version
Browse files Browse the repository at this point in the history
implement version command
  • Loading branch information
cmac1000 authored Nov 28, 2018
2 parents eccba39 + 31a769b commit 7c906c6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
19 changes: 19 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"fmt"

"github.com/pbs/gorson/internal/gorson/version"
"github.com/spf13/cobra"
)

func init() {
cmd := &cobra.Command{
Use: "version",
Short: "Get gorson version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.Version)
},
}
rootCmd.AddCommand(cmd)
}
4 changes: 4 additions & 0 deletions internal/gorson/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package version

// Version is current gorson version
const Version = "0.1.0"
3 changes: 1 addition & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ IFS=$'\n\t'
cd "$( dirname "${BASH_SOURCE[0]}" )/.."

>&2 echo "building gorson"
GIT_SHA=$(git rev-parse --short HEAD)
mkdir -p bin
go build -ldflags "-X main.GitSHA=${GIT_SHA}" -o bin/gorson .
go build -o bin/gorson .
13 changes: 6 additions & 7 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ IFS=$'\n\t'

cd "$( dirname "${BASH_SOURCE[0]}" )/.."

GIT_SHA=$(git rev-parse --short HEAD)
# TODO we probably want this in a go file, to support `gorson version`, etc
VERSION="0.0.1"
./scripts/clean.sh
mkdir -p bin

VERSION=`egrep -o '[0-9]+\.[0-9a-z.\-]+' ./internal/gorson/version/version.go`

>&2 echo "building gorson_builder docker image"
# build a local docker image called gorson_builder: we'll use this to
Expand All @@ -36,7 +37,5 @@ for platform in darwin linux; do \
-e "GOARCH=amd64" \
-e "CGO_ENABLED=0" \
gorson_builder \
go build \
-ldflags="-s -w -X main.GitSHA=${GIT_SHA}" \
-o bin/$binary_name
done
go build -o bin/$binary_name
done

0 comments on commit 7c906c6

Please sign in to comment.