From c051f741b02eee9a9eac289a98da58f37bc49a55 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch Date: Sat, 15 Sep 2018 23:33:31 +0000 Subject: [PATCH] add goreleaser Add a goreleaser configuration file that builds binaries for Linux, MacOS and Windows, for 32bit (x86/386) and 64bit (x64/amd64). The binaries will be archived into a tar.gz/zip file along with the LICENSE file. The `dist/` directory will be written to by goreleaser with the binaries during the build process, so it's also been added to .gitignore. Goreleaser can be installed with: go get github.com/goreleaser/goreleaser Or other methods for install can be found at: https://goreleaser.com To build all the binaries and release them to GitHub: 1. Tag the release. e.g. `git tag -a v1.0.0 -m 'First release'` 2. Generate a GitHub Personal Access Token. See https://github.com/settings/tokens. 3. Push the release to GitHub. e.g. `git push origin v1.0.0` 4. Run goreleaser. e.g. `GITHUB_TOKEN=xxxxxxx... goreleaser` Go releaser will build the binaries, and upload the binaries to the GitHub project's release page for the release that was tagged. --- .gitignore | 1 + cmd/grpcurl/.goreleaser.yml | 22 ++++++++++++++++++++++ cmd/grpcurl/grpcurl.go | 8 ++++++++ 3 files changed, 31 insertions(+) create mode 100644 .gitignore create mode 100644 cmd/grpcurl/.goreleaser.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..849ddff --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist/ diff --git a/cmd/grpcurl/.goreleaser.yml b/cmd/grpcurl/.goreleaser.yml new file mode 100644 index 0000000..2c357c1 --- /dev/null +++ b/cmd/grpcurl/.goreleaser.yml @@ -0,0 +1,22 @@ +builds: + - binary: grpcurl + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - 386 + +archive: + wrap_in_directory: true + format: tar.gz + format_overrides: + - goos: windows + format: zip + replacements: + amd64: x64 + 386: x86 + darwin: macos + files: + - LICENSE diff --git a/cmd/grpcurl/grpcurl.go b/cmd/grpcurl/grpcurl.go index c17eee6..86ca563 100644 --- a/cmd/grpcurl/grpcurl.go +++ b/cmd/grpcurl/grpcurl.go @@ -30,6 +30,8 @@ import ( "github.com/fullstorydev/grpcurl" ) +var version = "" + 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 v%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 {