github.com/goreleaser/goreleaser@v1.25.1/internal/pipe/prebuild/prebuild.go (about)

     1  // Package prebuild provides a pipe that runs before the build and gomod pipes, mainly to resolve common templates.
     2  package prebuild
     3  
     4  import (
     5  	"github.com/goreleaser/goreleaser/internal/tmpl"
     6  	"github.com/goreleaser/goreleaser/pkg/context"
     7  )
     8  
     9  // Pipe for build.
    10  type Pipe struct{}
    11  
    12  func (Pipe) String() string {
    13  	return "build prerequisites"
    14  }
    15  
    16  // Run the pipe.
    17  func (Pipe) Run(ctx *context.Context) error {
    18  	tpl := tmpl.New(ctx)
    19  	for i := range ctx.Config.Builds {
    20  		m, err := tpl.Apply(ctx.Config.Builds[i].Main)
    21  		if err != nil {
    22  			return err
    23  		}
    24  		if m == "" {
    25  			m = "."
    26  		}
    27  		ctx.Config.Builds[i].Main = m
    28  	}
    29  	return nil
    30  }