diff --git a/.goreleaser.yml b/.goreleaser.yml index c860365776a..10cf16535c6 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -101,6 +101,7 @@ brews: folder: Formula homepage: https://goreleaser.com description: Deliver Go binaries as fast and easily as possible + license: MIT test: | system "#{bin}/goreleaser -v" dependencies: diff --git a/internal/pipe/brew/brew.go b/internal/pipe/brew/brew.go index e96e1c105d4..ebb368b5ac1 100644 --- a/internal/pipe/brew/brew.go +++ b/internal/pipe/brew/brew.go @@ -266,6 +266,7 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifa Desc: cfg.Description, Homepage: cfg.Homepage, Version: ctx.Version, + License: cfg.License, Caveats: split(cfg.Caveats), Dependencies: cfg.Dependencies, Conflicts: cfg.Conflicts, diff --git a/internal/pipe/brew/brew_test.go b/internal/pipe/brew/brew_test.go index b2e8cab0e85..4c4df9d4657 100644 --- a/internal/pipe/brew/brew_test.go +++ b/internal/pipe/brew/brew_test.go @@ -72,6 +72,7 @@ func assertDefaultTemplateData(t *testing.T, formulae string) { func TestFullFormulae(t *testing.T) { data := defaultTemplateData + data.License = "MIT" data.Caveats = []string{"Here are some caveats"} data.Dependencies = []config.HomebrewDependency{{Name: "gtk+"}} data.Conflicts = []string{"svn"} diff --git a/internal/pipe/brew/template.go b/internal/pipe/brew/template.go index a084e2ec13d..3e88b1c3ba0 100644 --- a/internal/pipe/brew/template.go +++ b/internal/pipe/brew/template.go @@ -7,6 +7,7 @@ type templateData struct { Desc string Homepage string Version string + License string Caveats []string Plist string DownloadStrategy string @@ -36,6 +37,9 @@ class {{ .Name }} < Formula desc "{{ .Desc }}" homepage "{{ .Homepage }}" version "{{ .Version }}" + {{ if .License -}} + license "{{ .License }}" + {{ end -}} bottle :unneeded {{- if and (not .MacOS.DownloadURL) (or .LinuxAmd64.DownloadURL .LinuxArm.DownloadURL .LinuxArm64.DownloadURL) }} depends_on :linux diff --git a/internal/pipe/brew/testdata/test.rb.golden b/internal/pipe/brew/testdata/test.rb.golden index a0eda49200f..2ad3bbcddbb 100644 --- a/internal/pipe/brew/testdata/test.rb.golden +++ b/internal/pipe/brew/testdata/test.rb.golden @@ -3,6 +3,7 @@ class Test < Formula desc "Some desc" homepage "https://google.com" version "0.1.3" + license "MIT" bottle :unneeded if OS.mac? diff --git a/pkg/config/config.go b/pkg/config/config.go index c34110be61f..07061cd64fd 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -102,6 +102,7 @@ type Homebrew struct { Conflicts []string `yaml:",omitempty"` Description string `yaml:",omitempty"` Homepage string `yaml:",omitempty"` + License string `yaml:",omitempty"` SkipUpload string `yaml:"skip_upload,omitempty"` DownloadStrategy string `yaml:"download_strategy,omitempty"` URLTemplate string `yaml:"url_template,omitempty"` diff --git a/www/docs/customization/homebrew.md b/www/docs/customization/homebrew.md index 84072273d75..a6670d98eb1 100644 --- a/www/docs/customization/homebrew.md +++ b/www/docs/customization/homebrew.md @@ -84,6 +84,10 @@ brews: # Default is empty. description: "Software to create fast and easy drum rolls." + # SPDX identifier of your app's license. + # Default is empty. + license: "MIT" + # Setting this will prevent goreleaser to actually try to commit the updated # formula - instead, the formula file will be stored on the dist folder only, # leaving the responsibility of publishing it to the user.