mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
32fd1e158c
* refactor: merging archive in the same repo * refactor: merging archive in the same repo
28 lines
634 B
Go
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)
|
|
}
|