From 1ae2fbe5236314cc8135317018091f5435f65aa6 Mon Sep 17 00:00:00 2001 From: Songmu Date: Tue, 30 Apr 2019 01:38:17 +0900 Subject: [PATCH] ghr can be installed from official homebrew --- .travis.yml | 2 -- Makefile | 4 --- README.md | 8 ++++- release/main.go | 96 ------------------------------------------------- 4 files changed, 7 insertions(+), 103 deletions(-) delete mode 100644 release/main.go diff --git a/.travis.yml b/.travis.yml index 018e244..771d0e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,6 @@ env: - secure: "c7Owhq9NWblgnQLvmkssks3j4zNPCvgkkagVcuz3GmhcklVrZqY3H57FNepT3pkTYt+EJgqocBoohZodVFXsn917DcrMHETO6enDLUvmsJTTdxVFIU6ylr79NLTfNSJFY//gCe3WiMPw7bEePrAP1o2zMCvK21bZoHN6r48VHgY=" os: - osx -install: - - echo "skipping travis default" script: - make test-all after_script: diff --git a/Makefile b/Makefile index 93485b3..5779752 100644 --- a/Makefile +++ b/Makefile @@ -51,10 +51,6 @@ crossbuild: CREDITS install: go install -ldflags "-X main.GitCommit=$(COMMIT)" -.PHONY: brew -brew: crossbuild - go run release/main.go v$(VERSION) pkg/dist/v$(VERSION)/ghr_v$(VERSION)_darwin_amd64.zip > ../homebrew-ghr/ghr.rb - .PHONY: upload upload: build devel-deps bin/ghr -v diff --git a/README.md b/README.md index 881445c..daf8e6d 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,13 @@ $ ghr \ ## Install -You can download binary from [release page](https://github.com/tcnksm/ghr/releases) and place it in `$PATH` directory. +If you are OSX user, you can use [Homebrew](http://brew.sh/): + +```bash +$ brew install ghr +``` + +If you are in another platform, you can download binary from [release page](https://github.com/tcnksm/ghr/releases) and place it in `$PATH` directory. Or you can use `go get` (you need to use go1.7 or later), diff --git a/release/main.go b/release/main.go deleted file mode 100644 index 5e46add..0000000 --- a/release/main.go +++ /dev/null @@ -1,96 +0,0 @@ -package main - -import ( - "crypto/sha256" - "fmt" - "io/ioutil" - "log" - "os" - "path/filepath" - "strings" - "text/template" -) - -// formulaTmpl holds a go template for the homebrew formula -var formulaTmpl = `require "formula" - -class {{ .Name | Title }} < Formula - homepage "https://github.com/tcnksm/{{ .Name }}" - version '{{ .Version }}' - - url "https://github.com/tcnksm/{{ .Name }}/releases/download/{{ .Version }}/ghr_{{ .Version }}_darwin_amd64.zip" - sha256 "{{ .Sha256 }}" - - def install - bin.install '{{ .Name }}' - end - - def caveats - msg = <<-'EOF' - ________ ___ ___ ________ -|\ ____\|\ \|\ \|\ __ \ -\ \ \___|\ \ \\\ \ \ \|\ \ - \ \ \ __\ \ __ \ \ _ _\ - \ \ \|\ \ \ \ \ \ \ \\ \| - \ \_______\ \__\ \__\ \__\\ _\ - \|_______|\|__|\|__|\|__|\|__| - -EOF - end -end -` - -func main() { - os.Exit(_main()) -} - -func _main() int { - if len(os.Args) != 3 { - log.Println("Usage: go run main.go VERSION FILE") - return 0 - } - - name := "ghr" - version := os.Args[1] - file := os.Args[2] - - file, err := filepath.Abs(file) - if err != nil { - log.Println(err) - return 1 - } - - f, err := os.Open(file) - if err != nil { - log.Println(err) - return 1 - } - defer f.Close() - - buf, err := ioutil.ReadAll(f) - if err != nil { - log.Println(err) - return 1 - } - checkSum := sha256.Sum256(buf) - - tmpl, err := template.New("formula").Funcs(template.FuncMap{ - "Title": strings.Title, - }).Parse(formulaTmpl) - if err != nil { - log.Fatal(err) - } - - if err := tmpl.Execute(os.Stdout, struct { - Name, Version, Sha256 string - }{ - Name: name, - Version: version, - Sha256: fmt.Sprintf("%x", checkSum), - }); err != nil { - log.Println(err) - return 1 - } - - return 0 -}