diff --git a/pipeline/compress/compress_test.go b/pipeline/compress/compress_test.go new file mode 100644 index 000000000..ed3575042 --- /dev/null +++ b/pipeline/compress/compress_test.go @@ -0,0 +1,14 @@ +package compress + +import ( + "testing" + "github.com/docker/docker/pkg/testutil/assert" +) + +func TestExtWindows(t *testing.T) { + assert.Equal(t, ext("windows"), ".exe") +} + +func TestExtOthers(t *testing.T) { + assert.Equal(t, ext("linux"), "") +} diff --git a/pipeline/compress/zip.go b/pipeline/compress/zip.go index 16deaf5c2..fff42f1b2 100644 --- a/pipeline/compress/zip.go +++ b/pipeline/compress/zip.go @@ -51,7 +51,7 @@ func create(system, arch string, config config.ProjectConfig) error { return err } } - if err := addFile(tw, config.BinaryName, binaryName(system, arch, config.BinaryName)); err != nil { + if err := addFile(tw, config.BinaryName+ext(system), binaryPath(system, arch, config.BinaryName)); err != nil { return err } return nil @@ -85,6 +85,13 @@ func nameFor(system, arch, binary string) string { return binary + "_" + uname.FromGo(system) + "_" + uname.FromGo(arch) } -func binaryName(system, arch, binary string) string { +func binaryPath(system, arch, binary string) string { return "dist/" + nameFor(system, arch, binary) + "/" + binary } + +func ext(system string) string { + if system == "windows" { + return ".exe" + } + return "" +}