1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-14 03:51:24 +02:00

fix: goreleaser build --single-target on arm64

refs https://github.com/goreleaser/goreleaser/issues/5238#issuecomment-2454334189
This commit is contained in:
Carlos Alexandro Becker 2024-11-04 08:51:43 -03:00
parent 431b18f6ee
commit cb8997e76b
No known key found for this signature in database
2 changed files with 86 additions and 3 deletions

View File

@ -33,6 +33,22 @@ func getFilter() string {
goarm := ordered.First(os.Getenv("GGOARM"), os.Getenv("GOARM"), experimental.DefaultGOARM())
target = target + "_" + goarm
}
if strings.HasSuffix(target, "_arm64") {
goarm := ordered.First(os.Getenv("GGOARM64"), os.Getenv("GOARM64"), "v8.0")
target = target + "_" + goarm
}
if strings.HasSuffix(target, "_386") {
goarm := ordered.First(os.Getenv("GGO386"), os.Getenv("GO386"), "sse2")
target = target + "_" + goarm
}
if strings.HasSuffix(target, "_ppc64") {
goarm := ordered.First(os.Getenv("GGOPPC64"), os.Getenv("GOPPC64"), "power8")
target = target + "_" + goarm
}
if strings.HasSuffix(target, "_riscv64") {
goarm := ordered.First(os.Getenv("GGORISCV64"), os.Getenv("GORISCV64"), "rva20u64")
target = target + "_" + goarm
}
if strings.HasSuffix(target, "_mips") ||
strings.HasSuffix(target, "_mips64") ||
strings.HasSuffix(target, "_mipsle") ||

View File

@ -35,7 +35,7 @@ func TestRun(t *testing.T) {
t.Setenv("GOOS", "windows")
t.Setenv("GOARCH", "arm64")
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "windows_arm64", ctx.PartialTarget)
require.Equal(t, "windows_arm64_v8.0", ctx.PartialTarget)
})
t.Run("using GGOOS and GGOARCH", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
@ -44,7 +44,7 @@ func TestRun(t *testing.T) {
t.Setenv("GGOOS", "windows")
t.Setenv("GGOARCH", "arm64")
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "windows_arm64", ctx.PartialTarget)
require.Equal(t, "windows_arm64_v8.0", ctx.PartialTarget)
})
t.Run("custom GGOARM", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
@ -62,6 +62,22 @@ func TestRun(t *testing.T) {
require.Equal(t, "linux_arm_7", ctx.PartialTarget)
})
})
t.Run("custom GGOARM64", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Dist: "dist",
}, testctx.Partial)
t.Setenv("GGOOS", "linux")
t.Setenv("GGOARCH", "arm64")
t.Run("default", func(t *testing.T) {
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "linux_arm64_v8.0", ctx.PartialTarget)
})
t.Run("default", func(t *testing.T) {
t.Setenv("GGOARM64", "v9.0")
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "linux_arm64_v9.0", ctx.PartialTarget)
})
})
t.Run("custom GGOAMD64", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Dist: "dist",
@ -98,6 +114,54 @@ func TestRun(t *testing.T) {
})
}
})
t.Run("custom GGO386", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Dist: "dist",
}, testctx.Partial)
t.Setenv("GGOOS", "linux")
t.Setenv("GGOARCH", "386")
t.Run("default", func(t *testing.T) {
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "linux_386_sse2", ctx.PartialTarget)
})
t.Run("default", func(t *testing.T) {
t.Setenv("GGO386", "softfloat")
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "linux_386_softfloat", ctx.PartialTarget)
})
})
t.Run("custom GGOPPC64", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Dist: "dist",
}, testctx.Partial)
t.Setenv("GGOOS", "linux")
t.Setenv("GGOARCH", "ppc64")
t.Run("default", func(t *testing.T) {
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "linux_ppc64_power8", ctx.PartialTarget)
})
t.Run("default", func(t *testing.T) {
t.Setenv("GGOPPC64", "power9")
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "linux_ppc64_power9", ctx.PartialTarget)
})
})
t.Run("custom GGORISCV64", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Dist: "dist",
}, testctx.Partial)
t.Setenv("GGOOS", "linux")
t.Setenv("GGOARCH", "riscv64")
t.Run("default", func(t *testing.T) {
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "linux_riscv64_rva20u64", ctx.PartialTarget)
})
t.Run("default", func(t *testing.T) {
t.Setenv("GGORISCV64", "rva22u64")
require.NoError(t, pipe.Run(ctx))
require.Equal(t, "linux_riscv64_rva22u64", ctx.PartialTarget)
})
})
t.Run("using runtime", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Dist: "dist",
@ -105,8 +169,11 @@ func TestRun(t *testing.T) {
require.NoError(t, pipe.Run(ctx))
target := fmt.Sprintf("%s_%s", runtime.GOOS, runtime.GOARCH)
// commonly tests will run on either arm64 or amd64.
if runtime.GOARCH == "amd64" {
switch runtime.GOARCH {
case "amd64":
target += "_v1"
case "arm64":
target += "_v8.0"
}
require.Equal(t, target, ctx.PartialTarget)
})