mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-04 03:11:55 +02:00
homebrew: add custom install command
This commit is contained in:
parent
7e8dcdae77
commit
938b50c399
@ -280,9 +280,14 @@ brew:
|
||||
- bash
|
||||
|
||||
# Packages that run as a service
|
||||
plist:
|
||||
plist:|
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
...
|
||||
|
||||
# Custom install script for brew. Default: "bin.install "program"
|
||||
install:|
|
||||
bin.install "program"
|
||||
...
|
||||
```
|
||||
|
||||
By defining the `brew` section, GoReleaser will take care of publishing the Homebrew tap.
|
||||
|
@ -12,6 +12,7 @@ type Homebrew struct {
|
||||
Folder string
|
||||
Caveats string
|
||||
Plist string
|
||||
Install string
|
||||
Dependencies []string
|
||||
Conflicts []string
|
||||
}
|
||||
|
@ -37,10 +37,22 @@ const formula = `class {{ .Name }} < Formula
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if .Install }}
|
||||
|
||||
def install
|
||||
{{- range $index, $element := .Install }}
|
||||
{{ . -}}
|
||||
{{- end }}
|
||||
end
|
||||
|
||||
{{- else }}
|
||||
|
||||
def install
|
||||
bin.install "{{ .BinaryName }}"
|
||||
end
|
||||
|
||||
{{- end }}
|
||||
|
||||
{{- if .Caveats }}
|
||||
|
||||
def caveats
|
||||
@ -71,6 +83,7 @@ type templateData struct {
|
||||
Format string
|
||||
SHA256 string
|
||||
Plist string
|
||||
Install []string
|
||||
Dependencies []string
|
||||
Conflicts []string
|
||||
}
|
||||
@ -188,6 +201,7 @@ func dataFor(
|
||||
Dependencies: ctx.Config.Brew.Dependencies,
|
||||
Conflicts: ctx.Config.Brew.Conflicts,
|
||||
Plist: ctx.Config.Brew.Plist,
|
||||
Install: strings.Split(ctx.Config.Brew.Install, "\n"),
|
||||
}, err
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ var defaultTemplateData = templateData{
|
||||
File: "test_Darwin_x86_64",
|
||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
|
||||
Format: "tar.gz",
|
||||
Plist: "it works",
|
||||
}
|
||||
|
||||
func assertDefaultTemplateData(t *testing.T, formulae string) {
|
||||
@ -39,7 +38,6 @@ func assertDefaultTemplateData(t *testing.T, formulae string) {
|
||||
assert.Contains(formulae, "url \"https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz\"")
|
||||
assert.Contains(formulae, "sha256 \"1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68\"")
|
||||
assert.Contains(formulae, "version \"0.1.3\"")
|
||||
assert.Contains(formulae, "bin.install \"test\"")
|
||||
}
|
||||
|
||||
func TestFullFormulae(t *testing.T) {
|
||||
@ -48,6 +46,8 @@ func TestFullFormulae(t *testing.T) {
|
||||
data.Caveats = "Here are some caveats"
|
||||
data.Dependencies = []string{"gtk", "git"}
|
||||
data.Conflicts = []string{"conflicting_dep"}
|
||||
data.Plist = "it works"
|
||||
data.Install = []string{"custom install script", "another install script"}
|
||||
out, err := doBuildFormula(data)
|
||||
assert.NoError(err)
|
||||
formulae := out.String()
|
||||
@ -57,6 +57,8 @@ func TestFullFormulae(t *testing.T) {
|
||||
assert.Contains(formulae, "depends_on \"gtk\"")
|
||||
assert.Contains(formulae, "depends_on \"git\"")
|
||||
assert.Contains(formulae, "conflicts_with \"conflicting_dep\"")
|
||||
assert.Contains(formulae, "custom install script")
|
||||
assert.Contains(formulae, "another install script")
|
||||
assert.Contains(formulae, "def plist;")
|
||||
}
|
||||
|
||||
@ -66,6 +68,8 @@ func TestFormulaeSimple(t *testing.T) {
|
||||
assert.NoError(err)
|
||||
formulae := out.String()
|
||||
assertDefaultTemplateData(t, formulae)
|
||||
assert.Contains(formulae, "bin.install \"test\"")
|
||||
assert.NotContains(formulae, "def caveats")
|
||||
assert.NotContains(formulae, "depends_on")
|
||||
assert.NotContains(formulae, "def plist;")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user