1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

fixed releasing

This commit is contained in:
Carlos Alexandro Becker 2016-12-29 10:15:08 -02:00
parent dab3f399f2
commit 8cf148f989
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 14 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import (
"context"
"crypto/sha256"
"fmt"
"html/template"
"text/template"
"strings"
"github.com/google/go-github/github"
@ -51,6 +51,16 @@ func Brew(version string, config config.ProjectConfig) error {
var out bytes.Buffer
tmpl.Execute(&out, data)
var sha *string
file, _, _, err := client.Repositories.GetContents(
parts[0], parts[1], config.BinaryName+".rb", &github.RepositoryContentGetOptions{},
)
if err == nil {
sha = file.SHA
} else {
sha = github.String(fmt.Sprintf("%s", sha256.Sum256(out.Bytes())))
}
_, _, err = client.Repositories.UpdateFile(
parts[0],
parts[1],
@ -62,7 +72,7 @@ func Brew(version string, config config.ProjectConfig) error {
},
Content: out.Bytes(),
Message: github.String(config.BinaryName + " version " + version),
SHA: github.String(fmt.Sprintf("%s", sha256.Sum256(out.Bytes()))),
SHA: sha,
},
)
return err

View File

@ -1,7 +1,7 @@
repo: goreleaser/releaser
binary_name: release
brew:
repo: goreleaser/brew
repo: goreleaser/homebrew-formulae
build:
arches:
- amd64

View File

@ -23,6 +23,7 @@ func Release(version, diff string, config config.ProjectConfig) error {
owner := strings.Split(config.Repo, "/")[0]
repo := strings.Split(config.Repo, "/")[1]
// TODO update release if it already exists
r, _, err := client.Repositories.CreateRelease(owner, repo, &github.RepositoryRelease{
Name: github.String(version),
TagName: github.String(version),