You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	buidl with ext
This commit is contained in:
		| @@ -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 "" | ||||
| } | ||||
|   | ||||
| @@ -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 "" | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user