mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
feat: support tgz and txz as archive formats
We support `.tar.gz` since the beginning, and `.tar.xz` for a long time. `.tgz` and `.txz` are just commonly used shorthands for the same formats. Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
00d16bb51d
commit
c41d6de833
@ -23,13 +23,13 @@ type Archive interface {
|
||||
// New archive.
|
||||
func New(w io.Writer, format string) (Archive, error) {
|
||||
switch format {
|
||||
case "tar.gz":
|
||||
case "tar.gz", "tgz":
|
||||
return targz.New(w), nil
|
||||
case "tar":
|
||||
return tar.New(w), nil
|
||||
case "gz":
|
||||
return gzip.New(w), nil
|
||||
case "tar.xz":
|
||||
case "tar.xz", "txz":
|
||||
return tarxz.New(w), nil
|
||||
case "zip":
|
||||
return zip.New(w), nil
|
||||
|
@ -18,7 +18,7 @@ func TestArchive(t *testing.T) {
|
||||
require.NoError(t, empty.Close())
|
||||
require.NoError(t, os.Mkdir(folder+"/folder-inside", 0o755))
|
||||
|
||||
for _, format := range []string{"tar.gz", "zip", "gz", "tar.xz", "tar"} {
|
||||
for _, format := range []string{"tar.gz", "zip", "gz", "tar.xz", "tar", "tgz", "txz"} {
|
||||
format := format
|
||||
t.Run(format, func(t *testing.T) {
|
||||
f1, err := os.Create(filepath.Join(t.TempDir(), "1.tar"))
|
||||
@ -37,7 +37,7 @@ func TestArchive(t *testing.T) {
|
||||
require.NoError(t, archive.Close())
|
||||
require.NoError(t, f1.Close())
|
||||
|
||||
if format == "tar.xz" || format == "gz" {
|
||||
if format == "tar.xz" || format == "txz" || format == "gz" {
|
||||
_, err := Copying(f1, io.Discard, format)
|
||||
require.Error(t, err)
|
||||
return
|
||||
|
@ -447,7 +447,7 @@ func (bh Hook) JSONSchema() *jsonschema.Schema {
|
||||
// FormatOverride is used to specify a custom format for a specific GOOS.
|
||||
type FormatOverride struct {
|
||||
Goos string `yaml:"goos,omitempty" json:"goos,omitempty"`
|
||||
Format string `yaml:"format,omitempty" json:"format,omitempty"`
|
||||
Format string `yaml:"format,omitempty" json:"format,omitempty" jsonschema:"enum=tar,enum=tgz,enum=tar.gz,enum=zip,enum=gz,enum=tar.xz,enum=txz,default=tar.gz"`
|
||||
}
|
||||
|
||||
// File is a file inside an archive.
|
||||
@ -516,7 +516,7 @@ type Archive struct {
|
||||
BuildsInfo FileInfo `yaml:"builds_info,omitempty" json:"builds_info,omitempty"`
|
||||
NameTemplate string `yaml:"name_template,omitempty" json:"name_template,omitempty"`
|
||||
Replacements map[string]string `yaml:"replacements,omitempty" json:"replacements,omitempty"` // Deprecated: use templates instead
|
||||
Format string `yaml:"format,omitempty" json:"format,omitempty"`
|
||||
Format string `yaml:"format,omitempty" json:"format,omitempty" jsonschema:"enum=tar,enum=tgz,enum=tar.gz,enum=zip,enum=gz,enum=tar.xz,enum=txz,default=tar.gz"`
|
||||
FormatOverrides []FormatOverride `yaml:"format_overrides,omitempty" json:"format_overrides,omitempty"`
|
||||
WrapInDirectory string `yaml:"wrap_in_directory,omitempty" json:"wrap_in_directory,omitempty" jsonschema:"oneof_type=string;boolean"`
|
||||
StripParentBinaryFolder bool `yaml:"strip_parent_binary_folder,omitempty" json:"strip_parent_binary_folder,omitempty"`
|
||||
|
@ -19,7 +19,7 @@ archives:
|
||||
builds:
|
||||
- default
|
||||
|
||||
# Archive format. Valid options are `tar.gz`, `tar.xz`, `tar`, `gz`, `zip` and `binary`.
|
||||
# Archive format. Valid options are `tar.gz`, `tgz`, `tar.xz`, `txz`, tar`, `gz`, `zip` and `binary`.
|
||||
# If format is `binary`, no archives are created and the binaries are instead
|
||||
# uploaded directly.
|
||||
#
|
||||
@ -36,10 +36,10 @@ archives:
|
||||
# Archive name.
|
||||
#
|
||||
# Default:
|
||||
# - if format is `tar.gz`, `tar.xz`, `gz` or `zip`:
|
||||
# - `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}`
|
||||
# - if format is `binary`:
|
||||
# - `{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}`
|
||||
# - if format is anything else:
|
||||
# - `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}`
|
||||
# Templates: allowed
|
||||
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
|
||||
|
||||
|
9
www/docs/static/schema-pro.json
generated
vendored
9
www/docs/static/schema-pro.json
generated
vendored
@ -3108,7 +3108,14 @@
|
||||
"type": "string"
|
||||
},
|
||||
"format": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"tar",
|
||||
"tgz",
|
||||
"tar.gz",
|
||||
"zip"
|
||||
],
|
||||
"default": "tar.gz"
|
||||
},
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
|
24
www/docs/static/schema.json
generated
vendored
24
www/docs/static/schema.json
generated
vendored
@ -184,7 +184,17 @@
|
||||
"type": "object"
|
||||
},
|
||||
"format": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"tar",
|
||||
"tgz",
|
||||
"tar.gz",
|
||||
"zip",
|
||||
"gz",
|
||||
"tar.xz",
|
||||
"txz"
|
||||
],
|
||||
"default": "tar.gz"
|
||||
},
|
||||
"format_overrides": {
|
||||
"items": {
|
||||
@ -987,7 +997,17 @@
|
||||
"type": "string"
|
||||
},
|
||||
"format": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"tar",
|
||||
"tgz",
|
||||
"tar.gz",
|
||||
"zip",
|
||||
"gz",
|
||||
"tar.xz",
|
||||
"txz"
|
||||
],
|
||||
"default": "tar.gz"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user