diff --git a/goreleaserlib/goreleaser.go b/goreleaserlib/goreleaser.go index 378608788..9f6c37dc7 100644 --- a/goreleaserlib/goreleaser.go +++ b/goreleaserlib/goreleaser.go @@ -19,8 +19,8 @@ import ( "github.com/goreleaser/goreleaser/pipeline/defaults" "github.com/goreleaser/goreleaser/pipeline/dist" "github.com/goreleaser/goreleaser/pipeline/docker" + "github.com/goreleaser/goreleaser/pipeline/effectiveconfig" "github.com/goreleaser/goreleaser/pipeline/env" - "github.com/goreleaser/goreleaser/pipeline/finalconfig" "github.com/goreleaser/goreleaser/pipeline/fpm" "github.com/goreleaser/goreleaser/pipeline/git" "github.com/goreleaser/goreleaser/pipeline/release" @@ -38,20 +38,20 @@ func init() { } var pipes = []pipeline.Piper{ - defaults.Pipe{}, // load default configs - dist.Pipe{}, // ensure ./dist is clean - finalconfig.Pipe{}, // writes the actual config (with defaults et al set) to dist - git.Pipe{}, // get and validate git repo state - changelog.Pipe{}, // builds the release changelog - env.Pipe{}, // load and validate environment variables - build.Pipe{}, // build - archive.Pipe{}, // archive (tar.gz, zip, etc) - fpm.Pipe{}, // archive via fpm (deb, rpm, etc) - snapcraft.Pipe{}, // archive via snapcraft (snap) - checksums.Pipe{}, // checksums of the files - docker.Pipe{}, // create and push docker images - release.Pipe{}, // release to github - brew.Pipe{}, // push to brew tap + defaults.Pipe{}, // load default configs + dist.Pipe{}, // ensure ./dist is clean + effectiveconfig.Pipe{}, // writes the actual config (with defaults et al set) to dist + git.Pipe{}, // get and validate git repo state + changelog.Pipe{}, // builds the release changelog + env.Pipe{}, // load and validate environment variables + build.Pipe{}, // build + archive.Pipe{}, // archive (tar.gz, zip, etc) + fpm.Pipe{}, // archive via fpm (deb, rpm, etc) + snapcraft.Pipe{}, // archive via snapcraft (snap) + checksums.Pipe{}, // checksums of the files + docker.Pipe{}, // create and push docker images + release.Pipe{}, // release to github + brew.Pipe{}, // push to brew tap } // Flags interface represents an extractor of cli flags diff --git a/pipeline/defaults/defaults.go b/pipeline/defaults/defaults.go index fed2d5d22..dc1e88ea6 100644 --- a/pipeline/defaults/defaults.go +++ b/pipeline/defaults/defaults.go @@ -16,7 +16,7 @@ import ( "github.com/goreleaser/goreleaser/pipeline/snapshot" ) -// Pipe for brew deployment +// Pipe that sets the defaults type Pipe struct{} func (Pipe) String() string { @@ -50,4 +50,3 @@ func (Pipe) Run(ctx *context.Context) error { } return nil } - diff --git a/pipeline/finalconfig/finalconfig.go b/pipeline/effectiveconfig/config.go similarity index 69% rename from pipeline/finalconfig/finalconfig.go rename to pipeline/effectiveconfig/config.go index 37becbbce..94faa3278 100644 --- a/pipeline/finalconfig/finalconfig.go +++ b/pipeline/effectiveconfig/config.go @@ -1,4 +1,4 @@ -package finalconfig +package effectiveconfig import ( "io/ioutil" @@ -9,19 +9,21 @@ import ( yaml "gopkg.in/yaml.v2" ) +// Pipe that writes the effective config file to dist type Pipe struct { } func (Pipe) String() string { - return "writing the final config file to dist folder" + return "writing effective config file" } +// Run the pipe func (Pipe) Run(ctx *context.Context) (err error) { var path = filepath.Join(ctx.Config.Dist, "config.yaml") bts, err := yaml.Marshal(ctx.Config) if err != nil { return err } - log.WithField("path", path).Info("writting") + log.WithField("config", path).Info("writting") return ioutil.WriteFile(path, bts, 0644) } diff --git a/pipeline/effectiveconfig/config_test.go b/pipeline/effectiveconfig/config_test.go new file mode 100644 index 000000000..e5a9ea346 --- /dev/null +++ b/pipeline/effectiveconfig/config_test.go @@ -0,0 +1,33 @@ +package effectiveconfig + +import ( + "io/ioutil" + "os" + "path/filepath" + "testing" + + "github.com/goreleaser/goreleaser/config" + "github.com/goreleaser/goreleaser/context" + "github.com/goreleaser/goreleaser/internal/testlib" + "github.com/stretchr/testify/assert" +) + +func TestPipeDescription(t *testing.T) { + assert.NotEmpty(t, Pipe{}.String()) +} + +func Test(t *testing.T) { + folder, back := testlib.Mktmp(t) + defer back() + dist := filepath.Join(folder, "dist") + assert.NoError(t, os.Mkdir(dist, 0755)) + var ctx = context.New( + config.Project{ + Dist: dist, + }, + ) + assert.NoError(t, Pipe{}.Run(ctx)) + bts, err := ioutil.ReadFile(filepath.Join(dist, "config.yaml")) + assert.NoError(t, err) + assert.NotEmpty(t, string(bts)) +}