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

Merge pull request #115 from goreleaser/conflicts-with

adds conflicts_with for fpm and brew
This commit is contained in:
Carlos Alexandro Becker 2017-02-02 08:44:10 -02:00 committed by GitHub
commit c46b0c712c
6 changed files with 41 additions and 12 deletions

View File

@ -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.

View File

@ -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

View File

@ -3,6 +3,9 @@ brew:
folder: Formula
dependencies:
- git
conflicts:
# previous name of goreleaser...
- releaser
fpm:
formats:
- deb

View File

@ -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
}

View File

@ -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)

View File

@ -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