mirror of
https://github.com/goreleaser/goreleaser.git
synced 2026-06-19 23:24:39 +02:00
buidl with ext
This commit is contained in:
2 files changed
+20
-11
No files matched your search
@@ -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 ""
|
||||||
|
}
|
||||||
@@ -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 ""
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user