1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00

fixing archiving and brew

This commit is contained in:
Carlos Alexandro Becker 2017-06-27 20:06:45 -03:00
parent 4504cd4527
commit a8f1645ea9
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
4 changed files with 41 additions and 34 deletions

View File

@ -7,6 +7,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"github.com/apex/log"
yaml "gopkg.in/yaml.v1" yaml "gopkg.in/yaml.v1"
) )
@ -128,5 +129,6 @@ func LoadReader(fd io.Reader) (config Project, err error) {
return config, err return config, err
} }
err = yaml.Unmarshal(data, &config) err = yaml.Unmarshal(data, &config)
log.WithField("config", config).Debug("loaded")
return return
} }

View File

@ -38,7 +38,7 @@ func (Pipe) Run(ctx *context.Context) error {
} }
func create(ctx *context.Context, platform, name string) 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) var format = formatFor(ctx, platform)
file, err := os.Create(folder + "." + format) file, err := os.Create(folder + "." + format)
if err != nil { if err != nil {
@ -60,7 +60,8 @@ func create(ctx *context.Context, platform, name string) error {
} }
for _, build := range ctx.Config.Builds { for _, build := range ctx.Config.Builds {
var binary = build.Binary + ext.For(platform) 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 return err
} }
} }

View File

@ -134,17 +134,21 @@ func doBuildFormula(data templateData) (bytes.Buffer, error) {
return out, err 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) { func dataFor(ctx *context.Context, client client.Client) (result templateData, err error) {
file := ctx.Archives["darwinamd64"] if !hasDarwinBuilds(ctx) {
if file == "" {
return result, ErrNoDarwin64Build return result, ErrNoDarwin64Build
} }
sum, err := checksum.SHA256( var file = ctx.Config.Name + "." + ctx.Config.Archive.Format
filepath.Join( sum, err := checksum.SHA256(filepath.Join(ctx.Config.Dist, file))
ctx.Config.Dist,
file+"."+ctx.Config.Archive.Format,
),
)
if err != nil { if err != nil {
return return
} }

View File

@ -66,12 +66,9 @@ func setReleaseDefaults(ctx *context.Context) error {
} }
func setBuildDefaults(ctx *context.Context) { func setBuildDefaults(ctx *context.Context) {
for i, build := range ctx.Config.Builds { var builds []config.Build
ctx.Config.Builds[i] = buildWithDefaults(ctx, build) log.WithField("builds", ctx.Config.Builds).Debug("builds cleaned")
} for _, build := range ctx.Config.Builds {
}
func buildWithDefaults(ctx *context.Context, build config.Build) config.Build {
if build.Binary == "" { if build.Binary == "" {
build.Binary = ctx.Config.Release.GitHub.Name build.Binary = ctx.Config.Release.GitHub.Name
} }
@ -90,7 +87,10 @@ func buildWithDefaults(ctx *context.Context, build config.Build) config.Build {
if build.Ldflags == "" { if build.Ldflags == "" {
build.Ldflags = "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}" build.Ldflags = "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}"
} }
return build builds = append(builds, build)
}
ctx.Config.Builds = builds
log.WithField("builds", ctx.Config.Builds).Debug("set")
} }
func setArchiveDefaults(ctx *context.Context) error { func setArchiveDefaults(ctx *context.Context) error {