diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index 3d50cbc09..5f43e86ff 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -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 { diff --git a/pipeline/brew/brew_test.go b/pipeline/brew/brew_test.go index 74ea870fa..fe0b10daf 100644 --- a/pipeline/brew/brew_test.go +++ b/pipeline/brew/brew_test.go @@ -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) diff --git a/pipeline/brew/testdata/binary_overriden.rb.golden b/pipeline/brew/testdata/binary_overriden.rb.golden index 9697088b9..0a8b478af 100644 --- a/pipeline/brew/testdata/binary_overriden.rb.golden +++ b/pipeline/brew/testdata/binary_overriden.rb.golden @@ -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"