1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pkg/archive/archive.go
Carlos Alexandro Becker 73641c71ac
feat: file mappings in archives (#2347)
* refactor: archive files

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* feat: better archives

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* feat: better archives

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: test todos

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: go mod tidy et al

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: improve docs and remove typoe 'licence' from defaults

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* test: fixes

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* fix: error string

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* test: remove some logs

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* test: use utc

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2021-07-21 22:09:02 -03:00

37 lines
878 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/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(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(), ".tar.xz") {
return tarxz.New(file)
}
if strings.HasSuffix(file.Name(), ".zip") {
return zip.New(file)
}
return targz.New(file)
}