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

     1  package effectiveconfig
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  
     7  	"github.com/caarlos0/log"
     8  	"github.com/goreleaser/goreleaser/internal/yaml"
     9  	"github.com/goreleaser/goreleaser/pkg/context"
    10  )
    11  
    12  // Pipe that writes the effective config file to dist.
    13  type Pipe struct{}
    14  
    15  func (Pipe) String() string {
    16  	return "writing effective config file"
    17  }
    18  
    19  // Run the pipe.
    20  func (Pipe) Run(ctx *context.Context) (err error) {
    21  	path := filepath.Join(ctx.Config.Dist, "config.yaml")
    22  	bts, err := yaml.Marshal(ctx.Config)
    23  	if err != nil {
    24  		return err
    25  	}
    26  	log.WithField("config", path).Info("writing")
    27  	return os.WriteFile(path, bts, 0o644) //nolint: gosec
    28  }