1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-31 01:53:50 +02:00
goreleaser/pkg/build/build.go

51 lines
1.0 KiB
Go
Raw Normal View History

2018-01-25 01:22:45 +02:00
// Package build provides the API for external builders
2018-01-21 18:31:08 +02:00
package build
import (
"sync"
"github.com/goreleaser/goreleaser/v2/pkg/config"
"github.com/goreleaser/goreleaser/v2/pkg/context"
2018-01-21 18:31:08 +02:00
)
//nolint:gochecknoglobals
2018-01-21 18:31:08 +02:00
var (
builders = map[string]Builder{}
lock sync.Mutex
)
// Register registers a builder to a given name.
func Register(name string, builder Builder) {
2018-01-21 18:31:08 +02:00
lock.Lock()
builders[name] = builder
2018-01-21 18:31:08 +02:00
lock.Unlock()
}
// For gets the previously registered builder for the given name.
func For(name string) Builder {
return builders[name]
2018-01-21 18:31:08 +02:00
}
// Options to be passed down to a builder.
2018-01-21 18:31:08 +02:00
type Options struct {
Name string
Path string
Ext string // with the leading `.`.
Target string
Goos string
Goarch string
Goamd64 string
Go386 string
Goarm string
Goarm64 string
Gomips string
Goppc64 string
Goriscv64 string
2018-01-21 18:31:08 +02:00
}
// Builder defines a builder.
2018-01-21 18:31:08 +02:00
type Builder interface {
WithDefaults(build config.Build) (config.Build, error)
2018-01-21 18:31:08 +02:00
Build(ctx *context.Context, build config.Build, options Options) error
}