diff --git a/config/config.go b/config/config.go index 15f43ea7a..4323aa9a2 100644 --- a/config/config.go +++ b/config/config.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "os" + "github.com/apex/log" yaml "gopkg.in/yaml.v1" ) @@ -128,5 +129,6 @@ func LoadReader(fd io.Reader) (config Project, err error) { return config, err } err = yaml.Unmarshal(data, &config) + log.WithField("config", config).Debug("loaded") return } diff --git a/pipeline/archive/archive.go b/pipeline/archive/archive.go index 147411ea9..49fda5440 100644 --- a/pipeline/archive/archive.go +++ b/pipeline/archive/archive.go @@ -38,7 +38,7 @@ func (Pipe) Run(ctx *context.Context) error { } func create(ctx *context.Context, platform, name string) error { - var folder = filepath.Join(ctx.Config.Dist, name) + var folder = filepath.Join(ctx.Config.Dist, ctx.Config.Name) var format = formatFor(ctx, platform) file, err := os.Create(folder + "." + format) if err != nil { @@ -60,7 +60,8 @@ func create(ctx *context.Context, platform, name string) error { } for _, build := range ctx.Config.Builds { var binary = build.Binary + ext.For(platform) - if err := archive.Add(binary, filepath.Join(folder, binary)); err != nil { + var bin = filepath.Join(ctx.Config.Dist, name) + if err := archive.Add(binary, filepath.Join(bin, binary)); err != nil { return err } } diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index 47fb09e71..663bf7960 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -134,17 +134,21 @@ func doBuildFormula(data templateData) (bytes.Buffer, error) { return out, err } +func hasDarwinBuilds(ctx *context.Context) bool { + for key := range ctx.Archives { + if strings.HasSuffix(key, "darwinamd64") { + return true + } + } + return false +} + func dataFor(ctx *context.Context, client client.Client) (result templateData, err error) { - file := ctx.Archives["darwinamd64"] - if file == "" { + if !hasDarwinBuilds(ctx) { return result, ErrNoDarwin64Build } - sum, err := checksum.SHA256( - filepath.Join( - ctx.Config.Dist, - file+"."+ctx.Config.Archive.Format, - ), - ) + var file = ctx.Config.Name + "." + ctx.Config.Archive.Format + sum, err := checksum.SHA256(filepath.Join(ctx.Config.Dist, file)) if err != nil { return } diff --git a/pipeline/defaults/defaults.go b/pipeline/defaults/defaults.go index e010b39cc..089c318d9 100644 --- a/pipeline/defaults/defaults.go +++ b/pipeline/defaults/defaults.go @@ -66,31 +66,31 @@ func setReleaseDefaults(ctx *context.Context) error { } func setBuildDefaults(ctx *context.Context) { - for i, build := range ctx.Config.Builds { - ctx.Config.Builds[i] = buildWithDefaults(ctx, build) + var builds []config.Build + log.WithField("builds", ctx.Config.Builds).Debug("builds cleaned") + for _, build := range ctx.Config.Builds { + if build.Binary == "" { + build.Binary = ctx.Config.Release.GitHub.Name + } + if build.Main == "" { + build.Main = "." + } + if len(build.Goos) == 0 { + build.Goos = []string{"linux", "darwin"} + } + if len(build.Goarch) == 0 { + build.Goarch = []string{"amd64", "386"} + } + if len(build.Goarm) == 0 { + build.Goarm = []string{"6"} + } + if build.Ldflags == "" { + build.Ldflags = "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}" + } + builds = append(builds, build) } -} - -func buildWithDefaults(ctx *context.Context, build config.Build) config.Build { - if build.Binary == "" { - build.Binary = ctx.Config.Release.GitHub.Name - } - if build.Main == "" { - build.Main = "." - } - if len(build.Goos) == 0 { - build.Goos = []string{"linux", "darwin"} - } - if len(build.Goarch) == 0 { - build.Goarch = []string{"amd64", "386"} - } - if len(build.Goarm) == 0 { - build.Goarm = []string{"6"} - } - if build.Ldflags == "" { - build.Ldflags = "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}" - } - return build + ctx.Config.Builds = builds + log.WithField("builds", ctx.Config.Builds).Debug("set") } func setArchiveDefaults(ctx *context.Context) error {