diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d7e81b667ad..772436a4957 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -129,13 +129,13 @@ docker_manifests: - 'ghcr.io/goreleaser/goreleaser:{{ .Tag }}-arm64' archives: - - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 + - name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }}' format_overrides: - goos: windows format: zip diff --git a/cmd/init.go b/cmd/init.go index eeba3e54155..d7134a9de8a 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -31,7 +31,7 @@ func newInitCmd() *initCmd { defer conf.Close() log.Infof(boldStyle.Render(fmt.Sprintf("Generating %s file", root.config))) - if _, err := conf.WriteString(static.ExampleConfig); err != nil { + if _, err := conf.Write(static.ExampleConfig); err != nil { return err } diff --git a/cmd/testdata/good.yml b/cmd/testdata/good.yml index ad179f8cc21..4641e27d570 100644 --- a/cmd/testdata/good.yml +++ b/cmd/testdata/good.yml @@ -9,13 +9,6 @@ before: builds: - env: - CGO_ENABLED=0 -archives: -- replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 checksum: name_template: 'checksums.txt' snapshot: diff --git a/internal/builders/golang/build.go b/internal/builders/golang/build.go index 6c53b2eff36..f2c8e329ce4 100644 --- a/internal/builders/golang/build.go +++ b/internal/builders/golang/build.go @@ -186,7 +186,7 @@ func (*Builder) Build(ctx *context.Context, build config.Build, options api.Opti } if build.ModTimestamp != "" { - modTimestamp, err := tmpl.New(ctx).WithEnvS(env).WithArtifact(a, map[string]string{}).Apply(build.ModTimestamp) + modTimestamp, err := tmpl.New(ctx).WithEnvS(env).WithArtifact(a).Apply(build.ModTimestamp) if err != nil { return err } @@ -314,7 +314,7 @@ func processFlags(ctx *context.Context, a *artifact.Artifact, env, flags []strin } func processFlag(ctx *context.Context, a *artifact.Artifact, env []string, rawFlag string) (string, error) { - return tmpl.New(ctx).WithEnvS(env).WithArtifact(a, map[string]string{}).Apply(rawFlag) + return tmpl.New(ctx).WithEnvS(env).WithArtifact(a).Apply(rawFlag) } func run(ctx *context.Context, command, env []string, dir string) error { diff --git a/internal/builders/golang/build_test.go b/internal/builders/golang/build_test.go index 4ddfe5a75da..0d683540405 100644 --- a/internal/builders/golang/build_test.go +++ b/internal/builders/golang/build_test.go @@ -898,7 +898,7 @@ func TestLdFlagsFullTemplate(t *testing.T) { Env: map[string]string{"FOO": "123"}, } artifact := &artifact.Artifact{Goarch: "amd64"} - flags, err := tmpl.New(ctx).WithArtifact(artifact, map[string]string{}). + flags, err := tmpl.New(ctx).WithArtifact(artifact). Apply(`-s -w -X main.version={{.Version}} -X main.tag={{.Tag}} -X main.date={{.Date}} -X main.commit={{.Commit}} -X "main.foo={{.Env.FOO}}" -X main.time={{ time "20060102" }} -X main.arch={{.Arch}} -X main.commitDate={{.CommitDate}}`) require.NoError(t, err) require.Contains(t, flags, "-s -w") diff --git a/internal/exec/exec.go b/internal/exec/exec.go index 296a8ff1161..30ab40cd63e 100644 --- a/internal/exec/exec.go +++ b/internal/exec/exec.go @@ -155,16 +155,19 @@ func resolveCommand(ctx *context.Context, publisher config.Publisher, artifact * replacements := make(map[string]string) // TODO: Replacements should be associated only with relevant artifacts/archives + // this is pretty much all wrong and will be removed soon. archives := ctx.Config.Archives if len(archives) > 0 { replacements = archives[0].Replacements } dir := publisher.Dir + + // nolint:staticcheck + tpl := tmpl.New(ctx). + WithArtifactReplacements(artifact, replacements) if dir != "" { - dir, err = tmpl.New(ctx). - WithArtifact(artifact, replacements). - Apply(dir) + dir, err = tpl.Apply(dir) if err != nil { return nil, err } @@ -172,9 +175,7 @@ func resolveCommand(ctx *context.Context, publisher config.Publisher, artifact * cmd := publisher.Cmd if cmd != "" { - cmd, err = tmpl.New(ctx). - WithArtifact(artifact, replacements). - Apply(cmd) + cmd, err = tpl.Apply(cmd) if err != nil { return nil, err } @@ -187,9 +188,7 @@ func resolveCommand(ctx *context.Context, publisher config.Publisher, artifact * env := make([]string, len(publisher.Env)) for i, e := range publisher.Env { - e, err = tmpl.New(ctx). - WithArtifact(artifact, replacements). - Apply(e) + e, err = tpl.Apply(e) if err != nil { return nil, err } diff --git a/internal/http/http.go b/internal/http/http.go index 148c81435e5..880217c2237 100644 --- a/internal/http/http.go +++ b/internal/http/http.go @@ -386,10 +386,13 @@ func resolveTargetTemplate(ctx *context.Context, upload *config.Upload, artifact replacements := map[string]string{} if upload.Mode == ModeBinary { // TODO: multiple archives here + // will be removed soon anyway replacements = ctx.Config.Archives[0].Replacements } + + // nolint:staticcheck return tmpl.New(ctx). - WithArtifact(artifact, replacements). + WithArtifactReplacements(artifact, replacements). Apply(upload.Target) } @@ -399,9 +402,11 @@ func resolveHeaderTemplate(ctx *context.Context, upload *config.Upload, artifact replacements := map[string]string{} if upload.Mode == ModeBinary { // TODO: multiple archives here + // will be removed soon anyway replacements = ctx.Config.Archives[0].Replacements } + // nolint:staticcheck return tmpl.New(ctx). - WithArtifact(artifact, replacements). + WithArtifactReplacements(artifact, replacements). Apply(headerValue) } diff --git a/internal/pipe/archive/archive.go b/internal/pipe/archive/archive.go index 4b20472e638..efea0c78582 100644 --- a/internal/pipe/archive/archive.go +++ b/internal/pipe/archive/archive.go @@ -15,6 +15,7 @@ import ( "github.com/caarlos0/log" "github.com/goreleaser/goreleaser/internal/archivefiles" "github.com/goreleaser/goreleaser/internal/artifact" + "github.com/goreleaser/goreleaser/internal/deprecate" "github.com/goreleaser/goreleaser/internal/ids" "github.com/goreleaser/goreleaser/internal/semerrgroup" "github.com/goreleaser/goreleaser/internal/tmpl" @@ -74,6 +75,9 @@ func (Pipe) Default(ctx *context.Context) error { archive.NameTemplate = defaultBinaryNameTemplate } } + if len(archive.Replacements) != 0 { + deprecate.Notice(ctx, "archives.replacements") + } ids.Inc(archive.ID) } return ids.Validate() @@ -138,7 +142,8 @@ func createMeta(ctx *context.Context, arch config.Archive) error { } func create(ctx *context.Context, arch config.Archive, binaries []*artifact.Artifact) error { - template := tmpl.New(ctx).WithArtifact(binaries[0], arch.Replacements) + // nolint:staticcheck + template := tmpl.New(ctx).WithArtifactReplacements(binaries[0], arch.Replacements) format := packageFormat(arch, binaries[0].Goos) return doCreate(ctx, arch, binaries, format, template) } @@ -244,8 +249,9 @@ func wrapFolder(a config.Archive) string { func skip(ctx *context.Context, archive config.Archive, binaries []*artifact.Artifact) error { for _, binary := range binaries { + // nolint:staticcheck name, err := tmpl.New(ctx). - WithArtifact(binary, archive.Replacements). + WithArtifactReplacements(binary, archive.Replacements). Apply(archive.NameTemplate) if err != nil { return err diff --git a/internal/pipe/aur/aur.go b/internal/pipe/aur/aur.go index d8bb6a5be9e..93f2ca18367 100644 --- a/internal/pipe/aur/aur.go +++ b/internal/pipe/aur/aur.go @@ -311,7 +311,7 @@ func dataFor(ctx *context.Context, cfg config.AUR, cl client.Client, artifacts [ } cfg.URLTemplate = url } - url, err := tmpl.New(ctx).WithArtifact(art, map[string]string{}).Apply(cfg.URLTemplate) + url, err := tmpl.New(ctx).WithArtifact(art).Apply(cfg.URLTemplate) if err != nil { return result, err } diff --git a/internal/pipe/brew/brew.go b/internal/pipe/brew/brew.go index 85f5f3c50dc..fd916fef01f 100644 --- a/internal/pipe/brew/brew.go +++ b/internal/pipe/brew/brew.go @@ -347,7 +347,7 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifa cfg.URLTemplate = url } - url, err := tmpl.New(ctx).WithArtifact(art, map[string]string{}).Apply(cfg.URLTemplate) + url, err := tmpl.New(ctx).WithArtifact(art).Apply(cfg.URLTemplate) if err != nil { return result, err } diff --git a/internal/pipe/chocolatey/chocolatey.go b/internal/pipe/chocolatey/chocolatey.go index bf0a47cce15..f7c57bb2326 100644 --- a/internal/pipe/chocolatey/chocolatey.go +++ b/internal/pipe/chocolatey/chocolatey.go @@ -302,9 +302,7 @@ func dataFor(ctx *context.Context, cl client.Client, choco config.Chocolatey, ar return result, err } - url, err := tmpl.New(ctx). - WithArtifact(artifact, map[string]string{}). - Apply(choco.URLTemplate) + url, err := tmpl.New(ctx).WithArtifact(artifact).Apply(choco.URLTemplate) if err != nil { return result, err } diff --git a/internal/pipe/krew/krew.go b/internal/pipe/krew/krew.go index 5bab918eb0b..f9183181793 100644 --- a/internal/pipe/krew/krew.go +++ b/internal/pipe/krew/krew.go @@ -222,7 +222,7 @@ func manifestFor(ctx *context.Context, cfg config.Krew, cl client.Client, artifa } cfg.URLTemplate = url } - url, err := tmpl.New(ctx).WithArtifact(art, map[string]string{}).Apply(cfg.URLTemplate) + url, err := tmpl.New(ctx).WithArtifact(art).Apply(cfg.URLTemplate) if err != nil { return result, err } diff --git a/internal/pipe/nfpm/nfpm.go b/internal/pipe/nfpm/nfpm.go index 186c728fea2..efd3767adf0 100644 --- a/internal/pipe/nfpm/nfpm.go +++ b/internal/pipe/nfpm/nfpm.go @@ -59,6 +59,9 @@ func (Pipe) Default(ctx *context.Context) error { if fpm.Maintainer == "" { deprecate.NoticeCustom(ctx, "nfpms.maintainer", "`{{ .Property }}` should always be set, check {{ .URL }} for more info") } + if len(fpm.Replacements) != 0 { + deprecate.Notice(ctx, "nfpms.replacements") + } ids.Inc(fpm.ID) } @@ -166,8 +169,9 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar if err != nil { return err } + // nolint:staticcheck t := tmpl.New(ctx). - WithArtifact(binaries[0], overridden.Replacements). + WithArtifactReplacements(binaries[0], overridden.Replacements). WithExtraFields(tmpl.Fields{ "Release": fpm.Release, "Epoch": fpm.Epoch, diff --git a/internal/pipe/sbom/sbom.go b/internal/pipe/sbom/sbom.go index 6784baf9025..9e7f30da52d 100644 --- a/internal/pipe/sbom/sbom.go +++ b/internal/pipe/sbom/sbom.go @@ -238,8 +238,7 @@ func applyTemplate(ctx *context.Context, cfg config.SBOM, a *artifact.Artifact) } extraEnvs = appendExtraEnv("artifact", procPath, extraEnvs, env) extraEnvs = appendExtraEnv("artifactID", a.ID(), extraEnvs, env) - - templater = templater.WithArtifact(a, nil) + templater = templater.WithArtifact(a) } for _, keyValue := range cfg.Env { diff --git a/internal/pipe/scoop/scoop.go b/internal/pipe/scoop/scoop.go index 912f3dd8f90..79747c06296 100644 --- a/internal/pipe/scoop/scoop.go +++ b/internal/pipe/scoop/scoop.go @@ -241,9 +241,7 @@ func dataFor(ctx *context.Context, cl client.Client, artifacts []*artifact.Artif continue } - url, err := tmpl.New(ctx). - WithArtifact(artifact, map[string]string{}). - Apply(ctx.Config.Scoop.URLTemplate) + url, err := tmpl.New(ctx).WithArtifact(artifact).Apply(ctx.Config.Scoop.URLTemplate) if err != nil { return manifest, err } diff --git a/internal/pipe/snapcraft/snapcraft.go b/internal/pipe/snapcraft/snapcraft.go index be6e54cdf86..c45b205d77e 100644 --- a/internal/pipe/snapcraft/snapcraft.go +++ b/internal/pipe/snapcraft/snapcraft.go @@ -13,6 +13,7 @@ import ( "github.com/caarlos0/log" "github.com/goreleaser/goreleaser/internal/artifact" + "github.com/goreleaser/goreleaser/internal/deprecate" "github.com/goreleaser/goreleaser/internal/gio" "github.com/goreleaser/goreleaser/internal/ids" "github.com/goreleaser/goreleaser/internal/pipe" @@ -122,6 +123,9 @@ func (Pipe) Default(ctx *context.Context) error { snap.Builds = append(snap.Builds, b.ID) } } + if len(snap.Replacements) != 0 { + deprecate.Notice(ctx, "snapcrafts.replacements") + } ids.Inc(snap.ID) } return ids.Validate() @@ -211,8 +215,9 @@ func (Pipe) Publish(ctx *context.Context) error { func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries []*artifact.Artifact) error { log := log.WithField("arch", arch) + // nolint:staticcheck folder, err := tmpl.New(ctx). - WithArtifact(binaries[0], snap.Replacements). + WithArtifactReplacements(binaries[0], snap.Replacements). Apply(snap.NameTemplate) if err != nil { return err diff --git a/internal/static/config.go b/internal/static/config.go index 7538744d117..84672dbae2a 100644 --- a/internal/static/config.go +++ b/internal/static/config.go @@ -1,43 +1,9 @@ -// Package static contains static "text" files, just because embedding real -// static files would be kind of an overengineering right now, so it's just -// strings in go code really. +// Package static contains static "text" files. package static -// ExampleConfig is the config used within goreleaser init. -const ExampleConfig = `# This is an example .goreleaser.yml file with some sensible defaults. -# Make sure to check the documentation at https://goreleaser.com -before: - hooks: - # You may remove this if you don't use go modules. - - go mod tidy - # you may remove this if you don't need go generate - - go generate ./... -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - - windows - - darwin -archives: - - replacements: - darwin: Darwin - linux: Linux - windows: Windows - 386: i386 - amd64: x86_64 -checksum: - name_template: 'checksums.txt' -snapshot: - name_template: "{{ incpatch .Version }}-next" -changelog: - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' +import _ "embed" -# modelines, feel free to remove those if you don't want/use them: -# yaml-language-server: $schema=https://goreleaser.com/static/schema.json -# vim: set ts=2 sw=2 tw=0 fo=cnqoj -` +// ExampleConfig is the config used within goreleaser init. +// +//go:embed config.yaml +var ExampleConfig []byte diff --git a/internal/static/config.yaml b/internal/static/config.yaml new file mode 100644 index 00000000000..d24c44bd546 --- /dev/null +++ b/internal/static/config.yaml @@ -0,0 +1,44 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }}' + # use zip for windows archives + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +# modelines, feel free to remove those if you don't want/use them: +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/internal/static/config_test.go b/internal/static/config_test.go index b54868badd4..65905c4af19 100644 --- a/internal/static/config_test.go +++ b/internal/static/config_test.go @@ -1,7 +1,7 @@ package static import ( - "strings" + "bytes" "testing" "github.com/goreleaser/goreleaser/pkg/config" @@ -9,6 +9,7 @@ import ( ) func TestExampleConfig(t *testing.T) { - _, err := config.LoadReader(strings.NewReader(ExampleConfig)) + _, err := config.LoadReader(bytes.NewReader(ExampleConfig)) require.NoError(t, err) + require.NotEmpty(t, ExampleConfig) } diff --git a/internal/tmpl/tmpl.go b/internal/tmpl/tmpl.go index 1fda16039a6..2b179edfdf2 100644 --- a/internal/tmpl/tmpl.go +++ b/internal/tmpl/tmpl.go @@ -143,8 +143,10 @@ func (t *Template) WithExtraFields(f Fields) *Template { return t } -// WithArtifact populates Fields from the artifact and replacements. -func (t *Template) WithArtifact(a *artifact.Artifact, replacements map[string]string) *Template { +// WithArtifactReplacements populates Fields from the artifact and replacements. +// +// Deprecated: use WithArtifact instead. +func (t *Template) WithArtifactReplacements(a *artifact.Artifact, replacements map[string]string) *Template { t.fields[osKey] = replace(replacements, a.Goos) t.fields[arch] = replace(replacements, a.Goarch) t.fields[arm] = replace(replacements, a.Goarm) @@ -157,6 +159,20 @@ func (t *Template) WithArtifact(a *artifact.Artifact, replacements map[string]st return t } +// WithArtifact populates Fields from the artifact. +func (t *Template) WithArtifact(a *artifact.Artifact) *Template { + t.fields[osKey] = a.Goos + t.fields[arch] = a.Goarch + t.fields[arm] = a.Goarm + t.fields[mips] = a.Gomips + t.fields[amd64] = a.Goamd64 + t.fields[binary] = artifact.ExtraOr(*a, binary, t.fields[projectName].(string)) + t.fields[artifactName] = a.Name + t.fields[artifactExt] = artifact.ExtraOr(*a, artifact.ExtraExt, "") + t.fields[artifactPath] = a.Path + return t +} + func (t *Template) WithBuildOptions(opts build.Options) *Template { return t.WithExtraFields(buildOptsToFields(opts)) } @@ -243,6 +259,7 @@ func (t *Template) ApplySingleEnvOnly(s string) (string, error) { return out.String(), err } +// deprecated: will be removed soon. func replace(replacements map[string]string, original string) string { result := replacements[original] if result == "" { diff --git a/internal/tmpl/tmpl_test.go b/internal/tmpl/tmpl_test.go index bccb35ecc26..b334ccef916 100644 --- a/internal/tmpl/tmpl_test.go +++ b/internal/tmpl/tmpl_test.go @@ -80,7 +80,7 @@ func TestWithArtifact(t *testing.T) { expect := expect t.Run(expect, func(t *testing.T) { t.Parallel() - result, err := New(ctx).WithArtifact( + result, err := New(ctx).WithArtifactReplacements( &artifact.Artifact{ Name: "not-this-binary", Path: "/tmp/foo.exe", @@ -103,7 +103,7 @@ func TestWithArtifact(t *testing.T) { t.Run("artifact without binary name", func(t *testing.T) { t.Parallel() - result, err := New(ctx).WithArtifact( + result, err := New(ctx).WithArtifactReplacements( &artifact.Artifact{ Name: "another-binary", Goarch: "amd64", diff --git a/pkg/config/config.go b/pkg/config/config.go index 95ceaf8d32e..f745f82c87c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -476,7 +476,7 @@ type Archive struct { ID string `yaml:"id,omitempty" json:"id,omitempty"` Builds []string `yaml:"builds,omitempty" json:"builds,omitempty"` NameTemplate string `yaml:"name_template,omitempty" json:"name_template,omitempty"` - Replacements map[string]string `yaml:"replacements,omitempty" json:"replacements,omitempty"` + Replacements map[string]string `yaml:"replacements,omitempty" json:"replacements,omitempty"` // Deprecated: use templates instead Format string `yaml:"format,omitempty" json:"format,omitempty"` 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"` @@ -654,7 +654,7 @@ type NFPMOverridables struct { Release string `yaml:"release,omitempty" json:"release,omitempty"` Prerelease string `yaml:"prerelease,omitempty" json:"prerelease,omitempty"` VersionMetadata string `yaml:"version_metadata,omitempty" json:"version_metadata,omitempty"` - Replacements map[string]string `yaml:"replacements,omitempty" json:"replacements,omitempty"` + Replacements map[string]string `yaml:"replacements,omitempty" json:"replacements,omitempty"` // Deprecated: use templates instead Dependencies []string `yaml:"dependencies,omitempty" json:"dependencies,omitempty"` Recommends []string `yaml:"recommends,omitempty" json:"recommends,omitempty"` Suggests []string `yaml:"suggests,omitempty" json:"suggests,omitempty"` @@ -741,7 +741,7 @@ type SnapcraftLayoutMetadata struct { // Snapcraft config. type Snapcraft struct { NameTemplate string `yaml:"name_template,omitempty" json:"name_template,omitempty"` - Replacements map[string]string `yaml:"replacements,omitempty" json:"replacements,omitempty"` + Replacements map[string]string `yaml:"replacements,omitempty" json:"replacements,omitempty"` // Deprecated: use templates instead. Publish bool `yaml:"publish,omitempty" json:"publish,omitempty"` ID string `yaml:"id,omitempty" json:"id,omitempty"` diff --git a/www/docs/customization/archive.md b/www/docs/customization/archive.md index 6b6d4ca41b5..230d05be8cd 100644 --- a/www/docs/customization/archive.md +++ b/www/docs/customization/archive.md @@ -40,16 +40,6 @@ archives: # - `{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}` name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" - # Replacements for GOOS and GOARCH in the archive name. - # Keys should be valid GOOSs or GOARCHs. - # Values are the respective replacements. - # Default is empty. - replacements: - amd64: 64-bit - 386: 32-bit - darwin: macOS - linux: Tux - # Set this to true if you want all files in the archive to be in a single directory. # If set to true and you extract the archive 'goreleaser_Linux_arm64.tar.gz', # you'll get a folder 'goreleaser_Linux_arm64'. diff --git a/www/docs/customization/nfpm.md b/www/docs/customization/nfpm.md index bff5201331c..d278ac933b2 100644 --- a/www/docs/customization/nfpm.md +++ b/www/docs/customization/nfpm.md @@ -29,16 +29,6 @@ nfpms: - foo - bar - # Replacements for GOOS and GOARCH in the package name. - # Keys should be valid GOOSs or GOARCHs. - # Values are the respective replacements. - # Default is empty. - replacements: - amd64: 64-bit - 386: 32-bit - darwin: macOS - linux: Tux - # Your app's vendor. # Default is empty. vendor: Drum Roll Inc. diff --git a/www/docs/customization/snapcraft.md b/www/docs/customization/snapcraft.md index 4abf0b0c4c0..c65303e2d0e 100644 --- a/www/docs/customization/snapcraft.md +++ b/www/docs/customization/snapcraft.md @@ -29,16 +29,6 @@ snapcrafts: # Default: `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}` name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" - # Replacements for GOOS and GOARCH in the package name. - # Keys should be valid GOOSs or GOARCHs. - # Values are the respective replacements. - # Default is empty. - replacements: - amd64: 64-bit - 386: 32-bit - darwin: macOS - linux: Tux - # The name of the snap. This is optional. # Default is project name. name: drumroll diff --git a/www/docs/deprecations.md b/www/docs/deprecations.md index 9c37e251a24..6ddd12a64b7 100644 --- a/www/docs/deprecations.md +++ b/www/docs/deprecations.md @@ -36,6 +36,125 @@ Description. --> +### archives.replacements + +> since 2022-11-24 (v1.14.0) + +The `replacements` will be removed soon from the archives section, as it was +never handled correctly when multiple archives were being used, and it also +causes confusion in other places. + +You can still get the same features by abusing the `name_template` property. + +=== "Before" + + ``` yaml + archives: + - id: foo + name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 + ``` + +=== "After" + ``` yaml + archives: + - id: foo + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + ``` + +Those two configurations will yield the same results. + + +### nfpms.replacements + +> since 2022-11-24 (v1.14.0) + +The `replacements` will be removed soon from the nFPMs section. + +You can still get the same features by abusing the `file_name_template` property. + +=== "Before" + + ``` yaml + nfpms: + - id: foo + file_name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 + ``` + +=== "After" + ``` yaml + nfpms: + - id: foo + file_name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + ``` + +Those two configurations will yield the same results. + +Generally speaking, is probably best to use `{{ .ConventionalFileName }}` +instead of custom templates. + +### snapcrafts.replacements + +> since 2022-11-24 (v1.14.0) + +The `replacements` will be removed soon from the Snapcrafts section. + +You can still get the same features by abusing the `name_template` property. + +=== "Before" + + ``` yaml + snapcrafts: + - id: foo + name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' + replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 + ``` + +=== "After" + ``` yaml + snapcrafts: + - id: foo + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + ``` + +Those two configurations will yield the same results. + +Generally speaking, is probably best to use `{{ .ConventionalFileName }}` +instead of custom templates. + + + ### nfpms.maintainer > since 2022-05-07 (v1.9.0)