mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-30 04:50:45 +02:00
Merge pull request #87 from goreleaser/brew-depends
added brew dependencies support
This commit is contained in:
commit
4328f8279a
@ -8,9 +8,10 @@ import (
|
||||
|
||||
// Homebrew contains the brew section
|
||||
type Homebrew struct {
|
||||
Repo string
|
||||
Folder string
|
||||
Caveats string
|
||||
Repo string
|
||||
Folder string
|
||||
Caveats string
|
||||
Dependencies []string
|
||||
}
|
||||
|
||||
// Build contains the build configuration section
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
@ -135,16 +151,17 @@ func dataFor(ctx *context.Context, client *github.Client) (result templateData,
|
||||
description = *rep.Description
|
||||
}
|
||||
return templateData{
|
||||
Name: formulaNameFor(ctx.Config.Build.BinaryName),
|
||||
Desc: description,
|
||||
Homepage: homepage,
|
||||
Repo: ctx.Config.Release.Repo,
|
||||
Tag: ctx.Git.CurrentTag,
|
||||
BinaryName: ctx.Config.Build.BinaryName,
|
||||
Caveats: ctx.Config.Brew.Caveats,
|
||||
File: file,
|
||||
Format: ctx.Config.Archive.Format,
|
||||
SHA256: sum,
|
||||
Name: formulaNameFor(ctx.Config.Build.BinaryName),
|
||||
Desc: description,
|
||||
Homepage: homepage,
|
||||
Repo: ctx.Config.Release.Repo,
|
||||
Tag: ctx.Git.CurrentTag,
|
||||
BinaryName: ctx.Config.Build.BinaryName,
|
||||
Caveats: ctx.Config.Brew.Caveats,
|
||||
File: file,
|
||||
Format: ctx.Config.Archive.Format,
|
||||
SHA256: sum,
|
||||
Dependencies: ctx.Config.Brew.Dependencies,
|
||||
}, err
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user