mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
5d9110ab43
Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
38 lines
912 B
Go
38 lines
912 B
Go
// Package archive provides tar.gz and zip archiving
|
|
package archive
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/archive/gzip"
|
|
"github.com/goreleaser/goreleaser/pkg/archive/tar"
|
|
"github.com/goreleaser/goreleaser/pkg/archive/targz"
|
|
"github.com/goreleaser/goreleaser/pkg/archive/tarxz"
|
|
"github.com/goreleaser/goreleaser/pkg/archive/zip"
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
)
|
|
|
|
// Archive represents a compression archive files from disk can be written to.
|
|
type Archive interface {
|
|
Close() error
|
|
Add(f config.File) error
|
|
}
|
|
|
|
// New archive.
|
|
func New(w io.Writer, format string) (Archive, error) {
|
|
switch format {
|
|
case "tar.gz":
|
|
return targz.New(w), nil
|
|
case "tar":
|
|
return tar.New(w), nil
|
|
case "gz":
|
|
return gzip.New(w), nil
|
|
case "tar.xz":
|
|
return tarxz.New(w), nil
|
|
case "zip":
|
|
return zip.New(w), nil
|
|
}
|
|
return nil, fmt.Errorf("invalid archive format: %s", format)
|
|
}
|