1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00

fix: brew should aknowledge format overrides

This commit is contained in:
Carlos Alexandro Becker 2018-07-11 00:43:26 -07:00
parent d43c74f0bf
commit c34cc67260
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 15 additions and 5 deletions

View File

@ -91,7 +91,7 @@ func doRun(ctx *context.Context, client client.Client) error {
if ctx.Config.Brew.GitHub.Name == "" {
return pipeline.Skip("brew section is not configured")
}
if ctx.Config.Archive.Format == "binary" {
if getFormat(ctx) == "binary" {
return pipeline.Skip("archive format is binary")
}
@ -141,6 +141,15 @@ func doRun(ctx *context.Context, client client.Client) error {
return client.CreateFile(ctx, ctx.Config.Brew.CommitAuthor, ctx.Config.Brew.GitHub, content, path, msg)
}
func getFormat(ctx *context.Context) string {
for _, override := range ctx.Config.Archive.FormatOverrides {
if strings.HasPrefix("darwin", override.Goos) {
return override.Format
}
}
return ctx.Config.Archive.Format
}
func buildFormula(ctx *context.Context, artifact artifact.Artifact) (bytes.Buffer, error) {
data, err := dataFor(ctx, artifact)
if err != nil {

View File

@ -159,9 +159,10 @@ func TestRunPipe(t *testing.T) {
},
}
fn(ctx)
var path = filepath.Join(folder, "bin.tar.gz")
var format = getFormat(ctx)
var path = filepath.Join(folder, "bin."+format)
ctx.Artifacts.Add(artifact.Artifact{
Name: "bin.tar.gz",
Name: "bin." + format,
Path: path,
Goos: "darwin",
Goarch: "amd64",
@ -177,7 +178,7 @@ func TestRunPipe(t *testing.T) {
assert.True(t, client.CreatedFile)
var golden = fmt.Sprintf("testdata/%s.rb.golden", name)
if *update {
ioutil.WriteFile(golden, []byte(client.Content), 0655)
assert.NoError(t, ioutil.WriteFile(golden, []byte(client.Content), 0655))
}
bts, err := ioutil.ReadFile(golden)
assert.NoError(t, err)

View File

@ -1,7 +1,7 @@
class BinaryOverriden < Formula
desc "A run pipe test formula"
homepage "https://github.com/goreleaser"
url "https://github.com/test/test/releases/download/v1.0.1/bin.tar.gz"
url "https://github.com/test/test/releases/download/v1.0.1/bin.zip"
version "1.0.1"
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"