Skip to content

Commit

Permalink
build(release): enable DEFLATE compression
Browse files Browse the repository at this point in the history
  • Loading branch information
dbohdan committed Feb 20, 2025
1 parent 10090bb commit c926e21
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion script/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"archive/zip"
"compress/flate"
"crypto/sha256"
"encoding/hex"
"errors"
Expand All @@ -15,6 +16,7 @@ import (

const (
checksumFilename = "SHA256SUMS.txt"
deflateLevel = 6
dirPerms = 0o755
distDir = "dist"
filePerms = 0o644
Expand Down Expand Up @@ -159,6 +161,9 @@ func zipDirectory(zipPath, dirPath string) error {
defer zipFile.Close()

zipWriter := zip.NewWriter(zipFile)
zipWriter.RegisterCompressor(zip.Deflate, func(out io.Writer) (io.WriteCloser, error) {
return flate.NewWriter(out, deflateLevel)
})
defer zipWriter.Close()

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

relPath, err := filepath.Rel(filepath.Dir(checksumFilePath), filePath)
if err != nil {
return fmt.Errorf("failed to get relative path: %v", err)
return fmt.Errorf("failed to get relative path: %v", err)
}
checksumLine := fmt.Sprintf("%s %s\n", hash, relPath)

Expand Down

0 comments on commit c926e21

Please sign in to comment.