Repository: goreleaser/goreleaser
Pull request #2062 (2021-02-17 00:12:07)

fix: brew: check cpu
since now there are both amd64 and arm64 downloads for macs, I think its better to guard the amd64 download with a "if intel" check...

vercel[bot]: This pull request is being automatically deployed with Vercel ([learn more](https://vercel.link/github-learn-more)).  
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: [https://vercel.com/goreleaser/goreleaser/lakv4sv3j](https://vercel.com/goreleaser/goreleaser/lakv4sv3j)  
✅ Preview: [https://goreleaser-git-fix-brew.goreleaser.vercel.app](https://goreleaser-git-fix-brew.goreleaser.vercel.app)


codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2062?src=pr&el=h1) Report
> Merging [#2062](https://codecov.io/gh/goreleaser/goreleaser/pull/2062?src=pr&el=desc) (39a21ea) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/5e1ea32203c719404e83b06ab21dcb1d9ef18530?el=desc) (5e1ea32) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/2062/graphs/tree.svg?width=650&height=150&src=pr&token=3bJvv6b7hN)](https://codecov.io/gh/goreleaser/goreleaser/pull/2062?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #2062   +/-   ##
=======================================
  Coverage   82.87%   82.87%           
=======================================
  Files          74       74           
  Lines        3977     3977           
=======================================
  Hits         3296     3296           
  Misses        557      557           
  Partials      124      124           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2062?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2062?src=pr&el=footer). Last update [5e1ea32...39a21ea](https://codecov.io/gh/goreleaser/goreleaser/pull/2062?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/internal/pipe/brew/template.go b/internal/pipe/brew/template.go
index a189932d..fa96df49 100644
--- a/internal/pipe/brew/template.go
+++ b/internal/pipe/brew/template.go
@@ -50,7 +50,7 @@ class {{ .Name }} < Formula
   {{- end }}
   {{- printf "\n" }}
   {{- if .MacOSAmd64.DownloadURL }}
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "{{ .MacOSAmd64.DownloadURL }}"
     {{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
     sha256 "{{ .MacOSAmd64.SHA256 }}"


Test patch:
diff --git a/internal/pipe/brew/testdata/custom_block.rb.golden b/internal/pipe/brew/testdata/custom_block.rb.golden
index d5ffa733..25ac5f6e 100644
--- a/internal/pipe/brew/testdata/custom_block.rb.golden
+++ b/internal/pipe/brew/testdata/custom_block.rb.golden
@@ -8,7 +8,7 @@ class CustomBlock < Formula
   version "1.0.1"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://dummyhost/download/v1.0.1/bin.tar.gz"
     sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
   end
diff --git a/internal/pipe/brew/testdata/custom_download_strategy.rb.golden b/internal/pipe/brew/testdata/custom_download_strategy.rb.golden
index af685d87..1491e927 100644
--- a/internal/pipe/brew/testdata/custom_download_strategy.rb.golden
+++ b/internal/pipe/brew/testdata/custom_download_strategy.rb.golden
@@ -8,7 +8,7 @@ class CustomDownloadStrategy < Formula
   version "1.0.1"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://dummyhost/download/v1.0.1/bin.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
     sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
   end
diff --git a/internal/pipe/brew/testdata/custom_require.rb.golden b/internal/pipe/brew/testdata/custom_require.rb.golden
index 3a3ae4d5..3baaef0e 100644
--- a/internal/pipe/brew/testdata/custom_require.rb.golden
+++ b/internal/pipe/brew/testdata/custom_require.rb.golden
@@ -9,7 +9,7 @@ class CustomRequire < Formula
   version "1.0.1"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://dummyhost/download/v1.0.1/bin.tar.gz", :using => CustomDownloadStrategy
     sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
   end
diff --git a/internal/pipe/brew/testdata/default.rb.golden b/internal/pipe/brew/testdata/default.rb.golden
index b7231ac6..91c4f54a 100644
--- a/internal/pipe/brew/testdata/default.rb.golden
+++ b/internal/pipe/brew/testdata/default.rb.golden
@@ -8,7 +8,7 @@ class Default < Formula
   version "1.0.1"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://dummyhost/download/v1.0.1/bin.tar.gz"
     sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
   end
diff --git a/internal/pipe/brew/testdata/default_gitlab.rb.golden b/internal/pipe/brew/testdata/default_gitlab.rb.golden
index c8fb41f5..b99b5421 100644
--- a/internal/pipe/brew/testdata/default_gitlab.rb.golden
+++ b/internal/pipe/brew/testdata/default_gitlab.rb.golden
@@ -8,7 +8,7 @@ class DefaultGitlab < Formula
   version "1.0.1"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://dummyhost/download/v1.0.1/bin.tar.gz"
     sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
   end
diff --git a/internal/pipe/brew/testdata/foo_is_bar.rb.golden b/internal/pipe/brew/testdata/foo_is_bar.rb.golden
index 46ef06ac..e4920feb 100644
--- a/internal/pipe/brew/testdata/foo_is_bar.rb.golden
+++ b/internal/pipe/brew/testdata/foo_is_bar.rb.golden
@@ -8,7 +8,7 @@ class FooIsBar < Formula
   version "1.0.1"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://dummyhost/download/v1.0.1/bin.tar.gz"
     sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
   end
diff --git a/internal/pipe/brew/testdata/multiple_armv5.rb.golden b/internal/pipe/brew/testdata/multiple_armv5.rb.golden
index 0c7e8ce1..7480086c 100644
--- a/internal/pipe/brew/testdata/multiple_armv5.rb.golden
+++ b/internal/pipe/brew/testdata/multiple_armv5.rb.golden
@@ -8,7 +8,7 @@ class MultipleArmv5 < Formula
   version "1.0.1"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://dummyhost/download/v1.0.1/bin.tar.gz"
     sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
   end
diff --git a/internal/pipe/brew/testdata/multiple_armv6.rb.golden b/internal/pipe/brew/testdata/multiple_armv6.rb.golden
index 6d2f24bc..83877a67 100644
--- a/internal/pipe/brew/testdata/multiple_armv6.rb.golden
+++ b/internal/pipe/brew/testdata/multiple_armv6.rb.golden
@@ -8,7 +8,7 @@ class MultipleArmv6 < Formula
   version "1.0.1"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://dummyhost/download/v1.0.1/bin.tar.gz"
     sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
   end
diff --git a/internal/pipe/brew/testdata/multiple_armv7.rb.golden b/internal/pipe/brew/testdata/multiple_armv7.rb.golden
index 759c53ab..074a1526 100644
--- a/internal/pipe/brew/testdata/multiple_armv7.rb.golden
+++ b/internal/pipe/brew/testdata/multiple_armv7.rb.golden
@@ -8,7 +8,7 @@ class MultipleArmv7 < Formula
   version "1.0.1"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://dummyhost/download/v1.0.1/bin.tar.gz"
     sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
   end
diff --git a/internal/pipe/brew/testdata/test.rb.golden b/internal/pipe/brew/testdata/test.rb.golden
index aceee039..87d67479 100644
--- a/internal/pipe/brew/testdata/test.rb.golden
+++ b/internal/pipe/brew/testdata/test.rb.golden
@@ -9,7 +9,7 @@ class Test < Formula
   license "MIT"
   bottle :unneeded
 
-  if OS.mac?
+  if OS.mac? && Hardware::CPU.intel?
     url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz"
     sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68"
   end