2017-12-10 11:28:01 -02:00
|
|
|
package effectiveconfig
|
2017-12-08 22:30:02 -02:00
|
|
|
|
|
|
|
import (
|
2021-04-25 13:00:51 -03:00
|
|
|
"os"
|
2017-12-08 22:30:02 -02:00
|
|
|
"path/filepath"
|
|
|
|
|
2022-06-21 21:11:15 -03:00
|
|
|
"github.com/caarlos0/log"
|
2024-05-26 15:02:57 -03:00
|
|
|
"github.com/goreleaser/goreleaser/v2/internal/yaml"
|
|
|
|
"github.com/goreleaser/goreleaser/v2/pkg/context"
|
2017-12-08 22:30:02 -02:00
|
|
|
)
|
|
|
|
|
2020-05-26 00:48:10 -03:00
|
|
|
// Pipe that writes the effective config file to dist.
|
2021-04-25 14:20:49 -03:00
|
|
|
type Pipe struct{}
|
2017-12-08 22:30:02 -02:00
|
|
|
|
2024-06-22 22:43:57 -03:00
|
|
|
func (Pipe) String() string { return "" }
|
2017-12-08 22:30:02 -02:00
|
|
|
|
2020-05-26 00:48:10 -03:00
|
|
|
// Run the pipe.
|
2017-12-08 22:30:02 -02:00
|
|
|
func (Pipe) Run(ctx *context.Context) (err error) {
|
2021-04-25 14:20:49 -03:00
|
|
|
path := filepath.Join(ctx.Config.Dist, "config.yaml")
|
2017-12-08 22:30:02 -02:00
|
|
|
bts, err := yaml.Marshal(ctx.Config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-06-22 22:43:57 -03:00
|
|
|
log.WithField("path", path).Debug("writing effective configuration")
|
2024-10-31 18:51:54 +02:00
|
|
|
return os.WriteFile(path, bts, 0o644) //nolint:gosec
|
2017-12-08 22:30:02 -02:00
|
|
|
}
|