1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-09-16 09:26:52 +02:00

added brew dependencies support

This commit is contained in:
Carlos Alexandro Becker
2017-01-17 08:33:43 -02:00
parent 3540e35b19
commit b6d1b56a04
4 changed files with 47 additions and 15 deletions

View File

@@ -11,6 +11,7 @@ type Homebrew struct {
Repo string
Folder string
Caveats string
Dependencies []string
}
// Build contains the build configuration section

View File

@@ -81,3 +81,14 @@ brew:
# Caveats for the user of your binary.
# Default is empty.
caveats: "How to use this binary"
# Dependencies of your formula.
# For more info, check https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md
dependencies:
- pkg-config
- jpeg
- boost
- readline
- gtk+
- x11

View File

@@ -25,6 +25,12 @@ const formulae = `class {{ .Name }} < Formula
version "{{ .Tag }}"
sha256 "{{ .SHA256 }}"
{{- if .Dependencies }}
{{ range $index, $element := .Dependencies }}
depends_on: {{ . }}
{{- end }}
{{- end }}
def install
bin.install "{{ .BinaryName }}"
end
@@ -39,7 +45,17 @@ end
`
type templateData struct {
Name, Desc, Homepage, Repo, Tag, BinaryName, Caveats, File, Format, SHA256 string
Name string
Desc string
Homepage string
Repo string
Tag string
BinaryName string
Caveats string
File string
Format string
SHA256 string
Dependencies []string
}
// Pipe for brew deployment
@@ -145,6 +161,7 @@ func dataFor(ctx *context.Context, client *github.Client) (result templateData,
File: file,
Format: ctx.Config.Archive.Format,
SHA256: sum,
Dependencies: ctx.Config.Brew.Dependencies,
}, err
}

View File

@@ -38,19 +38,21 @@ func assertDefaultTemplateData(t *testing.T, formulae string) {
assert.Contains(formulae, "sha256 \"1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68\"")
assert.Contains(formulae, "version \"v0.1.3\"")
assert.Contains(formulae, "bin.install \"test\"")
}
func TestFullFormulae(t *testing.T) {
assert := assert.New(t)
data := defaultTemplateData
data.Caveats = "Here are some caveats"
data.Dependencies = []string{"gtk", "git"}
out, err := doBuildFormulae(data)
assert.NoError(err)
formulae := out.String()
assertDefaultTemplateData(t, formulae)
assert.Contains(formulae, "def caveats")
assert.Contains(formulae, "Here are some caveats")
assert.Contains(formulae, "depends_on: gtk")
assert.Contains(formulae, "depends_on: git")
}
func TestFormulaeNoCaveats(t *testing.T) {
@@ -60,4 +62,5 @@ func TestFormulaeNoCaveats(t *testing.T) {
formulae := out.String()
assertDefaultTemplateData(t, formulae)
assert.NotContains(formulae, "def caveats")
assert.NotContains(formulae, "depends_on")
}