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 32fd1e158c
refactor: merging archive in the same repo (#746)
* refactor: merging archive in the same repo

* refactor: merging archive in the same repo
2018-08-05 10:23:39 -03:00

28 lines
634 B
Go

// Package archive provides tar.gz and zip archiving
package archive
import (
"os"
"path/filepath"
"github.com/goreleaser/goreleaser/pkg/archive/tar"
"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
// If the exentions of the target file is .zip, the archive will be in the zip
// format, otherwise, it will be a tar.gz archive.
func New(file *os.File) Archive {
if filepath.Ext(file.Name()) == ".zip" {
return zip.New(file)
}
return tar.New(file)
}