all: build Windows protoc-gen-go as a .exe in a zip

Add a .exe suffix to the protoc-gen-go Windows binary.
Use zip instead of tar for the Windows release archive.

Fixes golang/protobuf#1323

Change-Id: If42fa6dfd8b5496148310fa2a3359161f1124229
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/321530
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/integration_test.go b/integration_test.go
index 4587ffb..dfcfd10 100644
--- a/integration_test.go
+++ b/integration_test.go
@@ -8,6 +8,7 @@
 
 import (
 	"archive/tar"
+	"archive/zip"
 	"bytes"
 	"compress/gzip"
 	"crypto/sha256"
@@ -392,18 +393,31 @@
 						t.Fatal(err)
 					}
 					out := new(bytes.Buffer)
-					gz, _ := gzip.NewWriterLevel(out, gzip.BestCompression)
-					gz.Comment = fmt.Sprintf("protoc-gen-go VERSION=%v GOOS=%v GOARCH=%v", v, goos, goarch)
-					tw := tar.NewWriter(gz)
-					tw.WriteHeader(&tar.Header{
-						Name: "protoc-gen-go",
-						Mode: int64(0775),
-						Size: int64(len(in)),
-					})
-					tw.Write(in)
-					tw.Close()
-					gz.Close()
-					if err := ioutil.WriteFile(binPath+".tar.gz", out.Bytes(), 0664); err != nil {
+					suffix := ""
+					comment := fmt.Sprintf("protoc-gen-go VERSION=%v GOOS=%v GOARCH=%v", v, goos, goarch)
+					switch goos {
+					case "windows":
+						suffix = ".zip"
+						zw := zip.NewWriter(out)
+						zw.SetComment(comment)
+						fw, _ := zw.Create("protoc-gen-go.exe")
+						fw.Write(in)
+						zw.Close()
+					default:
+						suffix = ".tar.gz"
+						gz, _ := gzip.NewWriterLevel(out, gzip.BestCompression)
+						gz.Comment = comment
+						tw := tar.NewWriter(gz)
+						tw.WriteHeader(&tar.Header{
+							Name: "protoc-gen-go",
+							Mode: int64(0775),
+							Size: int64(len(in)),
+						})
+						tw.Write(in)
+						tw.Close()
+						gz.Close()
+					}
+					if err := ioutil.WriteFile(binPath+suffix, out.Bytes(), 0664); err != nil {
 						t.Fatal(err)
 					}
 				}