Skip to content

Commit

Permalink
feat: add license as first class config key to homebrew (goreleaser#1908
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lukasmalkmus committed Nov 25, 2020
1 parent 761c56a commit ec0e68c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yml
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions internal/pipe/brew/brew.go
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions internal/pipe/brew/brew_test.go
Expand Up @@ -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"}
Expand Down
4 changes: 4 additions & 0 deletions internal/pipe/brew/template.go
Expand Up @@ -7,6 +7,7 @@ type templateData struct {
Desc string
Homepage string
Version string
License string
Caveats []string
Plist string
DownloadStrategy string
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions internal/pipe/brew/testdata/test.rb.golden
Expand Up @@ -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?
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Expand Up @@ -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"`
Expand Down
4 changes: 4 additions & 0 deletions www/docs/customization/homebrew.md
Expand Up @@ -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.
Expand Down

0 comments on commit ec0e68c

Please sign in to comment.