Skip to content

Commit c926e21

Browse files
committed
build(release): enable DEFLATE compression
1 parent 10090bb commit c926e21

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

script/release.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"archive/zip"
5+
"compress/flate"
56
"crypto/sha256"
67
"encoding/hex"
78
"errors"
@@ -15,6 +16,7 @@ import (
1516

1617
const (
1718
checksumFilename = "SHA256SUMS.txt"
19+
deflateLevel = 6
1820
dirPerms = 0o755
1921
distDir = "dist"
2022
filePerms = 0o644
@@ -159,6 +161,9 @@ func zipDirectory(zipPath, dirPath string) error {
159161
defer zipFile.Close()
160162

161163
zipWriter := zip.NewWriter(zipFile)
164+
zipWriter.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
165+
return flate.NewWriter(out, deflateLevel)
166+
})
162167
defer zipWriter.Close()
163168

164169
err = filepath.Walk(dirPath, func(path string, info fs.FileInfo, err error) error {
@@ -221,7 +226,7 @@ func appendChecksum(checksumFilePath, filePath string) error {
221226

222227
relPath, err := filepath.Rel(filepath.Dir(checksumFilePath), filePath)
223228
if err != nil {
224-
return fmt.Errorf("failed to get relative path: %v", err)
229+
return fmt.Errorf("failed to get relative path: %v", err)
225230
}
226231
checksumLine := fmt.Sprintf("%s %s\n", hash, relPath)
227232

0 commit comments

Comments
 (0)