1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/pkg/archive/archive.go
Carlos Alexandro Becker d2fa6d5821
feat: support gzip format (#959)
* feat: support gzip format

* fix: wrong .gz detection

* docs: gz + multiple build
2019-02-07 12:12:20 -02:00

32 lines
705 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/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(), ".zip") {
return zip.New(file)
}
return targz.New(file)
}