2022-01-14 15:33:11 +02:00
|
|
|
// Package prebuild provides a pipe that runs before the build and gomod pipes, mainly to resolve common templates.
|
|
|
|
package prebuild
|
|
|
|
|
|
|
|
import (
|
2024-05-26 20:02:57 +02:00
|
|
|
"github.com/goreleaser/goreleaser/v2/internal/tmpl"
|
|
|
|
"github.com/goreleaser/goreleaser/v2/pkg/context"
|
2022-01-14 15:33:11 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Pipe for build.
|
|
|
|
type Pipe struct{}
|
|
|
|
|
|
|
|
func (Pipe) String() string {
|
|
|
|
return "build prerequisites"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run the pipe.
|
|
|
|
func (Pipe) Run(ctx *context.Context) error {
|
|
|
|
tpl := tmpl.New(ctx)
|
|
|
|
for i := range ctx.Config.Builds {
|
|
|
|
m, err := tpl.Apply(ctx.Config.Builds[i].Main)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if m == "" {
|
|
|
|
m = "."
|
|
|
|
}
|
|
|
|
ctx.Config.Builds[i].Main = m
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|