1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-20 03:59:26 +02:00
goreleaser/pkg/archive/archive.go
J Taylor 081430bcc7
feat: xz compression (#1422)
* feat: xz compression

* remove .xz feature

* fix: format code with gofmt

* use larger dict for better compression

* Update pkg/archive/tarxz/tarxz.go

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2020-04-13 12:53:03 +00:00

36 lines
835 B
Go

// Package archive provides tar.gz and zip archiving
package archive
import (
"os"
"strings"
"github.com/goreleaser/goreleaser/pkg/archive/gzip"
"github.com/goreleaser/goreleaser/pkg/archive/targz"
"github.com/goreleaser/goreleaser/pkg/archive/tarxz"
"github.com/goreleaser/goreleaser/pkg/archive/zip"
)
// Archive represents a compression archive files from disk can be written to.
type Archive interface {
Close() error
Add(name, path string) error
}
// New archive.
func New(file *os.File) Archive {
if strings.HasSuffix(file.Name(), ".tar.gz") {
return targz.New(file)
}
if strings.HasSuffix(file.Name(), ".gz") {
return gzip.New(file)
}
if strings.HasSuffix(file.Name(), ".tar.xz") {
return tarxz.New(file)
}
if strings.HasSuffix(file.Name(), ".zip") {
return zip.New(file)
}
return targz.New(file)
}