From 2a7a4838d32feeddfd0325d238ee7a8cfeab2ade Mon Sep 17 00:00:00 2001 From: Bradley Kemp Date: Mon, 17 Jun 2019 19:42:03 +0100 Subject: [PATCH] Add goreleaser --- .goreleaser.yml | 51 +++++++++++++++++++++++++++++++++ README.md | 10 +++++-- internal/versionflag/version.go | 10 +++---- 3 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..6bb4073 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,51 @@ +before: + hooks: + - go mod download + +env: + - GO111MODULE=on + +builds: +- &common + goos: + - darwin + - windows + - linux + goarch: + - amd64 + ldflags: + - -s -w -X github.com/bradleyjkemp/grpc-tools/internal/versionflag.version={{.Version}} + id: grpc-dump + binary: grpc-dump + main: ./grpc-dump +- <<: *common + id: grpc-fixture + binary: grpc-fixture + main: ./grpc-fixture +- <<: *common + id: grpc-replay + binary: grpc-replay + main: ./grpc-replay +- <<: *common + id: grpc-view + binary: grpc-view + main: ./grpc-view + +brews: +- + github: + owner: bradleyjkemp + name: homebrew-formulae + homepage: "https://github.com/bradleyjkemp/grpc-tools" + description: "A suite of gRPC debugging tools. Like Fiddler/Charles but for gRPC." + +archives: +- replacements: + darwin: macOS + linux: Linux + windows: Windows + format: zip +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" diff --git a/README.md b/README.md index 8f1077c..1493b00 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,17 @@ This repository currently includes: These tools are in alpha so expect breaking changes between releases. See the [changelog](CHANGELOG.md) for full details. ### Installation: -Fetch the tools using: +The recommended way to install these tools is via [Homebrew](https://brew.sh/) using: +```bash +brew install bradleyjkemp/formulae/grpc-tools +``` + +Alternatively, binaries can be downloaded from the GitHub [releases page](https://github.com/bradleyjkemp/grpc-tools/releases/latest). + +Or you can build the tools from source using: ```bash go install github.com/bradleyjkemp/grpc-tools/... ``` -All the tools in this repository will now be installed to your `$GOPATH/bin` or `$GOBIN` directory. ## grpc-dump diff --git a/internal/versionflag/version.go b/internal/versionflag/version.go index d8e1b13..bac78cd 100644 --- a/internal/versionflag/version.go +++ b/internal/versionflag/version.go @@ -4,15 +4,13 @@ import ( "flag" "fmt" "os" - "runtime/debug" ) -func init() { - version := "non-module" - if info, ok := debug.ReadBuildInfo(); ok { - version = info.Main.Version - } +var ( + version string +) +func init() { flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s (%s):\n", os.Args[0], version) flag.PrintDefaults()