mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fixed releasing
This commit is contained in:
parent
dab3f399f2
commit
8cf148f989
14
brew/brew.go
14
brew/brew.go
@ -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
|
||||
|
@ -1,7 +1,7 @@
|
||||
repo: goreleaser/releaser
|
||||
binary_name: release
|
||||
brew:
|
||||
repo: goreleaser/brew
|
||||
repo: goreleaser/homebrew-formulae
|
||||
build:
|
||||
arches:
|
||||
- amd64
|
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user