1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-31 01:53:50 +02:00
goreleaser/internal/pipe/partial/partial.go
Carlos Alexandro Becker 0468da12fd
feat: default GOARM change to 7 (#5157)
Guarded by an environment variable for now.

Closes #5155
2024-09-27 13:31:29 -03:00

45 lines
1.3 KiB
Go

package partial
import (
"os"
"runtime"
"strings"
"github.com/charmbracelet/x/exp/ordered"
"github.com/goreleaser/goreleaser/v2/internal/experimental"
"github.com/goreleaser/goreleaser/v2/pkg/context"
)
type Pipe struct{}
func (Pipe) String() string { return "partial" }
func (Pipe) Skip(ctx *context.Context) bool { return !ctx.Partial }
func (Pipe) Run(ctx *context.Context) error {
ctx.PartialTarget = getFilter()
return nil
}
func getFilter() string {
goos := ordered.First(os.Getenv("GGOOS"), os.Getenv("GOOS"), runtime.GOOS)
goarch := ordered.First(os.Getenv("GGOARCH"), os.Getenv("GOARCH"), runtime.GOARCH)
target := goos + "_" + goarch
if strings.HasSuffix(target, "_amd64") {
goamd64 := ordered.First(os.Getenv("GGOAMD64"), os.Getenv("GOAMD64"), "v1")
target = target + "_" + goamd64
}
if strings.HasSuffix(target, "_arm") {
goarm := ordered.First(os.Getenv("GGOARM"), os.Getenv("GOARM"), experimental.DefaultGOARM())
target = target + "_" + goarm
}
if strings.HasSuffix(target, "_mips") ||
strings.HasSuffix(target, "_mips64") ||
strings.HasSuffix(target, "_mipsle") ||
strings.HasSuffix(target, "_mips64le") {
gomips := ordered.First(os.Getenv("GGOMIPS"), os.Getenv("GOMIPS"), "hardfloat")
target = target + "_" + gomips
}
return target
}