1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-07 13:31:37 +02:00

feat: support multiple binaries on gofish (#2569)

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2021-10-10 10:52:25 -03:00 committed by GitHub
parent b11f4e5204
commit a393262eb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 194 additions and 82 deletions

View File

@ -14,6 +14,7 @@ type releasePackage struct {
SHA256 string
OS string
Arch string
Binaries []string
}
const foodTemplate = `local name = "{{ .Name }}"
@ -28,19 +29,21 @@ food = {
packages = {
{{- range $element := .ReleasePackages}}
{{- if ne $element.OS ""}}
{
{
os = "{{ $element.OS }}",
arch = "{{ $element.Arch }}",
url = "{{ $element.DownloadURL }}",
sha256 = "{{ $element.SHA256 }}",
resources = {
{{- range $binary := $element.Binaries }}
{
path = {{if ne $element.OS "windows"}}name{{else}}name .. ".exe"{{end}},
installpath = {{if ne $element.OS "windows"}}"bin/" .. name,{{else}}"bin\\" .. name .. ".exe"{{end}}
path = {{if ne $element.OS "windows"}}"{{ $binary }}"{{else}}"{{ $binary }}.exe"{{end}},
installpath = {{if ne $element.OS "windows"}}"bin/{{ $binary }}"{{else}}"bin\\{{ $binary }}.exe"{{end}},
{{- if ne $element.OS "windows"}}
executable = true
{{- end }}
{{- end }}
}
{{- end }}
}
},
{{- end }}

View File

@ -211,6 +211,7 @@ func dataFor(ctx *context.Context, cfg config.GoFish, cl client.Client, artifact
SHA256: sum,
OS: artifact.Goos,
Arch: artifact.Goarch,
Binaries: artifact.ExtraOr("Binaries", []string{}).([]string),
}
for _, v := range result.ReleasePackages {
if v.OS == artifact.Goos && v.Arch == artifact.Goarch {

View File

@ -30,36 +30,42 @@ func createTemplateData() templateData {
OS: "darwin",
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz",
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
Binaries: []string{"bin1", "bin2", "bin3"},
},
{
Arch: "arm64",
OS: "darwin",
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz",
SHA256: "1633f61598ab0791e213135923624eb342196b349490sadasdsadsadasdasdsd",
Binaries: []string{"bin1", "bin2", "bin3"},
},
{
Arch: "amd64",
OS: "linux",
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz",
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
Binaries: []string{"bin1", "bin2", "bin3"},
},
{
Arch: "arm",
OS: "linux",
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz",
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
Binaries: []string{"bin1", "bin2", "bin3"},
},
{
Arch: "arm64",
OS: "linux",
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz",
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
Binaries: []string{"bin1", "bin2", "bin3"},
},
{
Arch: "amd64",
OS: "windows",
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_windows_amd64.zip",
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
Binaries: []string{"bin1", "bin2", "bin3"},
},
},
Name: "Test",
@ -202,8 +208,9 @@ func TestFullPipe(t *testing.T) {
Goarch: "amd64",
Type: artifact.UploadableArchive,
Extra: map[string]interface{}{
"ID": "foo",
"Format": "tar.gz",
"ID": "foo",
"Format": "tar.gz",
"Binaries": []string{"name"},
},
})
@ -266,8 +273,9 @@ func TestRunPipeNameTemplate(t *testing.T) {
Goarch: "amd64",
Type: artifact.UploadableArchive,
Extra: map[string]interface{}{
"ID": "foo",
"Format": "tar.gz",
"ID": "foo",
"Format": "tar.gz",
"Binaries": []string{"foo"},
},
})
@ -344,8 +352,9 @@ func TestRunPipeMultipleGoFishWithSkip(t *testing.T) {
Goarch: "amd64",
Type: artifact.UploadableArchive,
Extra: map[string]interface{}{
"ID": "foo",
"Format": "tar.gz",
"ID": "foo",
"Format": "tar.gz",
"Binaries": []string{"foo"},
},
})
@ -459,8 +468,9 @@ func TestRunPipeForMultipleArmVersions(t *testing.T) {
Goarm: a.goarm,
Type: artifact.UploadableArchive,
Extra: map[string]interface{}{
"ID": a.name,
"Format": "tar.gz",
"ID": a.name,
"Format": "tar.gz",
"Binaries": []string{"foo"},
},
})
f, err := os.Create(path)
@ -636,8 +646,9 @@ func TestRunPipeMultipleArchivesSameOsBuild(t *testing.T) {
Goarch: ttt.goarch,
Type: artifact.UploadableArchive,
Extra: map[string]interface{}{
"ID": fmt.Sprintf("foo%d", idx),
"Format": "tar.gz",
"ID": fmt.Sprintf("foo%d", idx),
"Format": "tar.gz",
"Binaries": []string{"foo"},
},
})
}
@ -702,8 +713,9 @@ func TestRunPipeNoUpload(t *testing.T) {
Goarch: "amd64",
Type: artifact.UploadableArchive,
Extra: map[string]interface{}{
"ID": "foo",
"Format": "tar.gz",
"ID": "foo",
"Format": "tar.gz",
"Binaries": []string{"foo"},
},
})
client := client.NewMock()

View File

@ -8,80 +8,138 @@ food = {
homepage = "https://google.com",
version = version,
packages = {
{
{
os = "darwin",
arch = "amd64",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz",
sha256 = "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "bin1",
installpath = "bin/bin1",
executable = true
}
{
path = "bin2",
installpath = "bin/bin2",
executable = true
}
{
path = "bin3",
installpath = "bin/bin3",
executable = true
}
}
},
{
{
os = "darwin",
arch = "arm64",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz",
sha256 = "1633f61598ab0791e213135923624eb342196b349490sadasdsadsadasdasdsd",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "bin1",
installpath = "bin/bin1",
executable = true
}
{
path = "bin2",
installpath = "bin/bin2",
executable = true
}
{
path = "bin3",
installpath = "bin/bin3",
executable = true
}
}
},
{
{
os = "linux",
arch = "amd64",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz",
sha256 = "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "bin1",
installpath = "bin/bin1",
executable = true
}
{
path = "bin2",
installpath = "bin/bin2",
executable = true
}
{
path = "bin3",
installpath = "bin/bin3",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz",
sha256 = "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "bin1",
installpath = "bin/bin1",
executable = true
}
{
path = "bin2",
installpath = "bin/bin2",
executable = true
}
{
path = "bin3",
installpath = "bin/bin3",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm64",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz",
sha256 = "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "bin1",
installpath = "bin/bin1",
executable = true
}
{
path = "bin2",
installpath = "bin/bin2",
executable = true
}
{
path = "bin3",
installpath = "bin/bin3",
executable = true
}
}
},
{
{
os = "windows",
arch = "amd64",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_windows_amd64.zip",
sha256 = "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
resources = {
{
path = name .. ".exe",
installpath = "bin\\" .. name .. ".exe"
path = "bin1.exe",
installpath = "bin\\bin1.exe",
}
{
path = "bin2.exe",
installpath = "bin\\bin2.exe",
}
{
path = "bin3.exe",
installpath = "bin\\bin3.exe",
}
}
},

View File

@ -8,41 +8,71 @@ food = {
homepage = "https://google.com",
version = version,
packages = {
{
{
os = "linux",
arch = "amd64",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz",
sha256 = "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "bin1",
installpath = "bin/bin1",
executable = true
}
{
path = "bin2",
installpath = "bin/bin2",
executable = true
}
{
path = "bin3",
installpath = "bin/bin3",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm6.tar.gz",
sha256 = "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "bin1",
installpath = "bin/bin1",
executable = true
}
{
path = "bin2",
installpath = "bin/bin2",
executable = true
}
{
path = "bin3",
installpath = "bin/bin3",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm64",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Arm64.tar.gz",
sha256 = "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "bin1",
installpath = "bin/bin1",
executable = true
}
{
path = "bin2",
installpath = "bin/bin2",
executable = true
}
{
path = "bin3",
installpath = "bin/bin3",
executable = true
}
}

View File

@ -8,15 +8,23 @@ food = {
homepage = "https://google.com",
version = version,
packages = {
{
{
os = "windows",
arch = "amd64",
url = "https://github.com/caarlos0/test/releases/download/v0.1.3/test_windows_amd64.zip",
sha256 = "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
resources = {
{
path = name .. ".exe",
installpath = "bin\\" .. name .. ".exe"
path = "bin1.exe",
installpath = "bin\\bin1.exe",
}
{
path = "bin2.exe",
installpath = "bin\\bin2.exe",
}
{
path = "bin3.exe",
installpath = "bin\\bin3.exe",
}
}
},

View File

@ -8,15 +8,15 @@ food = {
homepage = "https://github.com/goreleaser",
version = version,
packages = {
{
{
os = "darwin",
arch = "amd64",
url = "https://dummyhost/download/v1.0.1/bin.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "name",
installpath = "bin/name",
executable = true
}
}

View File

@ -8,15 +8,15 @@ food = {
homepage = "https://gitlab.com/goreleaser",
version = version,
packages = {
{
{
os = "darwin",
arch = "amd64",
url = "https://dummyhost/download/v1.0.1/bin.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "name",
installpath = "bin/name",
executable = true
}
}

View File

@ -8,41 +8,41 @@ food = {
homepage = "https://github.com/goreleaser",
version = version,
packages = {
{
{
os = "darwin",
arch = "amd64",
url = "https://dummyhost/download/v1.0.1/bin.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm64",
url = "https://dummyhost/download/v1.0.1/arm64.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm",
url = "https://dummyhost/download/v1.0.1/armv5.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}

View File

@ -8,41 +8,41 @@ food = {
homepage = "https://github.com/goreleaser",
version = version,
packages = {
{
{
os = "darwin",
arch = "amd64",
url = "https://dummyhost/download/v1.0.1/bin.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm64",
url = "https://dummyhost/download/v1.0.1/arm64.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm",
url = "https://dummyhost/download/v1.0.1/armv6.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}

View File

@ -8,41 +8,41 @@ food = {
homepage = "https://github.com/goreleaser",
version = version,
packages = {
{
{
os = "darwin",
arch = "amd64",
url = "https://dummyhost/download/v1.0.1/bin.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm64",
url = "https://dummyhost/download/v1.0.1/arm64.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}
},
{
{
os = "linux",
arch = "arm",
url = "https://dummyhost/download/v1.0.1/armv7.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}

View File

@ -8,15 +8,15 @@ food = {
homepage = "",
version = version,
packages = {
{
{
os = "darwin",
arch = "amd64",
url = "https://dummyhost/download/v1.0.1/bin.tar.gz",
sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
resources = {
{
path = name,
installpath = "bin/" .. name,
path = "foo",
installpath = "bin/foo",
executable = true
}
}