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

buidl with ext

This commit is contained in:
Carlos Alexandro Becker 2017-01-14 12:51:09 -02:00
parent ddec194c7e
commit 4e10d93b4d
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 20 additions and 11 deletions

View File

@ -41,7 +41,7 @@ func (Pipe) Run(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
output := "dist/" + name + "/" + context.Config.BinaryName
output := "dist/" + name + "/" + context.Config.BinaryName + extFor(system)
log.Println("Building", output, "...")
cmd := exec.Command(
"go",
@ -65,3 +65,10 @@ func build(name, system, arch string, context *context.Context) error {
}
return nil
}
func extFor(system string) string {
if system == "windows" {
return ".exe"
}
return ""
}

View File

@ -1,10 +1,10 @@
package compress
import (
"io/ioutil"
"log"
"os"
"github.com/goreleaser/releaser/config"
"github.com/goreleaser/releaser/context"
"github.com/goreleaser/releaser/pipeline/compress/tar"
"github.com/goreleaser/releaser/pipeline/compress/zip"
@ -45,12 +45,21 @@ func create(archive string, context *context.Context) error {
defer func() { _ = file.Close() }()
var archive = archiveFor(file, context.Config.Archive.Format)
defer func() { _ = archive.Close() }()
for _, f := range config.Files {
for _, f := range context.Config.Files {
if err := archive.Add(f, f); err != nil {
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 {
@ -59,10 +68,3 @@ func archiveFor(file *os.File, format string) Archive {
}
return tar.New(file)
}
func extFor(system string) string {
if system == "windows" {
return ".exe"
}
return ""
}