You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-06 09:09:29 +02:00
feat: support GOAMD64 (#3016)
* feat: support GOAMD64 * fix: test * wip * wip: docker et al * fix: archive format name * test: added new test * feat: nfpm amd4, mips et al * chore: rm unused file * fix: brew for multiple goamd64 * fix: krew * feat: aur * feat: krew * docs: brew * feat: gofis * feat: scoop * fix: docker filters * fix: snapcraft * fix: improve diff a bit * fix: snapcraft name template
This commit is contained in:
committed by
GitHub
parent
acfffe1c98
commit
b0583c700b
@@ -1,5 +1,5 @@
|
||||
// Package buildtarget can generate a list of targets based on a matrix of
|
||||
// goos, goarch, goarm, gomips and go version.
|
||||
// goos, goarch, goarm, goamd64, gomips and go version.
|
||||
package buildtarget
|
||||
|
||||
import (
|
||||
@@ -15,15 +15,12 @@ import (
|
||||
)
|
||||
|
||||
type target struct {
|
||||
os, arch, arm, mips string
|
||||
os, arch, arm, mips, amd64 string
|
||||
}
|
||||
|
||||
func (t target) String() string {
|
||||
if t.arm != "" {
|
||||
return fmt.Sprintf("%s_%s_%s", t.os, t.arch, t.arm)
|
||||
}
|
||||
if t.mips != "" {
|
||||
return fmt.Sprintf("%s_%s_%s", t.os, t.arch, t.mips)
|
||||
if extra := t.arm + t.mips + t.amd64; extra != "" {
|
||||
return fmt.Sprintf("%s_%s_%s", t.os, t.arch, extra)
|
||||
}
|
||||
return fmt.Sprintf("%s_%s", t.os, t.arch)
|
||||
}
|
||||
@@ -55,6 +52,9 @@ func matrix(build config.Build, version []byte) ([]string, error) {
|
||||
if target.mips != "" && !contains(target.mips, validGomips) {
|
||||
return result, fmt.Errorf("invalid gomips: %s", target.mips)
|
||||
}
|
||||
if target.amd64 != "" && !contains(target.amd64, validGoamd64) {
|
||||
return result, fmt.Errorf("invalid goamd64: %s", target.amd64)
|
||||
}
|
||||
if target.os == "windows" && target.arch == "arm64" && !go117re.Match(version) {
|
||||
log.Warn(color.New(color.Bold, color.FgHiYellow).Sprintf(
|
||||
"DEPRECATED: skipped windows/arm64 build on Go < 1.17 for compatibility, check %s for more info.",
|
||||
@@ -91,6 +91,16 @@ func allBuildTargets(build config.Build) (targets []target) {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(goarch, "amd64") {
|
||||
for _, goamd := range build.Goamd64 {
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
arch: goarch,
|
||||
amd64: goamd,
|
||||
})
|
||||
}
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(goarch, "mips") {
|
||||
for _, gomips := range build.Gomips {
|
||||
targets = append(targets, target{
|
||||
@@ -126,6 +136,9 @@ func ignored(build config.Build, target target) bool {
|
||||
if ig.Gomips != "" && ig.Gomips != target.mips {
|
||||
continue
|
||||
}
|
||||
if ig.Goamd64 != "" && ig.Goamd64 != target.amd64 {
|
||||
continue
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -242,6 +255,7 @@ var (
|
||||
"riscv64",
|
||||
}
|
||||
|
||||
validGoarm = []string{"5", "6", "7"}
|
||||
validGomips = []string{"hardfloat", "softfloat"}
|
||||
validGoarm = []string{"5", "6", "7"}
|
||||
validGomips = []string{"hardfloat", "softfloat"}
|
||||
validGoamd64 = []string{"v2", "v3"}
|
||||
)
|
||||
|
||||
@@ -39,6 +39,10 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
"hardfloat",
|
||||
"softfloat",
|
||||
},
|
||||
Goamd64: []string{
|
||||
"v2",
|
||||
"v3",
|
||||
},
|
||||
Ignore: []config.IgnoredBuild{
|
||||
{
|
||||
Goos: "linux",
|
||||
@@ -53,6 +57,9 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
}, {
|
||||
Goarch: "mips64le",
|
||||
Gomips: "softfloat",
|
||||
}, {
|
||||
Goarch: "amd64",
|
||||
Goamd64: "v3",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -62,7 +69,7 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{
|
||||
"linux_386",
|
||||
"linux_amd64",
|
||||
"linux_amd64_v2",
|
||||
"linux_arm_6",
|
||||
"linux_arm64",
|
||||
"linux_mips_hardfloat",
|
||||
@@ -72,18 +79,18 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
"linux_mipsle_softfloat",
|
||||
"linux_mips64le_hardfloat",
|
||||
"linux_riscv64",
|
||||
"darwin_amd64",
|
||||
"darwin_amd64_v2",
|
||||
"darwin_arm64",
|
||||
"freebsd_386",
|
||||
"freebsd_amd64",
|
||||
"freebsd_amd64_v2",
|
||||
"freebsd_arm_6",
|
||||
"freebsd_arm_7",
|
||||
"freebsd_arm64",
|
||||
"openbsd_386",
|
||||
"openbsd_amd64",
|
||||
"openbsd_amd64_v2",
|
||||
"openbsd_arm64",
|
||||
"windows_386",
|
||||
"windows_amd64",
|
||||
"windows_amd64_v2",
|
||||
"windows_arm_6",
|
||||
"windows_arm_7",
|
||||
"js_wasm",
|
||||
@@ -95,7 +102,7 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{
|
||||
"linux_386",
|
||||
"linux_amd64",
|
||||
"linux_amd64_v2",
|
||||
"linux_arm_6",
|
||||
"linux_arm64",
|
||||
"linux_mips_hardfloat",
|
||||
@@ -105,18 +112,18 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
"linux_mipsle_softfloat",
|
||||
"linux_mips64le_hardfloat",
|
||||
"linux_riscv64",
|
||||
"darwin_amd64",
|
||||
"darwin_amd64_v2",
|
||||
"darwin_arm64",
|
||||
"freebsd_386",
|
||||
"freebsd_amd64",
|
||||
"freebsd_amd64_v2",
|
||||
"freebsd_arm_6",
|
||||
"freebsd_arm_7",
|
||||
"freebsd_arm64",
|
||||
"openbsd_386",
|
||||
"openbsd_amd64",
|
||||
"openbsd_amd64_v2",
|
||||
"openbsd_arm64",
|
||||
"windows_386",
|
||||
"windows_amd64",
|
||||
"windows_amd64_v2",
|
||||
"windows_arm_6",
|
||||
"windows_arm_7",
|
||||
"windows_arm64",
|
||||
@@ -126,8 +133,9 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
|
||||
t.Run("invalid goos", func(t *testing.T) {
|
||||
_, err := matrix(config.Build{
|
||||
Goos: []string{"invalid"},
|
||||
Goarch: []string{"amd64"},
|
||||
Goos: []string{"invalid"},
|
||||
Goarch: []string{"amd64"},
|
||||
Goamd64: []string{"v2"},
|
||||
}, []byte("go version go1.18.0"))
|
||||
require.EqualError(t, err, "invalid goos: invalid")
|
||||
})
|
||||
@@ -157,6 +165,15 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
}, []byte("go version go1.18.0"))
|
||||
require.EqualError(t, err, "invalid gomips: invalid")
|
||||
})
|
||||
|
||||
t.Run("invalid goamd64", func(t *testing.T) {
|
||||
_, err := matrix(config.Build{
|
||||
Goos: []string{"linux"},
|
||||
Goarch: []string{"amd64"},
|
||||
Goamd64: []string{"invalid"},
|
||||
}, []byte("go version go1.18.0"))
|
||||
require.EqualError(t, err, "invalid goamd64: invalid")
|
||||
})
|
||||
}
|
||||
|
||||
func TestGoosGoarchCombos(t *testing.T) {
|
||||
@@ -212,7 +229,7 @@ func TestGoosGoarchCombos(t *testing.T) {
|
||||
}
|
||||
for _, p := range platforms {
|
||||
t.Run(fmt.Sprintf("%v %v valid=%v", p.os, p.arch, p.valid), func(t *testing.T) {
|
||||
require.Equal(t, p.valid, valid(target{p.os, p.arch, "", ""}))
|
||||
require.Equal(t, p.valid, valid(target{p.os, p.arch, "", "", ""}))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -222,27 +239,30 @@ func TestList(t *testing.T) {
|
||||
targets, err := List(config.Build{
|
||||
Goos: []string{"linux"},
|
||||
Goarch: []string{"amd64"},
|
||||
Goamd64: []string{"v2"},
|
||||
GoBinary: "go",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"linux_amd64"}, targets)
|
||||
require.Equal(t, []string{"linux_amd64_v2"}, targets)
|
||||
})
|
||||
|
||||
t.Run("success with dir", func(t *testing.T) {
|
||||
targets, err := List(config.Build{
|
||||
Goos: []string{"linux"},
|
||||
Goarch: []string{"amd64"},
|
||||
Goamd64: []string{"v2"},
|
||||
GoBinary: "go",
|
||||
Dir: "./testdata",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"linux_amd64"}, targets)
|
||||
require.Equal(t, []string{"linux_amd64_v2"}, targets)
|
||||
})
|
||||
|
||||
t.Run("error with dir", func(t *testing.T) {
|
||||
_, err := List(config.Build{
|
||||
Goos: []string{"linux"},
|
||||
Goarch: []string{"amd64"},
|
||||
Goamd64: []string{"v2"},
|
||||
GoBinary: "go",
|
||||
Dir: "targets.go",
|
||||
})
|
||||
@@ -253,6 +273,7 @@ func TestList(t *testing.T) {
|
||||
_, err := List(config.Build{
|
||||
Goos: []string{"linux"},
|
||||
Goarch: []string{"amd64"},
|
||||
Goamd64: []string{"v2"},
|
||||
GoBinary: "nope",
|
||||
})
|
||||
require.EqualError(t, err, `unable to determine version of go binary (nope): exec: "nope": executable file not found in $PATH`)
|
||||
|
||||
@@ -61,6 +61,9 @@ func (*Builder) WithDefaults(build config.Build) (config.Build, error) {
|
||||
if len(build.Gomips) == 0 {
|
||||
build.Gomips = []string{"hardfloat"}
|
||||
}
|
||||
if len(build.Goamd64) == 0 {
|
||||
build.Goamd64 = []string{"v2"}
|
||||
}
|
||||
targets, err := buildtarget.List(build)
|
||||
build.Targets = targets
|
||||
if err != nil {
|
||||
@@ -77,13 +80,14 @@ func (*Builder) Build(ctx *context.Context, build config.Build, options api.Opti
|
||||
}
|
||||
|
||||
artifact := &artifact.Artifact{
|
||||
Type: artifact.Binary,
|
||||
Path: options.Path,
|
||||
Name: options.Name,
|
||||
Goos: options.Goos,
|
||||
Goarch: options.Goarch,
|
||||
Goarm: options.Goarm,
|
||||
Gomips: options.Gomips,
|
||||
Type: artifact.Binary,
|
||||
Path: options.Path,
|
||||
Name: options.Name,
|
||||
Goos: options.Goos,
|
||||
Goarch: options.Goarch,
|
||||
Goamd64: options.Goamd64,
|
||||
Goarm: options.Goarm,
|
||||
Gomips: options.Gomips,
|
||||
Extra: map[string]interface{}{
|
||||
artifact.ExtraBinary: strings.TrimSuffix(filepath.Base(options.Path), options.Ext),
|
||||
artifact.ExtraExt: options.Ext,
|
||||
@@ -99,6 +103,7 @@ func (*Builder) Build(ctx *context.Context, build config.Build, options api.Opti
|
||||
"GOARM="+options.Goarm,
|
||||
"GOMIPS="+options.Gomips,
|
||||
"GOMIPS64="+options.Gomips,
|
||||
"GOAMD64="+options.Goamd64,
|
||||
)
|
||||
|
||||
cmd, err := buildGoBuildLine(ctx, build, options, artifact, env)
|
||||
@@ -131,9 +136,9 @@ func (*Builder) Build(ctx *context.Context, build config.Build, options api.Opti
|
||||
}
|
||||
|
||||
func withOverrides(ctx *context.Context, build config.Build, options api.Options) (config.BuildDetails, error) {
|
||||
optsTarget := options.Goos + options.Goarch + options.Goarm + options.Gomips
|
||||
optsTarget := options.Goos + options.Goarch + options.Goarm + options.Gomips + options.Goamd64
|
||||
for _, o := range build.BuildDetailsOverrides {
|
||||
overrideTarget, err := tmpl.New(ctx).Apply(o.Goos + o.Goarch + o.Gomips + o.Goarm)
|
||||
overrideTarget, err := tmpl.New(ctx).Apply(o.Goos + o.Goarch + o.Gomips + o.Goarm + o.Goamd64)
|
||||
if err != nil {
|
||||
return build.BuildDetails, err
|
||||
}
|
||||
|
||||
@@ -47,13 +47,20 @@ func TestWithDefaults(t *testing.T) {
|
||||
Gomips: []string{
|
||||
"softfloat",
|
||||
},
|
||||
Goamd64: []string{
|
||||
"v2",
|
||||
"v3",
|
||||
},
|
||||
GoBinary: "go1.2.3",
|
||||
},
|
||||
targets: []string{
|
||||
"linux_amd64",
|
||||
"linux_amd64_v2",
|
||||
"linux_amd64_v3",
|
||||
"linux_mips_softfloat",
|
||||
"darwin_amd64",
|
||||
"windows_amd64",
|
||||
"darwin_amd64_v2",
|
||||
"darwin_amd64_v3",
|
||||
"windows_amd64_v3",
|
||||
"windows_amd64_v2",
|
||||
"windows_arm_6",
|
||||
"linux_arm_6",
|
||||
},
|
||||
@@ -65,10 +72,10 @@ func TestWithDefaults(t *testing.T) {
|
||||
Binary: "foo",
|
||||
},
|
||||
targets: []string{
|
||||
"linux_amd64",
|
||||
"linux_amd64_v2",
|
||||
"linux_386",
|
||||
"linux_arm64",
|
||||
"darwin_amd64",
|
||||
"darwin_amd64_v2",
|
||||
"darwin_arm64",
|
||||
},
|
||||
goBinary: "go",
|
||||
@@ -79,12 +86,12 @@ func TestWithDefaults(t *testing.T) {
|
||||
Binary: "foo",
|
||||
Targets: []string{
|
||||
"linux_386",
|
||||
"darwin_amd64",
|
||||
"darwin_amd64_v2",
|
||||
},
|
||||
},
|
||||
targets: []string{
|
||||
"linux_386",
|
||||
"darwin_amd64",
|
||||
"darwin_amd64_v2",
|
||||
},
|
||||
goBinary: "go",
|
||||
},
|
||||
@@ -95,10 +102,10 @@ func TestWithDefaults(t *testing.T) {
|
||||
Dir: "./testdata",
|
||||
},
|
||||
targets: []string{
|
||||
"linux_amd64",
|
||||
"linux_amd64_v2",
|
||||
"linux_386",
|
||||
"linux_arm64",
|
||||
"darwin_amd64",
|
||||
"darwin_amd64_v2",
|
||||
"darwin_arm64",
|
||||
},
|
||||
goBinary: "go",
|
||||
@@ -110,10 +117,10 @@ func TestWithDefaults(t *testing.T) {
|
||||
Dir: "./nope",
|
||||
},
|
||||
targets: []string{
|
||||
"linux_amd64",
|
||||
"linux_amd64_v2",
|
||||
"linux_386",
|
||||
"linux_arm64",
|
||||
"darwin_amd64",
|
||||
"darwin_amd64_v2",
|
||||
"darwin_arm64",
|
||||
},
|
||||
goBinary: "go",
|
||||
|
||||
Reference in New Issue
Block a user