You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-09-16 09:26:52 +02:00
feat: write actual config to dist
Writes the actual config file (with defaults merged, etc) into the dist folder. Can be useful for debug purposes.
This commit is contained in:
committed by
Carlos Alexandro Becker
parent
bb5e27b0c4
commit
06ddedf12a
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
dist/
|
dist/
|
||||||
|
!pipeline/dist
|
||||||
vendor
|
vendor
|
||||||
coverage.txt
|
coverage.txt
|
||||||
goreleaser
|
goreleaser
|
||||||
|
@@ -16,10 +16,11 @@ import (
|
|||||||
"github.com/goreleaser/goreleaser/pipeline/build"
|
"github.com/goreleaser/goreleaser/pipeline/build"
|
||||||
"github.com/goreleaser/goreleaser/pipeline/changelog"
|
"github.com/goreleaser/goreleaser/pipeline/changelog"
|
||||||
"github.com/goreleaser/goreleaser/pipeline/checksums"
|
"github.com/goreleaser/goreleaser/pipeline/checksums"
|
||||||
"github.com/goreleaser/goreleaser/pipeline/cleandist"
|
|
||||||
"github.com/goreleaser/goreleaser/pipeline/defaults"
|
"github.com/goreleaser/goreleaser/pipeline/defaults"
|
||||||
|
"github.com/goreleaser/goreleaser/pipeline/dist"
|
||||||
"github.com/goreleaser/goreleaser/pipeline/docker"
|
"github.com/goreleaser/goreleaser/pipeline/docker"
|
||||||
"github.com/goreleaser/goreleaser/pipeline/env"
|
"github.com/goreleaser/goreleaser/pipeline/env"
|
||||||
|
"github.com/goreleaser/goreleaser/pipeline/finalconfig"
|
||||||
"github.com/goreleaser/goreleaser/pipeline/fpm"
|
"github.com/goreleaser/goreleaser/pipeline/fpm"
|
||||||
"github.com/goreleaser/goreleaser/pipeline/git"
|
"github.com/goreleaser/goreleaser/pipeline/git"
|
||||||
"github.com/goreleaser/goreleaser/pipeline/release"
|
"github.com/goreleaser/goreleaser/pipeline/release"
|
||||||
@@ -37,19 +38,20 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pipes = []pipeline.Piper{
|
var pipes = []pipeline.Piper{
|
||||||
defaults.Pipe{}, // load default configs
|
defaults.Pipe{}, // load default configs
|
||||||
git.Pipe{}, // get and validate git repo state
|
dist.Pipe{}, // ensure ./dist is clean
|
||||||
changelog.Pipe{}, // builds the release changelog
|
finalconfig.Pipe{}, // writes the actual config (with defaults et al set) to dist
|
||||||
env.Pipe{}, // load and validate environment variables
|
git.Pipe{}, // get and validate git repo state
|
||||||
cleandist.Pipe{}, // ensure ./dist is clean
|
changelog.Pipe{}, // builds the release changelog
|
||||||
build.Pipe{}, // build
|
env.Pipe{}, // load and validate environment variables
|
||||||
archive.Pipe{}, // archive (tar.gz, zip, etc)
|
build.Pipe{}, // build
|
||||||
fpm.Pipe{}, // archive via fpm (deb, rpm, etc)
|
archive.Pipe{}, // archive (tar.gz, zip, etc)
|
||||||
snapcraft.Pipe{}, // archive via snapcraft (snap)
|
fpm.Pipe{}, // archive via fpm (deb, rpm, etc)
|
||||||
checksums.Pipe{}, // checksums of the files
|
snapcraft.Pipe{}, // archive via snapcraft (snap)
|
||||||
docker.Pipe{}, // create and push docker images
|
checksums.Pipe{}, // checksums of the files
|
||||||
release.Pipe{}, // release to github
|
docker.Pipe{}, // create and push docker images
|
||||||
brew.Pipe{}, // push to brew tap
|
release.Pipe{}, // release to github
|
||||||
|
brew.Pipe{}, // push to brew tap
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flags interface represents an extractor of cli flags
|
// Flags interface represents an extractor of cli flags
|
||||||
|
@@ -48,6 +48,6 @@ func (Pipe) Run(ctx *context.Context) error {
|
|||||||
if ctx.Config.ProjectName == "" {
|
if ctx.Config.ProjectName == "" {
|
||||||
ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
|
ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
|
||||||
}
|
}
|
||||||
log.WithField("config", ctx.Config).Debug("defaults set")
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
// Package cleandist provides checks to make sure the dist folder is always
|
// Package dist provides checks to make sure the dist folder is always
|
||||||
// empty.
|
// empty.
|
||||||
package cleandist
|
package dist
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -22,12 +22,16 @@ func (Pipe) String() string {
|
|||||||
func (Pipe) Run(ctx *context.Context) (err error) {
|
func (Pipe) Run(ctx *context.Context) (err error) {
|
||||||
_, err = os.Stat(ctx.Config.Dist)
|
_, err = os.Stat(ctx.Config.Dist)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
log.Debug("./dist doesn't exist, moving on")
|
log.Debug("./dist doesn't exist, creating empty folder")
|
||||||
return nil
|
return mkdir(ctx)
|
||||||
}
|
}
|
||||||
if ctx.RmDist {
|
if ctx.RmDist {
|
||||||
log.Info("--rm-dist is set, removing ./dist")
|
log.Info("--rm-dist is set, cleaning it up")
|
||||||
return os.RemoveAll(ctx.Config.Dist)
|
err = os.RemoveAll(ctx.Config.Dist)
|
||||||
|
if err == nil {
|
||||||
|
err = mkdir(ctx)
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
files, err := ioutil.ReadDir(ctx.Config.Dist)
|
files, err := ioutil.ReadDir(ctx.Config.Dist)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -41,5 +45,9 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
log.Debug("./dist is empty")
|
log.Debug("./dist is empty")
|
||||||
return
|
return mkdir(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func mkdir(ctx *context.Context) error {
|
||||||
|
return os.Mkdir(ctx.Config.Dist, 0755)
|
||||||
}
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
package cleandist
|
package dist
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
27
pipeline/finalconfig/finalconfig.go
Normal file
27
pipeline/finalconfig/finalconfig.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package finalconfig
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/apex/log"
|
||||||
|
"github.com/goreleaser/goreleaser/context"
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Pipe struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Pipe) String() string {
|
||||||
|
return "writing the final config file to dist folder"
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
return ioutil.WriteFile(path, bts, 0644)
|
||||||
|
}
|
Reference in New Issue
Block a user