mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
feat(build): add GO386, GOMIPS64, GORISCV64, and GOPPC64 support (#5186)
continuing the work of #5153 closes #5153 --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: 世界 <i@sekai.icu>
This commit is contained in:
parent
883c155a68
commit
d583861e06
@ -181,16 +181,20 @@ func (e Extras) MarshalJSON() ([]byte, error) {
|
||||
|
||||
// Artifact represents an artifact and its relevant info.
|
||||
type Artifact struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Goos string `json:"goos,omitempty"`
|
||||
Goarch string `json:"goarch,omitempty"`
|
||||
Goarm string `json:"goarm,omitempty"`
|
||||
Gomips string `json:"gomips,omitempty"`
|
||||
Goamd64 string `json:"goamd64,omitempty"`
|
||||
Type Type `json:"internal_type,omitempty"`
|
||||
TypeS string `json:"type,omitempty"`
|
||||
Extra Extras `json:"extra,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Goos string `json:"goos,omitempty"`
|
||||
Goarch string `json:"goarch,omitempty"`
|
||||
Goamd64 string `json:"goamd64,omitempty"`
|
||||
Go386 string `json:"go386,omitempty"`
|
||||
Goarm string `json:"goarm,omitempty"`
|
||||
Goarm64 string `json:"goarm64,omitempty"`
|
||||
Gomips string `json:"gomips,omitempty"`
|
||||
Goppc64 string `json:"goppc64,omitempty"`
|
||||
Goriscv64 string `json:"goriscv64,omitempty"`
|
||||
Type Type `json:"internal_type,omitempty"`
|
||||
TypeS string `json:"type,omitempty"`
|
||||
Extra Extras `json:"extra,omitempty"`
|
||||
}
|
||||
|
||||
func (a Artifact) String() string {
|
||||
|
@ -4,6 +4,7 @@ package buildtarget
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/caarlos0/log"
|
||||
@ -11,11 +12,11 @@ import (
|
||||
)
|
||||
|
||||
type target struct {
|
||||
os, arch, arm, mips, amd64 string
|
||||
os, arch, amd64, go386, arm, arm64, mips, ppc64, riscv64 string
|
||||
}
|
||||
|
||||
func (t target) String() string {
|
||||
if extra := t.arm + t.mips + t.amd64; extra != "" {
|
||||
if extra := t.amd64 + t.go386 + t.arm + t.arm64 + t.mips + t.ppc64 + t.riscv64; extra != "" {
|
||||
return fmt.Sprintf("%s_%s_%s", t.os, t.arch, extra)
|
||||
}
|
||||
return fmt.Sprintf("%s_%s", t.os, t.arch)
|
||||
@ -34,14 +35,26 @@ func List(build config.Build) ([]string, error) {
|
||||
if !contains(target.arch, validGoarch) {
|
||||
return result, fmt.Errorf("invalid goarch: %s", target.arch)
|
||||
}
|
||||
if target.amd64 != "" && !contains(target.amd64, validGoamd64) {
|
||||
return result, fmt.Errorf("invalid goamd64: %s", target.amd64)
|
||||
}
|
||||
if target.go386 != "" && !contains(target.go386, validGo386) {
|
||||
return result, fmt.Errorf("invalid go386: %s", target.go386)
|
||||
}
|
||||
if target.arm != "" && !contains(target.arm, validGoarm) {
|
||||
return result, fmt.Errorf("invalid goarm: %s", target.arm)
|
||||
}
|
||||
if target.arm64 != "" && !validGoarm64.MatchString(target.arm64) {
|
||||
return result, fmt.Errorf("invalid goarm64: %s", target.arm64)
|
||||
}
|
||||
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.ppc64 != "" && !contains(target.ppc64, validGoppc64) {
|
||||
return result, fmt.Errorf("invalid goppc64: %s", target.ppc64)
|
||||
}
|
||||
if target.riscv64 != "" && !contains(target.riscv64, validGoriscv64) {
|
||||
return result, fmt.Errorf("invalid goriscv64: %s", target.riscv64)
|
||||
}
|
||||
if !valid(target) {
|
||||
log.WithField("target", target).Debug("skipped invalid build")
|
||||
@ -62,7 +75,32 @@ func List(build config.Build) ([]string, error) {
|
||||
func allBuildTargets(build config.Build) (targets []target) {
|
||||
for _, goos := range build.Goos {
|
||||
for _, goarch := range build.Goarch {
|
||||
if goarch == "arm" {
|
||||
//nolint:gocritic
|
||||
if strings.HasPrefix(goarch, "amd64") {
|
||||
for _, goamd64 := range build.Goamd64 {
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
arch: goarch,
|
||||
amd64: goamd64,
|
||||
})
|
||||
}
|
||||
} else if goarch == "386" {
|
||||
for _, go386 := range build.Go386 {
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
arch: goarch,
|
||||
go386: go386,
|
||||
})
|
||||
}
|
||||
} else if strings.HasPrefix(goarch, "arm64") {
|
||||
for _, goarm64 := range build.Goarm64 {
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
arch: goarch,
|
||||
arm64: goarm64,
|
||||
})
|
||||
}
|
||||
} else if strings.HasPrefix(goarch, "arm") {
|
||||
for _, goarm := range build.Goarm {
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
@ -70,19 +108,7 @@ func allBuildTargets(build config.Build) (targets []target) {
|
||||
arm: goarm,
|
||||
})
|
||||
}
|
||||
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") {
|
||||
} else if strings.HasPrefix(goarch, "mips") {
|
||||
for _, gomips := range build.Gomips {
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
@ -90,12 +116,28 @@ func allBuildTargets(build config.Build) (targets []target) {
|
||||
mips: gomips,
|
||||
})
|
||||
}
|
||||
continue
|
||||
} else if strings.HasPrefix(goarch, "ppc64") {
|
||||
for _, goppc64 := range build.Goppc64 {
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
arch: goarch,
|
||||
ppc64: goppc64,
|
||||
})
|
||||
}
|
||||
} else if strings.HasPrefix(goarch, "riscv64") {
|
||||
for _, goriscv64 := range build.Goriscv64 {
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
arch: goarch,
|
||||
riscv64: goriscv64,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
arch: goarch,
|
||||
})
|
||||
}
|
||||
targets = append(targets, target{
|
||||
os: goos,
|
||||
arch: goarch,
|
||||
})
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -111,13 +153,25 @@ func ignored(build config.Build, target target) bool {
|
||||
if ig.Goarch != "" && ig.Goarch != target.arch {
|
||||
continue
|
||||
}
|
||||
if ig.Goamd64 != "" && ig.Goamd64 != target.amd64 {
|
||||
continue
|
||||
}
|
||||
if ig.Go386 != "" && ig.Go386 != target.go386 {
|
||||
continue
|
||||
}
|
||||
if ig.Goarm != "" && ig.Goarm != target.arm {
|
||||
continue
|
||||
}
|
||||
if ig.Goarm64 != "" && ig.Goarm64 != target.arm64 {
|
||||
continue
|
||||
}
|
||||
if ig.Gomips != "" && ig.Gomips != target.mips {
|
||||
continue
|
||||
}
|
||||
if ig.Goamd64 != "" && ig.Goamd64 != target.amd64 {
|
||||
if ig.Goppc64 != "" && ig.Goppc64 != target.ppc64 {
|
||||
continue
|
||||
}
|
||||
if ig.Goriscv64 != "" && ig.Goriscv64 != target.riscv64 {
|
||||
continue
|
||||
}
|
||||
return true
|
||||
@ -225,7 +279,11 @@ var (
|
||||
"loong64",
|
||||
}
|
||||
|
||||
validGoarm = []string{"5", "6", "7"}
|
||||
validGomips = []string{"hardfloat", "softfloat"}
|
||||
validGoamd64 = []string{"v1", "v2", "v3", "v4"}
|
||||
validGoamd64 = []string{"v1", "v2", "v3", "v4"}
|
||||
validGo386 = []string{"sse2", "softfloat"}
|
||||
validGoarm = []string{"5", "6", "7"}
|
||||
validGoarm64 = regexp.MustCompile(`(v8\.[0-9]|v9\.[0-5])((,lse|,crypto)?)+`)
|
||||
validGomips = []string{"hardfloat", "softfloat"}
|
||||
validGoppc64 = []string{"power8", "power9", "power10"}
|
||||
validGoriscv64 = []string{"rva20u64", "rva22u64"}
|
||||
)
|
||||
|
@ -34,20 +34,38 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
"riscv64",
|
||||
"loong64",
|
||||
},
|
||||
Goarm: []string{
|
||||
"6",
|
||||
"7",
|
||||
},
|
||||
Gomips: []string{
|
||||
"hardfloat",
|
||||
"softfloat",
|
||||
},
|
||||
Goamd64: []string{
|
||||
"v1",
|
||||
"v2",
|
||||
"v3",
|
||||
"v4",
|
||||
},
|
||||
Go386: []string{
|
||||
"sse2",
|
||||
"softfloat",
|
||||
},
|
||||
Goarm: []string{
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
},
|
||||
Goarm64: []string{
|
||||
"v8.0",
|
||||
"v9.0",
|
||||
},
|
||||
Gomips: []string{
|
||||
"hardfloat",
|
||||
"softfloat",
|
||||
},
|
||||
Goppc64: []string{
|
||||
"power8",
|
||||
"power9",
|
||||
"power10",
|
||||
},
|
||||
Goriscv64: []string{
|
||||
"rva20u64",
|
||||
"rva22u64",
|
||||
},
|
||||
Ignore: []config.IgnoredBuild{
|
||||
{
|
||||
Goos: "linux",
|
||||
@ -56,15 +74,36 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
}, {
|
||||
Goos: "openbsd",
|
||||
Goarch: "arm",
|
||||
}, {
|
||||
Goarch: "amd64",
|
||||
Goamd64: "v1",
|
||||
}, {
|
||||
Goarch: "386",
|
||||
Go386: "sse2",
|
||||
}, {
|
||||
Goarch: "arm64",
|
||||
Goarm64: "v8.0",
|
||||
}, {
|
||||
Goarch: "mips",
|
||||
Gomips: "hardfloat",
|
||||
}, {
|
||||
Goarch: "mipsle",
|
||||
Gomips: "hardfloat",
|
||||
}, {
|
||||
Goarch: "mips64",
|
||||
Gomips: "hardfloat",
|
||||
}, {
|
||||
Goarch: "mips64le",
|
||||
Gomips: "softfloat",
|
||||
Gomips: "hardfloat",
|
||||
}, {
|
||||
Goarch: "amd64",
|
||||
Goamd64: "v3",
|
||||
Goarch: "ppc64",
|
||||
Goppc64: "power8",
|
||||
}, {
|
||||
Goarch: "ppc64le",
|
||||
Goppc64: "power8",
|
||||
}, {
|
||||
Goarch: "riscv64",
|
||||
Goriscv64: "rva20u64",
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -73,45 +112,46 @@ func TestAllBuildTargets(t *testing.T) {
|
||||
result, err := List(build)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{
|
||||
"linux_386",
|
||||
"linux_amd64_v1",
|
||||
"linux_386_softfloat",
|
||||
"linux_amd64_v2",
|
||||
"linux_amd64_v3",
|
||||
"linux_amd64_v4",
|
||||
"linux_arm_5",
|
||||
"linux_arm_6",
|
||||
"linux_arm64",
|
||||
"linux_mips_hardfloat",
|
||||
"linux_arm64_v9.0",
|
||||
"linux_mips_softfloat",
|
||||
"linux_mips64_softfloat",
|
||||
"linux_mipsle_hardfloat",
|
||||
"linux_mipsle_softfloat",
|
||||
"linux_mips64le_hardfloat",
|
||||
"linux_riscv64",
|
||||
"linux_mips64le_softfloat",
|
||||
"linux_riscv64_rva22u64",
|
||||
"linux_loong64",
|
||||
"darwin_amd64_v1",
|
||||
"darwin_amd64_v2",
|
||||
"darwin_amd64_v3",
|
||||
"darwin_amd64_v4",
|
||||
"darwin_arm64",
|
||||
"freebsd_386",
|
||||
"freebsd_amd64_v1",
|
||||
"darwin_arm64_v9.0",
|
||||
"freebsd_386_softfloat",
|
||||
"freebsd_amd64_v2",
|
||||
"freebsd_amd64_v3",
|
||||
"freebsd_amd64_v4",
|
||||
"freebsd_arm_5",
|
||||
"freebsd_arm_6",
|
||||
"freebsd_arm_7",
|
||||
"freebsd_arm64",
|
||||
"openbsd_386",
|
||||
"openbsd_amd64_v1",
|
||||
"freebsd_arm64_v9.0",
|
||||
"openbsd_386_softfloat",
|
||||
"openbsd_amd64_v2",
|
||||
"openbsd_amd64_v3",
|
||||
"openbsd_amd64_v4",
|
||||
"openbsd_arm64",
|
||||
"windows_386",
|
||||
"windows_amd64_v1",
|
||||
"openbsd_arm64_v9.0",
|
||||
"windows_386_softfloat",
|
||||
"windows_amd64_v2",
|
||||
"windows_amd64_v3",
|
||||
"windows_amd64_v4",
|
||||
"windows_arm_5",
|
||||
"windows_arm_6",
|
||||
"windows_arm_7",
|
||||
"windows_arm64",
|
||||
"windows_arm64_v9.0",
|
||||
"js_wasm",
|
||||
"ios_arm64",
|
||||
"ios_arm64_v9.0",
|
||||
"wasip1_wasm",
|
||||
}, result)
|
||||
})
|
||||
@ -219,7 +259,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{os: p.os, arch: p.arch}))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -63,15 +63,28 @@ func (*Builder) WithDefaults(build config.Build) (config.Build, error) {
|
||||
if len(build.Goarch) == 0 {
|
||||
build.Goarch = []string{"amd64", "arm64", "386"}
|
||||
}
|
||||
if len(build.Goamd64) == 0 {
|
||||
build.Goamd64 = []string{"v1"}
|
||||
}
|
||||
if len(build.Go386) == 0 {
|
||||
build.Go386 = []string{"sse2"}
|
||||
}
|
||||
if len(build.Goarm) == 0 {
|
||||
build.Goarm = []string{experimental.DefaultGOARM()}
|
||||
}
|
||||
if len(build.Goarm64) == 0 {
|
||||
build.Goarm64 = []string{"v8.0"}
|
||||
}
|
||||
if len(build.Gomips) == 0 {
|
||||
build.Gomips = []string{"hardfloat"}
|
||||
}
|
||||
if len(build.Goamd64) == 0 {
|
||||
build.Goamd64 = []string{"v1"}
|
||||
if len(build.Goppc64) == 0 {
|
||||
build.Goppc64 = []string{"power8"}
|
||||
}
|
||||
if len(build.Goriscv64) == 0 {
|
||||
build.Goriscv64 = []string{"rva20u64"}
|
||||
}
|
||||
|
||||
targets, err := buildtarget.List(build)
|
||||
if err != nil {
|
||||
return build, err
|
||||
@ -91,8 +104,16 @@ func (*Builder) WithDefaults(build config.Build) (config.Build, error) {
|
||||
targets[target+"_v1"] = true
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_386") {
|
||||
targets[target+"_sse2"] = true
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_arm") {
|
||||
targets[target+"_6"] = true
|
||||
targets[target+"_7"] = true
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_arm64") {
|
||||
targets[target+"_v8.0"] = true
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(target, "_mips") ||
|
||||
@ -102,6 +123,13 @@ func (*Builder) WithDefaults(build config.Build) (config.Build, error) {
|
||||
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
|
||||
}
|
||||
build.Targets = keys(targets)
|
||||
@ -116,12 +144,16 @@ func warnIfTargetsAndOtherOptionTogether(build config.Build) bool {
|
||||
|
||||
res := false
|
||||
for k, v := range map[string]int{
|
||||
"goos": len(build.Goos),
|
||||
"goarch": len(build.Goarch),
|
||||
"goarm": len(build.Goarm),
|
||||
"gomips": len(build.Gomips),
|
||||
"goamd64": len(build.Goamd64),
|
||||
"ignore": len(build.Ignore),
|
||||
"goos": len(build.Goos),
|
||||
"goarch": len(build.Goarch),
|
||||
"go386": len(build.Go386),
|
||||
"goamd64": len(build.Goamd64),
|
||||
"goarm": len(build.Goarm),
|
||||
"goarm64": len(build.Goarm64),
|
||||
"gomips": len(build.Gomips),
|
||||
"goppc64": len(build.Goppc64),
|
||||
"goriscv64": len(build.Goriscv64),
|
||||
"ignore": len(build.Ignore),
|
||||
} {
|
||||
if v == 0 {
|
||||
continue
|
||||
@ -164,14 +196,18 @@ func (*Builder) Build(ctx *context.Context, build config.Build, options api.Opti
|
||||
}
|
||||
|
||||
a := &artifact.Artifact{
|
||||
Type: artifact.Binary,
|
||||
Path: options.Path,
|
||||
Name: options.Name,
|
||||
Goos: options.Goos,
|
||||
Goarch: options.Goarch,
|
||||
Goamd64: options.Goamd64,
|
||||
Goarm: options.Goarm,
|
||||
Gomips: options.Gomips,
|
||||
Type: artifact.Binary,
|
||||
Path: options.Path,
|
||||
Name: options.Name,
|
||||
Goos: options.Goos,
|
||||
Goarch: options.Goarch,
|
||||
Goamd64: options.Goamd64,
|
||||
Go386: options.Go386,
|
||||
Goarm: options.Goarm,
|
||||
Goarm64: options.Goarm64,
|
||||
Gomips: options.Gomips,
|
||||
Goppc64: options.Goppc64,
|
||||
Goriscv64: options.Goriscv64,
|
||||
Extra: map[string]interface{}{
|
||||
artifact.ExtraBinary: strings.TrimSuffix(filepath.Base(options.Path), options.Ext),
|
||||
artifact.ExtraExt: options.Ext,
|
||||
@ -214,10 +250,14 @@ func (*Builder) Build(ctx *context.Context, build config.Build, options api.Opti
|
||||
env,
|
||||
"GOOS="+options.Goos,
|
||||
"GOARCH="+options.Goarch,
|
||||
"GOAMD64="+options.Goamd64,
|
||||
"GO386="+options.Go386,
|
||||
"GOARM="+options.Goarm,
|
||||
"GOARM64="+options.Goarm64,
|
||||
"GOMIPS="+options.Gomips,
|
||||
"GOMIPS64="+options.Gomips,
|
||||
"GOAMD64="+options.Goamd64,
|
||||
"GOPPC64="+options.Goppc64,
|
||||
"GORISCV64"+options.Goriscv64,
|
||||
)
|
||||
|
||||
if v := os.Getenv("GOCACHEPROG"); v != "" {
|
||||
@ -250,7 +290,7 @@ 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 + options.Goamd64
|
||||
optsTarget := options.Goos + options.Goarch + options.Goamd64 + options.Go386 + options.Goarm + options.Gomips
|
||||
for _, o := range build.BuildDetailsOverrides {
|
||||
overrideTarget, err := tmpl.New(ctx).Apply(o.Goos + o.Goarch + o.Gomips + o.Goarm + o.Goamd64)
|
||||
if err != nil {
|
||||
@ -482,14 +522,18 @@ func getHeaderArtifactForLibrary(build config.Build, options api.Options) *artif
|
||||
headerName := basePath + ".h"
|
||||
|
||||
return &artifact.Artifact{
|
||||
Type: artifact.Header,
|
||||
Path: fullPath,
|
||||
Name: headerName,
|
||||
Goos: options.Goos,
|
||||
Goarch: options.Goarch,
|
||||
Goamd64: options.Goamd64,
|
||||
Goarm: options.Goarm,
|
||||
Gomips: options.Gomips,
|
||||
Type: artifact.Header,
|
||||
Path: fullPath,
|
||||
Name: headerName,
|
||||
Goos: options.Goos,
|
||||
Goarch: options.Goarch,
|
||||
Goamd64: options.Goamd64,
|
||||
Go386: options.Go386,
|
||||
Goarm: options.Goarm,
|
||||
Goarm64: options.Goarm64,
|
||||
Gomips: options.Gomips,
|
||||
Goppc64: options.Goppc64,
|
||||
Goriscv64: options.Goriscv64,
|
||||
Extra: map[string]interface{}{
|
||||
artifact.ExtraBinary: headerName,
|
||||
artifact.ExtraExt: ".h",
|
||||
|
@ -74,13 +74,13 @@ func TestWithDefaults(t *testing.T) {
|
||||
},
|
||||
targets: []string{
|
||||
"linux_amd64_v1",
|
||||
"linux_386",
|
||||
"linux_arm64",
|
||||
"linux_386_sse2",
|
||||
"linux_arm64_v8.0",
|
||||
"darwin_amd64_v1",
|
||||
"darwin_arm64",
|
||||
"darwin_arm64_v8.0",
|
||||
"windows_amd64_v1",
|
||||
"windows_arm64",
|
||||
"windows_386",
|
||||
"windows_arm64_v8.0",
|
||||
"windows_386_sse2",
|
||||
},
|
||||
goBinary: "go",
|
||||
},
|
||||
@ -89,12 +89,12 @@ func TestWithDefaults(t *testing.T) {
|
||||
ID: "foo3",
|
||||
Binary: "foo",
|
||||
Targets: []string{
|
||||
"linux_386",
|
||||
"linux_386_sse2",
|
||||
"darwin_amd64_v2",
|
||||
},
|
||||
},
|
||||
targets: []string{
|
||||
"linux_386",
|
||||
"linux_386_sse2",
|
||||
"darwin_amd64_v2",
|
||||
},
|
||||
goBinary: "go",
|
||||
@ -104,12 +104,12 @@ func TestWithDefaults(t *testing.T) {
|
||||
ID: "foo3",
|
||||
Binary: "foo",
|
||||
Targets: []string{
|
||||
"linux_386",
|
||||
"linux_386_sse2",
|
||||
"darwin_amd64",
|
||||
},
|
||||
},
|
||||
targets: []string{
|
||||
"linux_386",
|
||||
"linux_386_sse2",
|
||||
"darwin_amd64_v1",
|
||||
},
|
||||
goBinary: "go",
|
||||
@ -120,7 +120,7 @@ func TestWithDefaults(t *testing.T) {
|
||||
Binary: "foo",
|
||||
Targets: []string{"linux_arm"},
|
||||
},
|
||||
targets: []string{"linux_arm_6"},
|
||||
targets: []string{"linux_arm_7"},
|
||||
goBinary: "go",
|
||||
},
|
||||
"custom targets no mips": {
|
||||
@ -167,13 +167,13 @@ func TestWithDefaults(t *testing.T) {
|
||||
},
|
||||
targets: []string{
|
||||
"linux_amd64_v1",
|
||||
"linux_386",
|
||||
"linux_arm64",
|
||||
"linux_386_sse2",
|
||||
"linux_arm64_v8.0",
|
||||
"darwin_amd64_v1",
|
||||
"darwin_arm64",
|
||||
"darwin_arm64_v8.0",
|
||||
"windows_amd64_v1",
|
||||
"windows_arm64",
|
||||
"windows_386",
|
||||
"windows_arm64_v8.0",
|
||||
"windows_386_sse2",
|
||||
},
|
||||
goBinary: "go",
|
||||
},
|
||||
@ -185,13 +185,13 @@ func TestWithDefaults(t *testing.T) {
|
||||
},
|
||||
targets: []string{
|
||||
"linux_amd64_v1",
|
||||
"linux_386",
|
||||
"linux_arm64",
|
||||
"linux_386_sse2",
|
||||
"linux_arm64_v8.0",
|
||||
"darwin_amd64_v1",
|
||||
"darwin_arm64",
|
||||
"darwin_arm64_v8.0",
|
||||
"windows_amd64_v1",
|
||||
"windows_arm64",
|
||||
"windows_386",
|
||||
"windows_arm64_v8.0",
|
||||
"windows_386_sse2",
|
||||
},
|
||||
goBinary: "go",
|
||||
},
|
||||
@ -1397,17 +1397,21 @@ func TestWarnIfTargetsAndOtherOptionsTogether(t *testing.T) {
|
||||
nonEmpty := []string{"foo", "bar"}
|
||||
for name, fn := range map[string]func(*config.Build){
|
||||
"goos": func(b *config.Build) { b.Goos = nonEmpty },
|
||||
"goamd64": func(b *config.Build) { b.Goamd64 = nonEmpty },
|
||||
"goarch": func(b *config.Build) { b.Goarch = nonEmpty },
|
||||
"goarm": func(b *config.Build) { b.Goarm = nonEmpty },
|
||||
"gomips": func(b *config.Build) { b.Gomips = nonEmpty },
|
||||
"goamd64": func(b *config.Build) { b.Goamd64 = nonEmpty },
|
||||
"ignores": func(b *config.Build) { b.Ignore = []config.IgnoredBuild{{Goos: "linux"}} },
|
||||
"multiple": func(b *config.Build) {
|
||||
b.Goos = nonEmpty
|
||||
b.Goarch = nonEmpty
|
||||
b.Goarm = nonEmpty
|
||||
b.Gomips = nonEmpty
|
||||
b.Goamd64 = nonEmpty
|
||||
b.Go386 = nonEmpty
|
||||
b.Goarm = nonEmpty
|
||||
b.Goarm64 = nonEmpty
|
||||
b.Gomips = nonEmpty
|
||||
b.Goppc64 = nonEmpty
|
||||
b.Goriscv64 = nonEmpty
|
||||
b.Ignore = []config.IgnoredBuild{{Goos: "linux"}}
|
||||
},
|
||||
} {
|
||||
|
@ -227,9 +227,13 @@ func create(ctx *context.Context, arch config.Archive, binaries []*artifact.Arti
|
||||
if len(binaries) > 0 {
|
||||
art.Goos = binaries[0].Goos
|
||||
art.Goarch = binaries[0].Goarch
|
||||
art.Goarm = binaries[0].Goarm
|
||||
art.Gomips = binaries[0].Gomips
|
||||
art.Goamd64 = binaries[0].Goamd64
|
||||
art.Go386 = binaries[0].Go386
|
||||
art.Goarm = binaries[0].Goarm
|
||||
art.Goarm64 = binaries[0].Goarm64
|
||||
art.Gomips = binaries[0].Gomips
|
||||
art.Goppc64 = binaries[0].Goppc64
|
||||
art.Goriscv64 = binaries[0].Goriscv64
|
||||
art.Extra[artifact.ExtraReplaces] = binaries[0].Extra[artifact.ExtraReplaces]
|
||||
}
|
||||
|
||||
@ -259,14 +263,18 @@ func skip(ctx *context.Context, archive config.Archive, binaries []*artifact.Art
|
||||
WithField("name", finalName).
|
||||
Info("skip archiving")
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Type: artifact.UploadableBinary,
|
||||
Name: finalName,
|
||||
Path: binary.Path,
|
||||
Goos: binary.Goos,
|
||||
Goarch: binary.Goarch,
|
||||
Goarm: binary.Goarm,
|
||||
Gomips: binary.Gomips,
|
||||
Goamd64: binary.Goamd64,
|
||||
Type: artifact.UploadableBinary,
|
||||
Name: finalName,
|
||||
Path: binary.Path,
|
||||
Goos: binary.Goos,
|
||||
Goarch: binary.Goarch,
|
||||
Goamd64: binary.Goamd64,
|
||||
Go386: binary.Go386,
|
||||
Goarm: binary.Goarm,
|
||||
Goarm64: binary.Goarm64,
|
||||
Gomips: binary.Gomips,
|
||||
Goppc64: binary.Goppc64,
|
||||
Goriscv64: binary.Goriscv64,
|
||||
Extra: map[string]interface{}{
|
||||
artifact.ExtraID: archive.ID,
|
||||
artifact.ExtraFormat: archive.Format,
|
||||
|
@ -168,27 +168,30 @@ func buildOptionsForTarget(ctx *context.Context, build config.Build, target stri
|
||||
goos := parts[0]
|
||||
goarch := parts[1]
|
||||
|
||||
var gomips string
|
||||
var goarm string
|
||||
var goamd64 string
|
||||
if strings.HasPrefix(goarch, "arm") && len(parts) > 2 {
|
||||
goarm = parts[2]
|
||||
}
|
||||
if strings.HasPrefix(goarch, "mips") && len(parts) > 2 {
|
||||
gomips = parts[2]
|
||||
}
|
||||
if strings.HasPrefix(goarch, "amd64") && len(parts) > 2 {
|
||||
goamd64 = parts[2]
|
||||
buildOpts := builders.Options{
|
||||
Target: target,
|
||||
Ext: ext,
|
||||
Goos: goos,
|
||||
Goarch: goarch,
|
||||
}
|
||||
|
||||
buildOpts := builders.Options{
|
||||
Target: target,
|
||||
Ext: ext,
|
||||
Goos: goos,
|
||||
Goarch: goarch,
|
||||
Goarm: goarm,
|
||||
Gomips: gomips,
|
||||
Goamd64: goamd64,
|
||||
if len(parts) > 2 {
|
||||
//nolint:gocritic
|
||||
if strings.HasPrefix(goarch, "amd64") {
|
||||
buildOpts.Goamd64 = parts[2]
|
||||
} else if goarch == "386" {
|
||||
buildOpts.Gomips = parts[2]
|
||||
} else if strings.HasPrefix(goarch, "arm64") {
|
||||
buildOpts.Goarm64 = parts[2]
|
||||
} else if strings.HasPrefix(goarch, "arm") {
|
||||
buildOpts.Goarm = parts[2]
|
||||
} else if strings.HasPrefix(goarch, "mips") {
|
||||
buildOpts.Gomips = parts[2]
|
||||
} else if strings.HasPrefix(goarch, "ppc64") {
|
||||
buildOpts.Goppc64 = parts[2]
|
||||
} else if goarch == "riscv64" {
|
||||
buildOpts.Goriscv64 = parts[2]
|
||||
}
|
||||
}
|
||||
|
||||
bin, err := tmpl.New(ctx).WithBuildOptions(buildOpts).Apply(build.Binary)
|
||||
|
@ -180,8 +180,8 @@ var termuxArchReplacer = strings.NewReplacer(
|
||||
|
||||
func create(ctx *context.Context, fpm config.NFPM, format string, artifacts []*artifact.Artifact) error {
|
||||
// TODO: improve mips handling on nfpm
|
||||
infoArch := artifacts[0].Goarch + artifacts[0].Goarm + artifacts[0].Gomips // key used for the ConventionalFileName et al
|
||||
arch := infoArch + artifacts[0].Goamd64 // unique arch key
|
||||
infoArch := artifacts[0].Goarch + artifacts[0].Go386 + artifacts[0].Goarm + artifacts[0].Goarm64 + artifacts[0].Gomips + artifacts[0].Goppc64 + artifacts[0].Goriscv64 // key used for the ConventionalFileName et al
|
||||
arch := infoArch + artifacts[0].Goamd64 // unique arch key
|
||||
infoPlatform := artifacts[0].Goos
|
||||
if infoPlatform == "ios" {
|
||||
if format == "deb" {
|
||||
|
@ -423,13 +423,18 @@ func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries [
|
||||
return nil
|
||||
}
|
||||
ctx.Artifacts.Add(&artifact.Artifact{
|
||||
Type: artifact.PublishableSnapcraft,
|
||||
Name: folder + ".snap",
|
||||
Path: snapFile,
|
||||
Goos: binaries[0].Goos,
|
||||
Goarch: binaries[0].Goarch,
|
||||
Goarm: binaries[0].Goarm,
|
||||
Goamd64: binaries[0].Goamd64,
|
||||
Type: artifact.PublishableSnapcraft,
|
||||
Name: folder + ".snap",
|
||||
Path: snapFile,
|
||||
Goos: binaries[0].Goos,
|
||||
Goarch: binaries[0].Goarch,
|
||||
Goamd64: binaries[0].Goamd64,
|
||||
Go386: binaries[0].Go386,
|
||||
Goarm: binaries[0].Goarm,
|
||||
Goarm64: binaries[0].Goarm64,
|
||||
Gomips: binaries[0].Gomips,
|
||||
Goppc64: binaries[0].Goppc64,
|
||||
Goriscv64: binaries[0].Goriscv64,
|
||||
Extra: map[string]interface{}{
|
||||
releasesExtra: channels,
|
||||
},
|
||||
|
@ -66,10 +66,14 @@ const (
|
||||
|
||||
// artifact-only keys.
|
||||
osKey = "Os"
|
||||
amd64 = "Amd64"
|
||||
arch = "Arch"
|
||||
amd64 = "Amd64"
|
||||
go386 = "386"
|
||||
arm = "Arm"
|
||||
arm64 = "Arm64"
|
||||
mips = "Mips"
|
||||
ppc64 = "Ppc64"
|
||||
riscv64 = "Riscv64"
|
||||
binary = "Binary"
|
||||
artifactName = "ArtifactName"
|
||||
artifactExt = "ArtifactExt"
|
||||
@ -170,9 +174,13 @@ func (t *Template) WithExtraFields(f Fields) *Template {
|
||||
func (t *Template) WithArtifact(a *artifact.Artifact) *Template {
|
||||
t.fields[osKey] = a.Goos
|
||||
t.fields[arch] = a.Goarch
|
||||
t.fields[arm] = a.Goarm
|
||||
t.fields[mips] = a.Gomips
|
||||
t.fields[amd64] = a.Goamd64
|
||||
t.fields[go386] = a.Go386
|
||||
t.fields[arm] = a.Goarm
|
||||
t.fields[arm64] = a.Goarm64
|
||||
t.fields[mips] = a.Gomips
|
||||
t.fields[ppc64] = a.Goppc64
|
||||
t.fields[riscv64] = a.Goriscv64
|
||||
t.fields[binary] = artifact.ExtraOr(*a, binary, t.fields[projectName].(string))
|
||||
t.fields[artifactName] = a.Name
|
||||
t.fields[artifactExt] = artifact.ExtraOr(*a, artifact.ExtraExt, "")
|
||||
@ -186,15 +194,19 @@ func (t *Template) WithBuildOptions(opts build.Options) *Template {
|
||||
|
||||
func buildOptsToFields(opts build.Options) Fields {
|
||||
return Fields{
|
||||
target: opts.Target,
|
||||
ext: opts.Ext,
|
||||
name: opts.Name,
|
||||
path: opts.Path,
|
||||
osKey: opts.Goos,
|
||||
arch: opts.Goarch,
|
||||
arm: opts.Goarm,
|
||||
amd64: opts.Goamd64,
|
||||
mips: opts.Gomips,
|
||||
target: opts.Target,
|
||||
ext: opts.Ext,
|
||||
name: opts.Name,
|
||||
path: opts.Path,
|
||||
osKey: opts.Goos,
|
||||
arch: opts.Goarch,
|
||||
amd64: opts.Goamd64,
|
||||
go386: opts.Go386,
|
||||
arm: opts.Goarm,
|
||||
arm64: opts.Goarm64,
|
||||
mips: opts.Gomips,
|
||||
ppc64: opts.Goppc64,
|
||||
riscv64: opts.Goriscv64,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,15 +28,19 @@ func For(name string) Builder {
|
||||
|
||||
// Options to be passed down to a builder.
|
||||
type Options struct {
|
||||
Name string
|
||||
Path string
|
||||
Ext string
|
||||
Target string
|
||||
Goos string
|
||||
Goarch string
|
||||
Goamd64 string
|
||||
Goarm string
|
||||
Gomips string
|
||||
Name string
|
||||
Path string
|
||||
Ext string
|
||||
Target string
|
||||
Goos string
|
||||
Goarch string
|
||||
Goamd64 string
|
||||
Go386 string
|
||||
Goarm string
|
||||
Goarm64 string
|
||||
Gomips string
|
||||
Goppc64 string
|
||||
Goriscv64 string
|
||||
}
|
||||
|
||||
// Builder defines a builder.
|
||||
|
@ -418,11 +418,15 @@ type BuildHooks struct { // renamed on pro
|
||||
|
||||
// IgnoredBuild represents a build ignored by the user.
|
||||
type IgnoredBuild struct {
|
||||
Goos string `yaml:"goos,omitempty" json:"goos,omitempty"`
|
||||
Goarch string `yaml:"goarch,omitempty" json:"goarch,omitempty"`
|
||||
Goarm string `yaml:"goarm,omitempty" json:"goarm,omitempty" jsonschema:"oneof_type=string;integer"`
|
||||
Gomips string `yaml:"gomips,omitempty" json:"gomips,omitempty"`
|
||||
Goamd64 string `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
|
||||
Goos string `yaml:"goos,omitempty" json:"goos,omitempty"`
|
||||
Goarch string `yaml:"goarch,omitempty" json:"goarch,omitempty"`
|
||||
Goamd64 string `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
|
||||
Go386 string `yaml:"go386,omitempty" json:"go386,omitempty"`
|
||||
Goarm string `yaml:"goarm,omitempty" json:"goarm,omitempty" jsonschema:"oneof_type=string;integer"`
|
||||
Goarm64 string `yaml:"goarm64,omitempty" json:"goarm64,omitempty"`
|
||||
Gomips string `yaml:"gomips,omitempty" json:"gomips,omitempty"`
|
||||
Goppc64 string `yaml:"goppc64,omitempty" json:"goppc64,omitempty"`
|
||||
Goriscv64 string `yaml:"goriscv64,omitempty" json:"goriscv64,omitempty"`
|
||||
}
|
||||
|
||||
// StringArray is a wrapper for an array of strings.
|
||||
@ -492,9 +496,13 @@ type Build struct {
|
||||
ID string `yaml:"id,omitempty" json:"id,omitempty"`
|
||||
Goos []string `yaml:"goos,omitempty" json:"goos,omitempty"`
|
||||
Goarch []string `yaml:"goarch,omitempty" json:"goarch,omitempty"`
|
||||
Goarm []string `yaml:"goarm,omitempty" json:"goarm,omitempty"`
|
||||
Gomips []string `yaml:"gomips,omitempty" json:"gomips,omitempty"`
|
||||
Goamd64 []string `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
|
||||
Go386 []string `yaml:"go386,omitempty" json:"go386,omitempty"`
|
||||
Goarm []string `yaml:"goarm,omitempty" json:"goarm,omitempty"`
|
||||
Goarm64 []string `yaml:"goarm64,omitempty" json:"goarm64,omitempty"`
|
||||
Gomips []string `yaml:"gomips,omitempty" json:"gomips,omitempty"`
|
||||
Goppc64 []string `yaml:"goppc64,omitempty" json:"goppc64,omitempty"`
|
||||
Goriscv64 []string `yaml:"goriscv64,omitempty" json:"goriscv64,omitempty"`
|
||||
Targets []string `yaml:"targets,omitempty" json:"targets,omitempty"`
|
||||
Ignore []IgnoredBuild `yaml:"ignore,omitempty" json:"ignore,omitempty"`
|
||||
Dir string `yaml:"dir,omitempty" json:"dir,omitempty"`
|
||||
|
@ -123,6 +123,13 @@ builds:
|
||||
- v2
|
||||
- v3
|
||||
|
||||
# GOARM64 to build when GOARCH is arm64.
|
||||
# For more info refer to: https://go.dev/doc/install/source#environment
|
||||
#
|
||||
# Default: [ 'v8.0' ].
|
||||
goarm64:
|
||||
- v9.0
|
||||
|
||||
# GOMIPS and GOMIPS64 to build when GOARCH is mips, mips64, mipsle or mips64le.
|
||||
# For more info refer to: https://go.dev/doc/install/source#environment
|
||||
#
|
||||
@ -131,6 +138,29 @@ builds:
|
||||
- hardfloat
|
||||
- softfloat
|
||||
|
||||
# GO386 to build when GOARCH is 386.
|
||||
# For more info refer to: https://go.dev/doc/install/source#environment
|
||||
#
|
||||
# Default: [ 'sse2' ].
|
||||
go386:
|
||||
- sse2
|
||||
- softfloat
|
||||
|
||||
# GOPPC64 to build when GOARCH is PPC64.
|
||||
# For more info refer to: https://go.dev/doc/install/source#environment
|
||||
#
|
||||
# Default: [ 'power8' ].
|
||||
goppc64:
|
||||
- power8
|
||||
- power9
|
||||
|
||||
# GORISCV64 to build when GOARCH is RISCV64.
|
||||
# For more info refer to: https://go.dev/doc/install/source#environment
|
||||
#
|
||||
# Default: [ 'rva20u64' ].
|
||||
goriscv64:
|
||||
- rva22u64
|
||||
|
||||
# List of combinations of GOOS + GOARCH + GOARM to ignore.
|
||||
ignore:
|
||||
- goos: darwin
|
||||
|
@ -87,6 +87,11 @@ You should be able to use all its fields on each item:
|
||||
- `.Goarm`
|
||||
- `.Gomips`
|
||||
- `.Goamd64`
|
||||
- `.Goarm64` (since v2.4)
|
||||
- `.Gomips64` (since v2.4)
|
||||
- `.Goppc64` (since v2.4)
|
||||
- `.Goriscv64` (since v2.4)
|
||||
- `.Go386` (since v2.4)
|
||||
- `.Type`
|
||||
- `.Extra`
|
||||
|
||||
@ -104,6 +109,11 @@ may have some extra fields:
|
||||
| `.Arm` | `GOARM` |
|
||||
| `.Mips` | `GOMIPS` |
|
||||
| `.Amd64` | `GOAMD64` |
|
||||
| `.Arm64` | `GOARM64` (since v2.4) |
|
||||
| `.Mips64` | `GOMIPS64` (since v2.4) |
|
||||
| `.PPC64` | `GOPPC64` (since v2.4) |
|
||||
| `.Riscv64` | `GORISCV64` (since v2.4) |
|
||||
| `.386` | `GO386` (since v2.4) |
|
||||
| `.Binary` | binary name |
|
||||
| `.ArtifactID` | archive id (since v2.3[^pro]) |
|
||||
| `.ArtifactName` | archive name |
|
||||
@ -187,7 +197,7 @@ foo_template: "foo_{{ .Env.GOVERSION }}"
|
||||
And then you can run:
|
||||
|
||||
```sh
|
||||
GOVERSION_NR=$(go version | awk '{print $3;}') goreleaser
|
||||
GOVERSION=$(go version | awk '{print $3;}') goreleaser
|
||||
```
|
||||
|
||||
!!! warning
|
||||
|
Loading…
x
Reference in New Issue
Block a user