mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-09 13:36:56 +02:00
fix: improving URLs on linuxbrew (#1900)
* fix: improving URLs on linuxbrew Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * refactor: rename template fields Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix(tests): adapts brew test formulas and docs * Revert "fix(tests): adapts brew test formulas and docs" This reverts commit 51dd8cf6c71ebc262661d0fb9cd43946bf4cfdb2. * fix: template Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * docs: fixed example Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> Co-authored-by: Manuel Vogel <mavogel@posteo.de>
This commit is contained in:
parent
40aa04fe71
commit
b4f154d81f
@ -310,21 +310,21 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifa
|
||||
result.MacOS = down
|
||||
} else if artifact.Goos == "linux" {
|
||||
switch artifact.Goarch {
|
||||
case "386", "amd64":
|
||||
if result.Linux.DownloadURL != "" {
|
||||
case "amd64":
|
||||
if result.LinuxAmd64.DownloadURL != "" {
|
||||
return result, ErrMultipleArchivesSameOS
|
||||
}
|
||||
result.Linux = down
|
||||
result.LinuxAmd64 = down
|
||||
case "arm":
|
||||
if result.Arm.DownloadURL != "" {
|
||||
if result.LinuxArm.DownloadURL != "" {
|
||||
return result, ErrMultipleArchivesSameOS
|
||||
}
|
||||
result.Arm = down
|
||||
result.LinuxArm = down
|
||||
case "arm64":
|
||||
if result.Arm64.DownloadURL != "" {
|
||||
if result.LinuxArm64.DownloadURL != "" {
|
||||
return result, ErrMultipleArchivesSameOS
|
||||
}
|
||||
result.Arm64 = down
|
||||
result.LinuxArm64 = down
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,15 +45,15 @@ var defaultTemplateData = templateData{
|
||||
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz",
|
||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
|
||||
},
|
||||
Linux: downloadable{
|
||||
LinuxAmd64: downloadable{
|
||||
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz",
|
||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
|
||||
},
|
||||
Arm: downloadable{
|
||||
LinuxArm: downloadable{
|
||||
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz",
|
||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
|
||||
},
|
||||
Arm64: downloadable{
|
||||
LinuxArm64: downloadable{
|
||||
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz",
|
||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
|
||||
},
|
||||
@ -95,6 +95,25 @@ func TestFullFormulae(t *testing.T) {
|
||||
require.Equal(t, string(bts), formulae)
|
||||
}
|
||||
|
||||
func TestFullFormulaeLinuxOnly(t *testing.T) {
|
||||
data := defaultTemplateData
|
||||
data.MacOS = downloadable{}
|
||||
data.Install = []string{`bin.install "test"`}
|
||||
formulae, err := doBuildFormula(context.New(config.Project{
|
||||
ProjectName: "foo",
|
||||
}), data)
|
||||
require.NoError(t, err)
|
||||
|
||||
var golden = "testdata/test_linux_only.rb.golden"
|
||||
if *update {
|
||||
err := ioutil.WriteFile(golden, []byte(formulae), 0655)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
bts, err := ioutil.ReadFile(golden)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, string(bts), formulae)
|
||||
}
|
||||
|
||||
func TestFormulaeSimple(t *testing.T) {
|
||||
formulae, err := doBuildFormula(context.New(config.Project{}), defaultTemplateData)
|
||||
require.NoError(t, err)
|
||||
@ -504,7 +523,7 @@ func TestRunPipeForMultipleArmVersions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunPipeNoDarwin64Build(t *testing.T) {
|
||||
func TestRunPipeNoBuilds(t *testing.T) {
|
||||
var ctx = &context.Context{
|
||||
TokenType: context.TokenTypeGitHub,
|
||||
Config: config.Project{
|
||||
|
@ -18,9 +18,9 @@ type templateData struct {
|
||||
CustomRequire string
|
||||
CustomBlock []string
|
||||
MacOS downloadable
|
||||
Linux downloadable
|
||||
Arm downloadable
|
||||
Arm64 downloadable
|
||||
LinuxAmd64 downloadable
|
||||
LinuxArm downloadable
|
||||
LinuxArm64 downloadable
|
||||
}
|
||||
|
||||
type downloadable struct {
|
||||
@ -37,39 +37,41 @@ class {{ .Name }} < Formula
|
||||
homepage "{{ .Homepage }}"
|
||||
version "{{ .Version }}"
|
||||
bottle :unneeded
|
||||
|
||||
{{- if and (not .MacOS.DownloadURL) (or .LinuxAmd64.DownloadURL .LinuxArm.DownloadURL .LinuxArm64.DownloadURL) }}
|
||||
depends_on :linux
|
||||
{{- end }}
|
||||
{{- printf "\n" }}
|
||||
{{- if .MacOS.DownloadURL }}
|
||||
if OS.mac?
|
||||
{{- if .MacOS.DownloadURL }}
|
||||
url "{{ .MacOS.DownloadURL }}"
|
||||
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||
sha256 "{{ .MacOS.SHA256 }}"
|
||||
{{- end }}
|
||||
elsif OS.linux?
|
||||
{{- if .Linux.DownloadURL }}
|
||||
if Hardware::CPU.intel?
|
||||
url "{{ .Linux.DownloadURL }}"
|
||||
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||
sha256 "{{ .Linux.SHA256 }}"
|
||||
end
|
||||
{{- end }}
|
||||
{{- if or .Arm.DownloadURL .Arm64.DownloadURL }}
|
||||
if Hardware::CPU.arm?
|
||||
if Hardware::CPU.is_64_bit?
|
||||
{{- if .Arm64.DownloadURL }}
|
||||
url "{{ .Arm64.DownloadURL }}"
|
||||
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||
sha256 "{{ .Arm64.SHA256 }}"
|
||||
{{- end }}
|
||||
else
|
||||
{{- if .Arm.DownloadURL }}
|
||||
url "{{ .Arm.DownloadURL }}"
|
||||
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||
sha256 "{{ .Arm.SHA256 }}"
|
||||
{{- end }}
|
||||
end
|
||||
end
|
||||
{{- end }}
|
||||
end
|
||||
{{- end }}
|
||||
|
||||
{{- if .LinuxAmd64.DownloadURL }}
|
||||
if OS.linux? && Hardware::CPU.intel?
|
||||
url "{{ .LinuxAmd64.DownloadURL }}"
|
||||
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||
sha256 "{{ .LinuxAmd64.SHA256 }}"
|
||||
end
|
||||
{{- end }}
|
||||
|
||||
{{- if .LinuxArm.DownloadURL }}
|
||||
if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
|
||||
url "{{ .LinuxArm.DownloadURL }}"
|
||||
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||
sha256 "{{ .LinuxArm.SHA256 }}"
|
||||
end
|
||||
{{- end }}
|
||||
|
||||
{{- if .LinuxArm64.DownloadURL }}
|
||||
if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
||||
url "{{ .LinuxArm64.DownloadURL }}"
|
||||
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||
sha256 "{{ .LinuxArm64.SHA256 }}"
|
||||
end
|
||||
{{- end }}
|
||||
|
||||
{{- with .CustomBlock }}
|
||||
{{ range $index, $element := . }}
|
||||
|
@ -8,7 +8,6 @@ class CustomBlock < Formula
|
||||
if OS.mac?
|
||||
url "https://dummyhost/download/v1.0.1/bin.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
elsif OS.linux?
|
||||
end
|
||||
|
||||
head "https://github.com/caarlos0/test.git"
|
||||
|
@ -8,7 +8,6 @@ class CustomDownloadStrategy < Formula
|
||||
if OS.mac?
|
||||
url "https://dummyhost/download/v1.0.1/bin.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
elsif OS.linux?
|
||||
end
|
||||
|
||||
depends_on "zsh" => :optional
|
||||
|
@ -9,7 +9,6 @@ class CustomRequire < Formula
|
||||
if OS.mac?
|
||||
url "https://dummyhost/download/v1.0.1/bin.tar.gz", :using => CustomDownloadStrategy
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
elsif OS.linux?
|
||||
end
|
||||
|
||||
depends_on "zsh" => :optional
|
||||
|
@ -8,7 +8,6 @@ class Default < Formula
|
||||
if OS.mac?
|
||||
url "https://dummyhost/download/v1.0.1/bin.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
elsif OS.linux?
|
||||
end
|
||||
|
||||
depends_on "zsh" => :optional
|
||||
|
@ -8,7 +8,6 @@ class DefaultGitlab < Formula
|
||||
if OS.mac?
|
||||
url "https://dummyhost/download/v1.0.1/bin.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
elsif OS.linux?
|
||||
end
|
||||
|
||||
depends_on "zsh" => :optional
|
||||
|
@ -8,7 +8,6 @@ class FooIsBar < Formula
|
||||
if OS.mac?
|
||||
url "https://dummyhost/download/v1.0.1/bin.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
elsif OS.linux?
|
||||
end
|
||||
|
||||
def install
|
||||
|
@ -8,16 +8,14 @@ class MultipleArmv5 < Formula
|
||||
if OS.mac?
|
||||
url "https://dummyhost/download/v1.0.1/bin.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
elsif OS.linux?
|
||||
if Hardware::CPU.arm?
|
||||
if Hardware::CPU.is_64_bit?
|
||||
url "https://dummyhost/download/v1.0.1/arm64.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
else
|
||||
url "https://dummyhost/download/v1.0.1/armv5.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
end
|
||||
end
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
|
||||
url "https://dummyhost/download/v1.0.1/armv5.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
||||
url "https://dummyhost/download/v1.0.1/arm64.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
end
|
||||
|
||||
depends_on "zsh"
|
||||
|
@ -8,16 +8,14 @@ class MultipleArmv6 < Formula
|
||||
if OS.mac?
|
||||
url "https://dummyhost/download/v1.0.1/bin.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
elsif OS.linux?
|
||||
if Hardware::CPU.arm?
|
||||
if Hardware::CPU.is_64_bit?
|
||||
url "https://dummyhost/download/v1.0.1/arm64.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
else
|
||||
url "https://dummyhost/download/v1.0.1/armv6.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
end
|
||||
end
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
|
||||
url "https://dummyhost/download/v1.0.1/armv6.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
||||
url "https://dummyhost/download/v1.0.1/arm64.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
end
|
||||
|
||||
depends_on "zsh"
|
||||
|
@ -8,16 +8,14 @@ class MultipleArmv7 < Formula
|
||||
if OS.mac?
|
||||
url "https://dummyhost/download/v1.0.1/bin.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
elsif OS.linux?
|
||||
if Hardware::CPU.arm?
|
||||
if Hardware::CPU.is_64_bit?
|
||||
url "https://dummyhost/download/v1.0.1/arm64.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
else
|
||||
url "https://dummyhost/download/v1.0.1/armv7.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
end
|
||||
end
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
|
||||
url "https://dummyhost/download/v1.0.1/armv7.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
||||
url "https://dummyhost/download/v1.0.1/arm64.tar.gz"
|
||||
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
end
|
||||
|
||||
depends_on "zsh"
|
||||
|
26
internal/pipe/brew/testdata/test.rb.golden
vendored
26
internal/pipe/brew/testdata/test.rb.golden
vendored
@ -8,20 +8,18 @@ class Test < Formula
|
||||
if OS.mac?
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68"
|
||||
elsif OS.linux?
|
||||
if Hardware::CPU.intel?
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||
end
|
||||
if Hardware::CPU.arm?
|
||||
if Hardware::CPU.is_64_bit?
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||
else
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||
end
|
||||
end
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.intel?
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||
end
|
||||
|
||||
devel do
|
||||
|
25
internal/pipe/brew/testdata/test_linux_only.rb.golden
vendored
Normal file
25
internal/pipe/brew/testdata/test_linux_only.rb.golden
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# This file was generated by GoReleaser. DO NOT EDIT.
|
||||
class Test < Formula
|
||||
desc "Some desc"
|
||||
homepage "https://google.com"
|
||||
version "0.1.3"
|
||||
bottle :unneeded
|
||||
depends_on :linux
|
||||
|
||||
if OS.linux? && Hardware::CPU.intel?
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz"
|
||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||
end
|
||||
|
||||
def install
|
||||
bin.install "test"
|
||||
end
|
||||
end
|
@ -146,18 +146,18 @@ class Program < Formula
|
||||
if os.Mac?
|
||||
url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_macOs_64bit.zip"
|
||||
sha256 "9ee30fc358fae8d248a2d7538957089885da321dca3f09e3296fe2058e7fff74"
|
||||
elsif os.Linux?
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.intel?
|
||||
url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_64bit.zip"
|
||||
sha256 "b41bebd25fd7bb1a67dc2cd5ee12c9f67073094567fdf7b3871f05fd74a45fdd"
|
||||
if Hardware::CPU.arm?
|
||||
if Hardware::CPU.is_64_bit?
|
||||
url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_arm64.zip"
|
||||
sha256 "97cadca3c3c3f36388a4a601acf878dd356d6275a976bee516798b72bfdbeecf"
|
||||
else
|
||||
url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_armv7.zip"
|
||||
sha256 "78f31239430eaaec01df783e2a3443753a8126c325292ed8ddb1658ddd2b401d"
|
||||
end
|
||||
end
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
|
||||
url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_armv7.zip"
|
||||
sha256 "78f31239430eaaec01df783e2a3443753a8126c325292ed8ddb1658ddd2b401d"
|
||||
end
|
||||
if OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
||||
url "https://github.com/user/repo/releases/download/v1.2.3/program_v1.2.3_Linux_arm64.zip"
|
||||
sha256 "97cadca3c3c3f36388a4a601acf878dd356d6275a976bee516798b72bfdbeecf"
|
||||
end
|
||||
|
||||
depends_on "git"
|
||||
|
Loading…
x
Reference in New Issue
Block a user