You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-09-16 09:26:52 +02:00
adds conflicts_with for fpm and brew
This commit is contained in:
@@ -12,6 +12,7 @@ type Homebrew struct {
|
|||||||
Folder string
|
Folder string
|
||||||
Caveats string
|
Caveats string
|
||||||
Dependencies []string
|
Dependencies []string
|
||||||
|
Conflicts []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hooks define actions to run before and/or after something
|
// Hooks define actions to run before and/or after something
|
||||||
@@ -47,6 +48,7 @@ type Release struct {
|
|||||||
type FPM struct {
|
type FPM struct {
|
||||||
Formats []string
|
Formats []string
|
||||||
Dependencies []string
|
Dependencies []string
|
||||||
|
Conflicts []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Project includes all project configuration
|
// Project includes all project configuration
|
||||||
|
@@ -31,6 +31,12 @@ const formula = `class {{ .Name }} < Formula
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if .Conflicts }}
|
||||||
|
{{ range $index, $element := .Conflicts }}
|
||||||
|
conflicts_with "{{ . }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
def install
|
def install
|
||||||
bin.install "{{ .BinaryName }}"
|
bin.install "{{ .BinaryName }}"
|
||||||
end
|
end
|
||||||
@@ -57,6 +63,7 @@ type templateData struct {
|
|||||||
Format string
|
Format string
|
||||||
SHA256 string
|
SHA256 string
|
||||||
Dependencies []string
|
Dependencies []string
|
||||||
|
Conflicts []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pipe for brew deployment
|
// Pipe for brew deployment
|
||||||
@@ -164,6 +171,7 @@ func dataFor(ctx *context.Context, client *github.Client) (result templateData,
|
|||||||
Format: ctx.Config.Archive.Format,
|
Format: ctx.Config.Archive.Format,
|
||||||
SHA256: sum,
|
SHA256: sum,
|
||||||
Dependencies: ctx.Config.Brew.Dependencies,
|
Dependencies: ctx.Config.Brew.Dependencies,
|
||||||
|
Conflicts: ctx.Config.Brew.Conflicts,
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@ func TestFullFormulae(t *testing.T) {
|
|||||||
data := defaultTemplateData
|
data := defaultTemplateData
|
||||||
data.Caveats = "Here are some caveats"
|
data.Caveats = "Here are some caveats"
|
||||||
data.Dependencies = []string{"gtk", "git"}
|
data.Dependencies = []string{"gtk", "git"}
|
||||||
|
data.Conflicts = []string{"conflicting_dep"}
|
||||||
out, err := doBuildFormula(data)
|
out, err := doBuildFormula(data)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
formulae := out.String()
|
formulae := out.String()
|
||||||
@@ -54,9 +55,10 @@ func TestFullFormulae(t *testing.T) {
|
|||||||
assert.Contains(formulae, "Here are some caveats")
|
assert.Contains(formulae, "Here are some caveats")
|
||||||
assert.Contains(formulae, "depends_on \"gtk\"")
|
assert.Contains(formulae, "depends_on \"gtk\"")
|
||||||
assert.Contains(formulae, "depends_on \"git\"")
|
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)
|
assert := assert.New(t)
|
||||||
out, err := doBuildFormula(defaultTemplateData)
|
out, err := doBuildFormula(defaultTemplateData)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
@@ -60,24 +60,27 @@ func create(ctx *context.Context, format, archive, arch string) error {
|
|||||||
log.Println("Creating", file)
|
log.Println("Creating", file)
|
||||||
|
|
||||||
var options = []string{
|
var options = []string{
|
||||||
"-s", "dir",
|
"--input-type", "dir",
|
||||||
"-t", format,
|
"--output-type", format,
|
||||||
"-n", name,
|
"--name", name,
|
||||||
"-v", ctx.Version,
|
"--version", ctx.Version,
|
||||||
"-a", arch,
|
"--architecture", arch,
|
||||||
"-C", path,
|
"--chdir", path,
|
||||||
"-p", file,
|
"--package", file,
|
||||||
"--force",
|
"--force",
|
||||||
}
|
}
|
||||||
for _, dep := range ctx.Config.FPM.Dependencies {
|
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
|
// This basically tells fpm to put the binary in the /usr/local/bin
|
||||||
// binary=/usr/local/bin/binary
|
// binary=/usr/local/bin/binary
|
||||||
options = append(options, name+"="+filepath.Join("/usr/local/bin", name))
|
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 errors.New(string(out))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user