Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(homebrew): add os to dependency #4481

Merged
merged 1 commit into from Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/pipe/brew/brew_test.go
Expand Up @@ -313,6 +313,8 @@ func TestFullPipe(t *testing.T) {
{Name: "zsh", Type: "optional"},
{Name: "bash", Version: "3.2.57"},
{Name: "fish", Type: "optional", Version: "v1.2.3"},
{Name: "powershell", Type: "optional", OS: "mac"},
{Name: "ash", Version: "1.0.0", OS: "linux"},
},
Conflicts: []string{"gtk+", "qt"},
Service: "run foo/bar\nkeep_alive true",
Expand Down
1 change: 1 addition & 0 deletions internal/pipe/brew/template.go
Expand Up @@ -49,6 +49,7 @@ class {{ .Name }} < Formula
{{ range $index, $element := . }}
depends_on "{{ .Name }}"
{{- if .Type }} => :{{ .Type }}{{- else if .Version }} => "{{ .Version }}"{{- end }}
{{- with .OS }} if OS.{{ . }}?{{- end }}
{{- end }}
{{- end -}}

Expand Down
Expand Up @@ -7,8 +7,10 @@ class CustomBlock < Formula
homepage "https://github.com/goreleaser"
version "1.0.1"

depends_on "ash" => "1.0.0" if OS.linux?
depends_on "bash" => "3.2.57"
depends_on "fish" => :optional
depends_on "powershell" => :optional if OS.mac?
depends_on "zsh" => :optional

on_macos do
Expand Down
Expand Up @@ -7,8 +7,10 @@ class CustomDownloadStrategy < Formula
homepage "https://github.com/goreleaser"
version "1.0.1"

depends_on "ash" => "1.0.0" if OS.linux?
depends_on "bash" => "3.2.57"
depends_on "fish" => :optional
depends_on "powershell" => :optional if OS.mac?
depends_on "zsh" => :optional

on_macos do
Expand Down
Expand Up @@ -8,8 +8,10 @@ class CustomRequire < Formula
homepage "https://github.com/goreleaser"
version "1.0.1"

depends_on "ash" => "1.0.0" if OS.linux?
depends_on "bash" => "3.2.57"
depends_on "fish" => :optional
depends_on "powershell" => :optional if OS.mac?
depends_on "zsh" => :optional

on_macos do
Expand Down
2 changes: 2 additions & 0 deletions internal/pipe/brew/testdata/TestFullPipe/default.rb.golden
Expand Up @@ -7,8 +7,10 @@ class Default < Formula
homepage "https://github.com/goreleaser"
version "1.0.1"

depends_on "ash" => "1.0.0" if OS.linux?
depends_on "bash" => "3.2.57"
depends_on "fish" => :optional
depends_on "powershell" => :optional if OS.mac?
depends_on "zsh" => :optional

on_macos do
Expand Down
Expand Up @@ -7,8 +7,10 @@ class DefaultGitlab < Formula
homepage "https://gitlab.com/goreleaser"
version "1.0.1"

depends_on "ash" => "1.0.0" if OS.linux?
depends_on "bash" => "3.2.57"
depends_on "fish" => :optional
depends_on "powershell" => :optional if OS.mac?
depends_on "zsh" => :optional

on_macos do
Expand Down
2 changes: 2 additions & 0 deletions internal/pipe/brew/testdata/TestFullPipe/git_remote.rb.golden
Expand Up @@ -7,8 +7,10 @@ class GitRemote < Formula
homepage "https://github.com/goreleaser"
version "1.0.1"

depends_on "ash" => "1.0.0" if OS.linux?
depends_on "bash" => "3.2.57"
depends_on "fish" => :optional
depends_on "powershell" => :optional if OS.mac?
depends_on "zsh" => :optional

on_macos do
Expand Down
2 changes: 2 additions & 0 deletions internal/pipe/brew/testdata/TestFullPipe/open_pr.rb.golden
Expand Up @@ -7,8 +7,10 @@ class OpenPr < Formula
homepage "https://github.com/goreleaser"
version "1.0.1"

depends_on "ash" => "1.0.0" if OS.linux?
depends_on "bash" => "3.2.57"
depends_on "fish" => :optional
depends_on "powershell" => :optional if OS.mac?
depends_on "zsh" => :optional

on_macos do
Expand Down
Expand Up @@ -7,8 +7,10 @@ class ValidRepositoryTemplates < Formula
homepage ""
version "1.0.1"

depends_on "ash" => "1.0.0" if OS.linux?
depends_on "bash" => "3.2.57"
depends_on "fish" => :optional
depends_on "powershell" => :optional if OS.mac?
depends_on "zsh" => :optional

on_macos do
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Expand Up @@ -156,6 +156,7 @@ type HomebrewDependency struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Version string `yaml:"version,omitempty" json:"version,omitempty"`
OS string `yaml:"os,omitempty" json:"os,omitempty" jsonschema:"enum=mac,enum=linux"`
}

// type alias to prevent stack overflowing in the custom unmarshaler.
Expand Down
5 changes: 5 additions & 0 deletions www/docs/customization/homebrew.md
Expand Up @@ -115,6 +115,11 @@ brews:
# Packages your package depends on.
dependencies:
- name: git
# Allow to specify the OS in which the dependency is required.
# Valid options are `mac` and `linux`.
#
# Since: v1.23.0
os: mac
- name: zsh
type: optional
- name: fish
Expand Down
7 changes: 7 additions & 0 deletions www/docs/static/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.