diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..849ddff --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..e7bfd3e --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,24 @@ +builds: + - binary: grpcurl + main: ./cmd/grpcurl + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - 386 + ldflags: + - -s -w -X main.version=v{{.Version}} + +archive: + format: tar.gz + format_overrides: + - goos: windows + format: zip + replacements: + amd64: x86_64 + 386: x86_32 + darwin: osx + files: + - LICENSE diff --git a/Makefile b/Makefile index 42a9a30..0c0b179 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +dev_build_version=$(shell git describe --tags --always --dirty) + # TODO: run golint and errcheck, but only to catch *new* violations and # decide whether to change code or not (e.g. we need to be able to whitelist # violations already in the code). They can be useful to catch errors, but @@ -16,7 +18,12 @@ updatedeps: .PHONY: install install: - go install ./... + go install -ldflags '-X "main.version=dev build $(dev_build_version)"' ./... + +.PHONY: release +release: + @GO111MODULE=off go get github.com/goreleaser/goreleaser + goreleaser --rm-dist .PHONY: checkgofmt checkgofmt: diff --git a/README.md b/README.md index 52eded1..4314715 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,11 @@ As mentioned above, `grpcurl` works seamlessly if the server supports the reflec service. If not, you can supply the `.proto` source files or you can supply protoset files (containing compiled descriptors, produced by `protoc`) to `grpcurl`. -## Installation +## Installation (binaries) + +Download the binary from the [releases](https://github.com/fullstorydev/grpcurl/releases) page. + +## Installation (source) You can use the `go` tool to install `grpcurl`: ```shell go get github.com/fullstorydev/grpcurl diff --git a/cmd/grpcurl/grpcurl.go b/cmd/grpcurl/grpcurl.go index c17eee6..6d4d053 100644 --- a/cmd/grpcurl/grpcurl.go +++ b/cmd/grpcurl/grpcurl.go @@ -30,6 +30,8 @@ import ( "github.com/fullstorydev/grpcurl" ) +var version = "dev build " + var ( exit = os.Exit @@ -37,6 +39,8 @@ var ( help = flag.Bool("help", false, `Print usage instructions and exit.`) + printVersion = flag.Bool("version", false, + `Print version.`) plaintext = flag.Bool("plaintext", false, `Use plain-text HTTP/2 when connecting to server (no TLS).`) insecure = flag.Bool("insecure", false, @@ -146,6 +150,10 @@ func main() { usage() os.Exit(0) } + if *printVersion { + fmt.Fprintf(os.Stderr, "%s %s\n", os.Args[0], version) + os.Exit(0) + } // Do extra validation on arguments and figure out what user asked us to do. if *plaintext && *insecure {