1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +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"
"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
}

View File

@ -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
}
}

View File

@ -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
}

View File

@ -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 {