buidl with ext

This commit is contained in:
Carlos Alexandro Becker committed 2017-01-14 12:51:09 -02:00
1 parent ddec194c7e
commit 4e10d93b4d
2 files changed
+20 -11

No files matched your search

+8 -1
View File
@@ -41,7 +41,7 @@ func (Pipe) Run(context *context.Context) error {
func build(name, system, arch string, context *context.Context) error { func build(name, system, arch string, context *context.Context) error {
ldflags := context.Config.Build.Ldflags + " -X main.version=" + context.Git.CurrentTag ldflags := context.Config.Build.Ldflags + " -X main.version=" + context.Git.CurrentTag
output := "dist/" + name + "/" + context.Config.BinaryName output := "dist/" + name + "/" + context.Config.BinaryName + extFor(system)
log.Println("Building", output, "...") log.Println("Building", output, "...")
cmd := exec.Command( cmd := exec.Command(
"go", "go",
@@ -65,3 +65,10 @@ func build(name, system, arch string, context *context.Context) error {
} }
return nil return nil
} }
func extFor(system string) string {
if system == "windows" {
return ".exe"
}
return ""
}
+12 -10
View File
@@ -1,10 +1,10 @@
package compress package compress
import ( import (
"io/ioutil"
"log" "log"
"os" "os"
"github.com/goreleaser/releaser/config"
"github.com/goreleaser/releaser/context" "github.com/goreleaser/releaser/context"
"github.com/goreleaser/releaser/pipeline/compress/tar" "github.com/goreleaser/releaser/pipeline/compress/tar"
"github.com/goreleaser/releaser/pipeline/compress/zip" "github.com/goreleaser/releaser/pipeline/compress/zip"
@@ -45,12 +45,21 @@ func create(archive string, context *context.Context) error {
defer func() { _ = file.Close() }() defer func() { _ = file.Close() }()
var archive = archiveFor(file, context.Config.Archive.Format) var archive = archiveFor(file, context.Config.Archive.Format)
defer func() { _ = archive.Close() }() defer func() { _ = archive.Close() }()
for _, f := range config.Files { for _, f := range context.Config.Files {
if err := archive.Add(f, f); err != nil { if err := archive.Add(f, f); err != nil {
return err return err
} }
} }
return archive.Add(config.BinaryName+extFor(system), "dist/"+name+"/"+config.BinaryName) files, err := ioutil.ReadDir("dist/" + name)
if err != nil {
return err
}
for _, f := range files {
if err := archive.Add(file.Name(), f); err != nil {
return err
}
}
return nil
} }
func archiveFor(file *os.File, format string) Archive { func archiveFor(file *os.File, format string) Archive {
@@ -59,10 +68,3 @@ func archiveFor(file *os.File, format string) Archive {
} }
return tar.New(file) return tar.New(file)
} }
func extFor(system string) string {
if system == "windows" {
return ".exe"
}
return ""
}