-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
executable file
·60 lines (51 loc) · 1.11 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"archive/zip"
"compress/flate"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
)
// this package creates the release zip file
func main() {
fullpath, _ := filepath.Abs("../build/auto_win_10_conf.zip")
outFile, err := os.Create(fullpath)
if err != nil {
log.Fatal(err)
}
defer outFile.Close()
// Create a new zip
w := zip.NewWriter(outFile)
// compress the zip
w.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
return flate.NewWriter(out, flate.BestCompression)
})
// files to write
var files = []struct {
Name, Body string
}{
{"config.json", "../build/config.json"},
{"setup.exe", "../build/setup.exe"},
}
// write the files to the zip
for _, file := range files {
f, err := w.Create(file.Name)
if err != nil {
log.Fatal(err)
}
FileContents, err := ioutil.ReadFile(file.Body)
_, err = f.Write(FileContents)
if err != nil {
log.Fatal(err)
}
}
// close the zip
err = w.Close()
if err != nil {
log.Fatal(err)
}
fmt.Println("Created release zip file")
}