mirror of
https://github.com/goreleaser/goreleaser.git
synced 2024-12-27 01:33:39 +02:00
fix: first class build targets
This commit is contained in:
parent
a93f40b8cf
commit
d933d8b316
@ -96,47 +96,46 @@ func (*Builder) WithDefaults(build config.Build) (config.Build, error) {
|
||||
if target == go118FirstClassTargetsName ||
|
||||
target == goStableFirstClassTargetsName {
|
||||
for _, t := range go118FirstClassTargets {
|
||||
targets[t] = true
|
||||
targets[fixTarget(t)] = true
|
||||
}
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_amd64") {
|
||||
targets[target+"_v1"] = true
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_386") {
|
||||
targets[target+"_sse2"] = true
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_arm") {
|
||||
targets[target+"_7"] = true
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_arm64") {
|
||||
targets[target+"_v8.0"] = true
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_mips") ||
|
||||
strings.HasSuffix(target, "_mips64") ||
|
||||
strings.HasSuffix(target, "_mipsle") ||
|
||||
strings.HasSuffix(target, "_mips64le") {
|
||||
targets[target+"_hardfloat"] = true
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_ppc64") ||
|
||||
strings.HasSuffix(target, "_ppc64le") {
|
||||
targets[target+"_power8"] = true
|
||||
}
|
||||
if strings.HasSuffix(target, "_riscv64") {
|
||||
targets[target+"_rva20u64"] = true
|
||||
}
|
||||
targets[target] = true
|
||||
targets[fixTarget(target)] = true
|
||||
}
|
||||
build.Targets = keys(targets)
|
||||
}
|
||||
return build, nil
|
||||
}
|
||||
|
||||
func fixTarget(target string) string {
|
||||
if strings.HasSuffix(target, "_amd64") {
|
||||
return target + "_v1"
|
||||
}
|
||||
if strings.HasSuffix(target, "_386") {
|
||||
return target + "_sse2"
|
||||
}
|
||||
if strings.HasSuffix(target, "_arm") {
|
||||
return target + "_" + experimental.DefaultGOARM()
|
||||
}
|
||||
if strings.HasSuffix(target, "_arm64") {
|
||||
return target + "_v8.0"
|
||||
}
|
||||
if strings.HasSuffix(target, "_mips") ||
|
||||
strings.HasSuffix(target, "_mips64") ||
|
||||
strings.HasSuffix(target, "_mipsle") ||
|
||||
strings.HasSuffix(target, "_mips64le") {
|
||||
return target + "_hardfloat"
|
||||
}
|
||||
if strings.HasSuffix(target, "_ppc64") ||
|
||||
strings.HasSuffix(target, "_ppc64le") {
|
||||
return target + "_power8"
|
||||
}
|
||||
if strings.HasSuffix(target, "_riscv64") {
|
||||
return target + "_rva20u64"
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
func warnIfTargetsAndOtherOptionTogether(build config.Build) bool {
|
||||
if len(build.Targets) == 0 {
|
||||
return false
|
||||
@ -179,14 +178,14 @@ const (
|
||||
|
||||
// go tool dist list -json | jq -r '.[] | select(.FirstClass) | [.GOOS, .GOARCH] | @tsv'
|
||||
var go118FirstClassTargets = []string{
|
||||
"darwin_amd64_v1",
|
||||
"darwin_amd64",
|
||||
"darwin_arm64",
|
||||
"linux_386",
|
||||
"linux_amd64_v1",
|
||||
"linux_arm_6",
|
||||
"linux_amd64",
|
||||
"linux_arm",
|
||||
"linux_arm64",
|
||||
"windows_386",
|
||||
"windows_amd64_v1",
|
||||
"windows_amd64",
|
||||
}
|
||||
|
||||
// Build builds a golang build.
|
||||
|
@ -22,6 +22,17 @@ import (
|
||||
|
||||
var runtimeTarget = runtime.GOOS + "_" + runtime.GOARCH
|
||||
|
||||
var go118FirstClassAdjustedTargets = []string{
|
||||
"darwin_amd64_v1",
|
||||
"darwin_arm64_v8.0",
|
||||
"linux_386_sse2",
|
||||
"linux_amd64_v1",
|
||||
"linux_arm_6",
|
||||
"linux_arm64_v8.0",
|
||||
"windows_386_sse2",
|
||||
"windows_amd64_v1",
|
||||
}
|
||||
|
||||
func TestWithDefaults(t *testing.T) {
|
||||
for name, testcase := range map[string]struct {
|
||||
build config.Build
|
||||
@ -120,7 +131,7 @@ func TestWithDefaults(t *testing.T) {
|
||||
Binary: "foo",
|
||||
Targets: []string{"linux_arm"},
|
||||
},
|
||||
targets: []string{"linux_arm_7"},
|
||||
targets: []string{"linux_arm_6"},
|
||||
goBinary: "go",
|
||||
},
|
||||
"custom targets no mips": {
|
||||
@ -201,7 +212,7 @@ func TestWithDefaults(t *testing.T) {
|
||||
Binary: "foo",
|
||||
Targets: []string{goStableFirstClassTargetsName},
|
||||
},
|
||||
targets: go118FirstClassTargets,
|
||||
targets: go118FirstClassAdjustedTargets,
|
||||
goBinary: "go",
|
||||
},
|
||||
"go 1.18 first class targets": {
|
||||
@ -210,7 +221,7 @@ func TestWithDefaults(t *testing.T) {
|
||||
Binary: "foo",
|
||||
Targets: []string{go118FirstClassTargetsName},
|
||||
},
|
||||
targets: go118FirstClassTargets,
|
||||
targets: go118FirstClassAdjustedTargets,
|
||||
goBinary: "go",
|
||||
},
|
||||
"go 1.18 first class targets plus custom": {
|
||||
@ -219,7 +230,7 @@ func TestWithDefaults(t *testing.T) {
|
||||
Binary: "foo",
|
||||
Targets: []string{"linux_amd64_v1", go118FirstClassTargetsName, "darwin_amd64_v2"},
|
||||
},
|
||||
targets: append(go118FirstClassTargets, "darwin_amd64_v2"),
|
||||
targets: append(go118FirstClassAdjustedTargets, "darwin_amd64_v2"),
|
||||
goBinary: "go",
|
||||
},
|
||||
"repeatin targets": {
|
||||
@ -228,7 +239,7 @@ func TestWithDefaults(t *testing.T) {
|
||||
Binary: "foo",
|
||||
Targets: []string{go118FirstClassTargetsName, go118FirstClassTargetsName, goStableFirstClassTargetsName},
|
||||
},
|
||||
targets: go118FirstClassTargets,
|
||||
targets: go118FirstClassAdjustedTargets,
|
||||
goBinary: "go",
|
||||
},
|
||||
} {
|
||||
@ -416,7 +427,13 @@ func TestBuild(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
require.ElementsMatch(t, ctx.Artifacts.List(), []*artifact.Artifact{
|
||||
list := ctx.Artifacts
|
||||
require.NoError(t, list.Visit(func(a *artifact.Artifact) error {
|
||||
s, err := filepath.Rel(folder, a.Path)
|
||||
a.Path = s
|
||||
return err
|
||||
}))
|
||||
require.ElementsMatch(t, list.List(), []*artifact.Artifact{
|
||||
{
|
||||
Name: "bin/foo-v5.6.7",
|
||||
Path: filepath.Join("dist", "linux_amd64", "bin", "foo-v5.6.7"),
|
||||
|
Loading…
Reference in New Issue
Block a user