1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/pipe/partial/partial.go
Carlos Alexandro Becker 25a054c5e1
feat: improve --single-target (#4442)
closes #4437 
closes #4426

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2023-11-27 18:29:50 -03:00

26 lines
601 B
Go

package partial
import (
"os"
"runtime"
"github.com/charmbracelet/x/exp/ordered"
"github.com/goreleaser/goreleaser/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)
return goos + "_" + goarch
}