diff --git a/README.md b/README.md index 02431c9cf..c592e5e7a 100644 --- a/README.md +++ b/README.md @@ -264,10 +264,15 @@ brew: # Default is empty. caveats: "How to use this binary" - # Dependencies of your formula + # Dependencies of your package dependencies: - git - zsh + + # Packages that conflict with your package + conflicts: + - svn + - bash ``` By defining the `brew` section, GoReleaser will take care of publishing the Homebrew tap. @@ -308,6 +313,12 @@ fpm: # Dependencies of your package dependencies: - git + - zsh + + # Packages that conflict with your package + conflicts: + - svn + - bash ``` Note that GoReleaser will not install `fpm` nor any of it's dependencies for you. diff --git a/config/config.go b/config/config.go index 43563482a..2ecfbad75 100644 --- a/config/config.go +++ b/config/config.go @@ -12,6 +12,7 @@ type Homebrew struct { Folder string Caveats string Dependencies []string + Conflicts []string } // Hooks define actions to run before and/or after something @@ -47,6 +48,7 @@ type Release struct { type FPM struct { Formats []string Dependencies []string + Conflicts []string } // Project includes all project configuration diff --git a/goreleaser.yml b/goreleaser.yml index 1f7d62dae..ba843d1a6 100644 --- a/goreleaser.yml +++ b/goreleaser.yml @@ -3,6 +3,9 @@ brew: folder: Formula dependencies: - git + conflicts: + # previous name of goreleaser... + - releaser fpm: formats: - deb diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index 2236fe256..069d84fd2 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -31,6 +31,12 @@ const formula = `class {{ .Name }} < Formula {{- end }} {{- end }} + {{- if .Conflicts }} + {{ range $index, $element := .Conflicts }} + conflicts_with "{{ . }}" + {{- end }} + {{- end }} + def install bin.install "{{ .BinaryName }}" end @@ -57,6 +63,7 @@ type templateData struct { Format string SHA256 string Dependencies []string + Conflicts []string } // Pipe for brew deployment @@ -164,6 +171,7 @@ func dataFor(ctx *context.Context, client *github.Client) (result templateData, Format: ctx.Config.Archive.Format, SHA256: sum, Dependencies: ctx.Config.Brew.Dependencies, + Conflicts: ctx.Config.Brew.Conflicts, }, err } diff --git a/pipeline/brew/brew_test.go b/pipeline/brew/brew_test.go index e9ada50af..628b760ca 100644 --- a/pipeline/brew/brew_test.go +++ b/pipeline/brew/brew_test.go @@ -46,6 +46,7 @@ func TestFullFormulae(t *testing.T) { data := defaultTemplateData data.Caveats = "Here are some caveats" data.Dependencies = []string{"gtk", "git"} + data.Conflicts = []string{"conflicting_dep"} out, err := doBuildFormula(data) assert.NoError(err) formulae := out.String() @@ -54,9 +55,10 @@ func TestFullFormulae(t *testing.T) { assert.Contains(formulae, "Here are some caveats") assert.Contains(formulae, "depends_on \"gtk\"") assert.Contains(formulae, "depends_on \"git\"") + assert.Contains(formulae, "conflicts_with \"conflicting_dep\"") } -func TestFormulaeNoCaveats(t *testing.T) { +func TestFormulaeSimple(t *testing.T) { assert := assert.New(t) out, err := doBuildFormula(defaultTemplateData) assert.NoError(err) diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 7e2681a65..3ea768c50 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -60,24 +60,27 @@ func create(ctx *context.Context, format, archive, arch string) error { log.Println("Creating", file) var options = []string{ - "-s", "dir", - "-t", format, - "-n", name, - "-v", ctx.Version, - "-a", arch, - "-C", path, - "-p", file, + "--input-type", "dir", + "--output-type", format, + "--name", name, + "--version", ctx.Version, + "--architecture", arch, + "--chdir", path, + "--package", file, "--force", } for _, dep := range ctx.Config.FPM.Dependencies { - options = append(options, "-d", dep) + options = append(options, "--depends", dep) } + for _, conflict := range ctx.Config.FPM.Conflicts { + options = append(options, "--conflicts", conflict) + } + // This basically tells fpm to put the binary in the /usr/local/bin // binary=/usr/local/bin/binary options = append(options, name+"="+filepath.Join("/usr/local/bin", name)) - cmd := exec.Command("fpm", options...) - if out, err := cmd.CombinedOutput(); err != nil { + if out, err := exec.Command("fpm", options...).CombinedOutput(); err != nil { return errors.New(string(out)) } return nil