mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
8858049a28
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
41 lines
768 B
Go
41 lines
768 B
Go
// Package tarxz implements the Archive interface providing tar.xz archiving
|
|
// and compression.
|
|
package tarxz
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/goreleaser/goreleaser/pkg/archive/tar"
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
"github.com/ulikunitz/xz"
|
|
)
|
|
|
|
// Archive as tar.xz.
|
|
type Archive struct {
|
|
xzw *xz.Writer
|
|
tw *tar.Archive
|
|
}
|
|
|
|
// Close all closeables.
|
|
func (a Archive) Close() error {
|
|
if err := a.tw.Close(); err != nil {
|
|
return err
|
|
}
|
|
return a.xzw.Close()
|
|
}
|
|
|
|
// New tar.xz archive.
|
|
func New(target io.Writer) Archive {
|
|
xzw, _ := xz.WriterConfig{DictCap: 16 * 1024 * 1024}.NewWriter(target)
|
|
tw := tar.New(xzw)
|
|
return Archive{
|
|
xzw: xzw,
|
|
tw: &tw,
|
|
}
|
|
}
|
|
|
|
// Add file to the archive.
|
|
func (a Archive) Add(f config.File) error {
|
|
return a.tw.Add(f)
|
|
}
|