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

feat(brew): post_install (#1790)

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: Grachev Mikhail <work@mgrachev.com>
This commit is contained in:
Carlos Alexandro Becker 2020-09-18 10:42:52 -03:00 committed by GitHub
parent f3f8b71373
commit 2eb6ec200f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 0 deletions

View File

@ -261,6 +261,7 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifa
Conflicts: cfg.Conflicts,
Plist: cfg.Plist,
Install: split(cfg.Install),
PostInstall: cfg.PostInstall,
Tests: split(cfg.Test),
DownloadStrategy: cfg.DownloadStrategy,
CustomRequire: cfg.CustomRequire,

View File

@ -77,6 +77,7 @@ func TestFullFormulae(t *testing.T) {
data.Dependencies = []config.HomebrewDependency{{Name: "gtk+"}}
data.Conflicts = []string{"svn"}
data.Plist = "it works"
data.PostInstall = `system "touch", "/tmp/foo"`
data.CustomBlock = []string{"devel do", ` url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz"`, ` sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68"`, "end"}
data.Install = []string{"custom install script", "another install script"}
data.Tests = []string{`system "#{bin}/{{.ProjectName}} -version"`}

View File

@ -11,6 +11,7 @@ type templateData struct {
Plist string
DownloadStrategy string
Install []string
PostInstall string
Dependencies []config.HomebrewDependency
Conflicts []string
Tests []string
@ -95,6 +96,13 @@ class {{ .Name }} < Formula
{{- end }}
end
{{- with .PostInstall }}
def post_install
{{ . }}
end
{{- end -}}
{{- with .Caveats }}
def caveats; <<~EOS

View File

@ -38,6 +38,10 @@ class Test < Formula
another install script
end
def post_install
system "touch", "/tmp/foo"
end
def caveats; <<~EOS
Here are some caveats
EOS

View File

@ -95,6 +95,7 @@ type Homebrew struct {
Caveats string `yaml:",omitempty"`
Plist string `yaml:",omitempty"`
Install string `yaml:",omitempty"`
PostInstall string `yaml:"post_install,omitempty"`
Dependencies []HomebrewDependency `yaml:",omitempty"`
Test string `yaml:",omitempty"`
Conflicts []string `yaml:",omitempty"`