1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-07-15 01:34:21 +02:00
BREAKING CHANGE

removed all deprecated options, config file should now have a `version:
2` bit


![Dont
Matter](https://github.com/goreleaser/goreleaser/assets/245435/31ece16a-cb70-4e43-9caa-8364e73fbeb9)

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2024-05-25 14:09:49 -03:00
committed by GitHub
parent 3e40af256c
commit 4fa8df6413
45 changed files with 331 additions and 572 deletions

View File

@ -27,10 +27,10 @@ func TestBuildSingleTarget(t *testing.T) {
func TestBuildInvalidConfig(t *testing.T) {
setup(t)
createFile(t, "goreleaser.yml", "foo: bar")
createFile(t, "goreleaser.yml", "version: 2\nfoo: bar")
cmd := newBuildCmd()
cmd.cmd.SetArgs([]string{"--snapshot", "--timeout=1m", "--parallelism=2", "--deprecated"})
require.EqualError(t, cmd.cmd.Execute(), "yaml: unmarshal errors:\n line 1: field foo not found in type config.Project")
require.EqualError(t, cmd.cmd.Execute(), "yaml: unmarshal errors:\n line 2: field foo not found in type config.Project")
}
func TestBuildBrokenProject(t *testing.T) {

View File

@ -37,7 +37,7 @@ func TestCheckConfigThatDoesNotExist(t *testing.T) {
func TestCheckConfigUnmarshalError(t *testing.T) {
cmd := newCheckCmd()
cmd.cmd.SetArgs([]string{"-f", "testdata/unmarshal_error.yml"})
require.EqualError(t, cmd.cmd.Execute(), "yaml: unmarshal errors:\n line 1: field foo not found in type config.Project")
require.EqualError(t, cmd.cmd.Execute(), "yaml: unmarshal errors:\n line 2: field foo not found in type config.Project")
require.Equal(t, 0, cmd.checked)
}

View File

@ -41,7 +41,7 @@ func TestReleaseAutoSnapshot(t *testing.T) {
func TestReleaseInvalidConfig(t *testing.T) {
setup(t)
createFile(t, "goreleaser.yml", "foo: bar")
createFile(t, "goreleaser.yml", "foo: bar\nversion: 2")
cmd := newReleaseCmd()
cmd.cmd.SetArgs([]string{"--snapshot", "--timeout=1m", "--parallelism=2", "--deprecated"})
require.EqualError(t, cmd.cmd.Execute(), "yaml: unmarshal errors:\n line 1: field foo not found in type config.Project")

View File

@ -1 +1,2 @@
version: 2
foo: bar

View File

@ -68,8 +68,8 @@ go 1.22
func createGoReleaserYaml(tb testing.TB) {
tb.Helper()
yaml := `build:
binary: fake
yaml := `builds:
- binary: fake
goos:
- linux
goarch:

View File

@ -386,7 +386,7 @@ func TestExtra(t *testing.T) {
Use: "docker",
},
"fail-plz": config.Homebrew{
Plist: "aaaa",
Service: "aaaa",
},
"unsupported": func() {},
"binaries": []string{"foo", "bar"},

View File

@ -15,7 +15,6 @@ 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"
@ -59,13 +58,6 @@ func (Pipe) Default(ctx *context.Context) error {
if archive.ID == "" {
archive.ID = "default"
}
if archive.StripParentBinaryFolder {
archive.StripBinaryDirectory = true
deprecate.Notice(ctx, "archives.strip_parent_binary_folder")
}
if archive.RLCP != "" && archive.Format != "binary" && len(archive.Files) > 0 {
deprecate.Notice(ctx, "archives.rlcp")
}
if len(archive.Files) == 0 {
archive.Files = []config.File{
{Source: "license*", Default: true},

View File

@ -4,7 +4,6 @@ package blob
import (
"fmt"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/semerrgroup"
"github.com/goreleaser/goreleaser/internal/tmpl"
@ -22,14 +21,9 @@ func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Blobs) == 0
func (Pipe) Default(ctx *context.Context) error {
for i := range ctx.Config.Blobs {
blob := &ctx.Config.Blobs[i]
if blob.Bucket == "" || blob.Provider == "" {
return fmt.Errorf("bucket or provider cannot be empty")
}
if blob.Folder != "" {
deprecate.Notice(ctx, "blobs.folder")
blob.Directory = blob.Folder
}
if blob.Directory == "" {
blob.Directory = "{{ .ProjectName }}/{{ .Tag }}"
}
@ -39,15 +33,6 @@ func (Pipe) Default(ctx *context.Context) error {
} else if blob.ContentDisposition == "-" {
blob.ContentDisposition = ""
}
if blob.OldDisableSSL {
deprecate.Notice(ctx, "blobs.disableSSL")
blob.DisableSSL = true
}
if blob.OldKMSKey != "" {
deprecate.Notice(ctx, "blobs.kmskey")
blob.KMSKey = blob.OldKMSKey
}
}
return nil
}

View File

@ -72,14 +72,14 @@ func TestMain(m *testing.M) {
func TestMinioUpload(t *testing.T) {
name := "basic"
folder := t.TempDir()
srcpath := filepath.Join(folder, "source.tar.gz")
tgzpath := filepath.Join(folder, "bin.tar.gz")
debpath := filepath.Join(folder, "bin.deb")
checkpath := filepath.Join(folder, "check.txt")
metapath := filepath.Join(folder, "metadata.json")
sigpath := filepath.Join(folder, "f.sig")
certpath := filepath.Join(folder, "f.pem")
directory := t.TempDir()
srcpath := filepath.Join(directory, "source.tar.gz")
tgzpath := filepath.Join(directory, "bin.tar.gz")
debpath := filepath.Join(directory, "bin.deb")
checkpath := filepath.Join(directory, "check.txt")
metapath := filepath.Join(directory, "metadata.json")
sigpath := filepath.Join(directory, "f.sig")
certpath := filepath.Join(directory, "f.pem")
require.NoError(t, os.WriteFile(checkpath, []byte("fake checksums"), 0o744))
require.NoError(t, os.WriteFile(metapath, []byte(`{"fake":true}`), 0o744))
require.NoError(t, os.WriteFile(srcpath, []byte("fake\nsrc"), 0o744))
@ -88,7 +88,7 @@ func TestMinioUpload(t *testing.T) {
require.NoError(t, os.WriteFile(sigpath, []byte("fake\nsig"), 0o744))
require.NoError(t, os.WriteFile(certpath, []byte("fake\ncert"), 0o744))
ctx := testctx.NewWithCfg(config.Project{
Dist: folder,
Dist: directory,
ProjectName: "testupload",
Blobs: []config.Blob{
{
@ -177,15 +177,15 @@ func TestMinioUpload(t *testing.T) {
func TestMinioUploadCustomBucketID(t *testing.T) {
name := "fromenv"
folder := t.TempDir()
tgzpath := filepath.Join(folder, "bin.tar.gz")
debpath := filepath.Join(folder, "bin.deb")
directory := t.TempDir()
tgzpath := filepath.Join(directory, "bin.tar.gz")
debpath := filepath.Join(directory, "bin.deb")
require.NoError(t, os.WriteFile(tgzpath, []byte("fake\ntargz"), 0o744))
require.NoError(t, os.WriteFile(debpath, []byte("fake\ndeb"), 0o744))
// Set custom BUCKET_ID env variable.
t.Setenv("BUCKET_ID", name)
ctx := testctx.NewWithCfg(config.Project{
Dist: folder,
Dist: directory,
ProjectName: "testupload",
Blobs: []config.Blob{
{
@ -211,21 +211,21 @@ func TestMinioUploadCustomBucketID(t *testing.T) {
require.NoError(t, Pipe{}.Publish(ctx))
}
func TestMinioUploadRootFolder(t *testing.T) {
func TestMinioUploadRootDirectory(t *testing.T) {
name := "rootdir"
folder := t.TempDir()
tgzpath := filepath.Join(folder, "bin.tar.gz")
debpath := filepath.Join(folder, "bin.deb")
directory := t.TempDir()
tgzpath := filepath.Join(directory, "bin.tar.gz")
debpath := filepath.Join(directory, "bin.deb")
require.NoError(t, os.WriteFile(tgzpath, []byte("fake\ntargz"), 0o744))
require.NoError(t, os.WriteFile(debpath, []byte("fake\ndeb"), 0o744))
ctx := testctx.NewWithCfg(config.Project{
Dist: folder,
Dist: directory,
ProjectName: "testupload",
Blobs: []config.Blob{
{
Provider: "s3",
Bucket: name,
Folder: "/",
Directory: "/",
Endpoint: "http://" + listen,
},
},
@ -247,13 +247,13 @@ func TestMinioUploadRootFolder(t *testing.T) {
}
func TestMinioUploadInvalidCustomBucketID(t *testing.T) {
folder := t.TempDir()
tgzpath := filepath.Join(folder, "bin.tar.gz")
debpath := filepath.Join(folder, "bin.deb")
directory := t.TempDir()
tgzpath := filepath.Join(directory, "bin.tar.gz")
debpath := filepath.Join(directory, "bin.deb")
require.NoError(t, os.WriteFile(tgzpath, []byte("fake\ntargz"), 0o744))
require.NoError(t, os.WriteFile(debpath, []byte("fake\ndeb"), 0o744))
ctx := testctx.NewWithCfg(config.Project{
Dist: folder,
Dist: directory,
ProjectName: "testupload",
Blobs: []config.Blob{
{
@ -280,16 +280,16 @@ func TestMinioUploadInvalidCustomBucketID(t *testing.T) {
func TestMinioUploadSkip(t *testing.T) {
name := "basic"
folder := t.TempDir()
debpath := filepath.Join(folder, "bin.deb")
tgzpath := filepath.Join(folder, "bin.tar.gz")
directory := t.TempDir()
debpath := filepath.Join(directory, "bin.deb")
tgzpath := filepath.Join(directory, "bin.tar.gz")
require.NoError(t, os.WriteFile(tgzpath, []byte("fake\ntargz"), 0o744))
require.NoError(t, os.WriteFile(debpath, []byte("fake\ndeb"), 0o744))
buildCtx := func(uploadID string) *context.Context {
ctx := testctx.NewWithCfg(
config.Project{
Dist: folder,
Dist: directory,
ProjectName: "testupload",
Blobs: []config.Blob{
{

View File

@ -83,13 +83,6 @@ func TestDefaults(t *testing.T) {
Provider: "gcs",
ContentDisposition: "-",
},
{
Bucket: "deprecated",
Provider: "s3",
Folder: "static",
OldDisableSSL: true,
OldKMSKey: "fake",
},
},
})
require.NoError(t, Pipe{}.Default(ctx))
@ -113,17 +106,6 @@ func TestDefaults(t *testing.T) {
Directory: "{{ .ProjectName }}/{{ .Tag }}",
ContentDisposition: "",
},
{
Bucket: "deprecated",
Provider: "s3",
Folder: "static",
Directory: "static",
OldDisableSSL: true,
DisableSSL: true,
OldKMSKey: "fake",
KMSKey: "fake",
ContentDisposition: "attachment;filename={{.Filename}}",
},
}, ctx.Config.Blobs)
}
@ -153,7 +135,7 @@ func TestURL(t *testing.T) {
Bucket: "foo",
Provider: "s3",
Region: "us-west-1",
Folder: "foo",
Directory: "foo",
Endpoint: "s3.foobar.com",
DisableSSL: true,
})
@ -177,7 +159,7 @@ func TestURL(t *testing.T) {
Bucket: "foo",
Provider: "gs",
Region: "us-west-1",
Folder: "foo",
Directory: "foo",
Endpoint: "s3.foobar.com",
DisableSSL: true,
})

View File

@ -8,7 +8,6 @@ import (
"os"
"path"
"path/filepath"
"reflect"
"sort"
"strings"
"text/template"
@ -17,7 +16,6 @@ import (
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/commitauthor"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/tmpl"
@ -71,17 +69,6 @@ func (Pipe) Default(ctx *context.Context) error {
if brew.Goamd64 == "" {
brew.Goamd64 = "v1"
}
if brew.Plist != "" {
deprecate.Notice(ctx, "brews.plist")
}
if brew.Folder != "" {
deprecate.Notice(ctx, "brews.folder")
brew.Directory = brew.Folder
}
if !reflect.DeepEqual(brew.Tap, config.RepoRef{}) {
brew.Repository = brew.Tap
deprecate.Notice(ctx, "brews.tap")
}
}
return nil
@ -419,7 +406,6 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.ReleaseURLTemp
Caveats: split(cfg.Caveats),
Dependencies: cfg.Dependencies,
Conflicts: cfg.Conflicts,
Plist: cfg.Plist,
Service: split(cfg.Service),
PostInstall: split(cfg.PostInstall),
Tests: split(cfg.Test),

View File

@ -109,7 +109,6 @@ func TestFullFormulae(t *testing.T) {
data.Caveats = []string{"Here are some caveats"}
data.Dependencies = []config.HomebrewDependency{{Name: "gtk+"}}
data.Conflicts = []string{"svn"}
data.Plist = "it works"
data.PostInstall = []string{`touch "/tmp/foo"`, `system "echo", "done"`}
data.CustomBlock = []string{"devel do", ` url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz"`, ` sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68"`, "end"}
data.Tests = []string{`system "#{bin}/{{.ProjectName}}", "-version"`}
@ -148,7 +147,6 @@ func TestFormulaeSimple(t *testing.T) {
require.NoError(t, err)
assertDefaultTemplateData(t, formulae)
require.NotContains(t, formulae, "def caveats")
require.NotContains(t, formulae, "def plist;")
}
func TestSplit(t *testing.T) {
@ -331,7 +329,6 @@ func TestFullPipe(t *testing.T) {
Description: "Run pipe test formula and FOO={{ .Env.FOO }}",
Caveats: "don't do this {{ .ProjectName }}",
Test: "system \"true\"\nsystem \"#{bin}/foo\", \"-h\"",
Plist: `<xml>whatever</xml>`,
Dependencies: []config.HomebrewDependency{
{Name: "zsh", Type: "optional"},
{Name: "bash", Version: "3.2.57"},
@ -748,8 +745,10 @@ func TestRunPipeForMultipleArmVersions(t *testing.T) {
Description: "Run pipe test formula and FOO={{ .Env.FOO }}",
Caveats: "don't do this {{ .ProjectName }}",
Test: "system \"true\"\nsystem \"#{bin}/foo\", \"-h\"",
Plist: `<xml>whatever</xml>`,
Dependencies: []config.HomebrewDependency{{Name: "zsh"}, {Name: "bash", Type: "recommended"}},
Dependencies: []config.HomebrewDependency{
{Name: "zsh"},
{Name: "bash", Type: "recommended"},
},
Conflicts: []string{"gtk+", "qt"},
Install: `bin.install "{{ .ProjectName }}"`,
Repository: config.RepoRef{
@ -1231,8 +1230,7 @@ func TestDefault(t *testing.T) {
ProjectName: "myproject",
Brews: []config.Homebrew{
{
Plist: "<xml>... whatever</xml>",
Tap: repo,
Repository: repo,
},
},
}, testctx.GitHubTokenType)
@ -1242,7 +1240,6 @@ func TestDefault(t *testing.T) {
require.NotEmpty(t, ctx.Config.Brews[0].CommitAuthor.Email)
require.NotEmpty(t, ctx.Config.Brews[0].CommitMessageTemplate)
require.Equal(t, repo, ctx.Config.Brews[0].Repository)
require.True(t, ctx.Deprecated)
}
func TestGHFolder(t *testing.T) {

View File

@ -13,7 +13,6 @@ type templateData struct {
Version string
License string
Caveats []string
Plist string
PostInstall []string
Dependencies []config.HomebrewDependency
Conflicts []string

View File

@ -78,17 +78,6 @@ class {{ .Name }} < Formula
end
{{- end -}}
{{- with .Plist }}
plist_options startup: false
def plist
<<~EOS
{{ . }}
EOS
end
{{- end -}}
{{- with .Service }}
service do

View File

@ -80,14 +80,6 @@ class Test < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
it works
EOS
end
test do
system "#{bin}/foo", "-version"
end

View File

@ -61,14 +61,6 @@ class CustomBlock < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -59,14 +59,6 @@ class CustomDownloadStrategy < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -60,14 +60,6 @@ class CustomRequire < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -59,14 +59,6 @@ class Default < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -59,14 +59,6 @@ class DefaultGitlab < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -59,14 +59,6 @@ class GitRemote < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -59,14 +59,6 @@ class OpenPr < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -59,14 +59,6 @@ class ValidRepositoryTemplates < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -68,14 +68,6 @@ class WithHeader < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -71,14 +71,6 @@ class WithManyHeaders < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
service do
run foo/bar
keep_alive true

View File

@ -61,14 +61,6 @@ class MultipleArmv5 < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
test do
system "true"
system "#{bin}/foo", "-h"

View File

@ -61,14 +61,6 @@ class MultipleArmv6 < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
test do
system "true"
system "#{bin}/foo", "-h"

View File

@ -61,14 +61,6 @@ class MultipleArmv7 < Formula
EOS
end
plist_options startup: false
def plist
<<~EOS
<xml>whatever</xml>
EOS
end
test do
system "true"
system "#{bin}/foo", "-h"

View File

@ -6,12 +6,10 @@ import (
"fmt"
"os"
"path/filepath"
"reflect"
"strings"
"github.com/caarlos0/go-shellwords"
"github.com/caarlos0/log"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/ids"
"github.com/goreleaser/goreleaser/internal/semerrgroup"
"github.com/goreleaser/goreleaser/internal/shell"
@ -48,10 +46,6 @@ func (Pipe) Run(ctx *context.Context) error {
// Default sets the pipe defaults.
func (Pipe) Default(ctx *context.Context) error {
if !reflect.DeepEqual(ctx.Config.SingleBuild, config.Build{}) {
deprecate.Notice(ctx, "build")
}
ids := ids.New("builds")
for i, build := range ctx.Config.Builds {
build, err := buildWithDefaults(ctx, build)
@ -62,7 +56,7 @@ func (Pipe) Default(ctx *context.Context) error {
ids.Inc(ctx.Config.Builds[i].ID)
}
if len(ctx.Config.Builds) == 0 {
build, err := buildWithDefaults(ctx, ctx.Config.SingleBuild)
build, err := buildWithDefaults(ctx, config.Build{})
if err != nil {
return err
}

View File

@ -399,33 +399,6 @@ func TestDefaultPartialBuilds(t *testing.T) {
})
}
func TestDefaultFillSingleBuild(t *testing.T) {
testlib.Mktmp(t)
ctx := testctx.NewWithCfg(config.Project{
ProjectName: "foo",
SingleBuild: config.Build{
Main: "testreleaser",
},
})
require.NoError(t, Pipe{}.Default(ctx))
require.Len(t, ctx.Config.Builds, 1)
require.Equal(t, "foo", ctx.Config.Builds[0].Binary)
}
func TestDefaultFailSingleBuild(t *testing.T) {
folder := testlib.Mktmp(t)
config := config.Project{
Dist: folder,
SingleBuild: config.Build{
Builder: "fakeFailDefault",
},
}
ctx := testctx.NewWithCfg(config)
require.EqualError(t, Pipe{}.Default(ctx), errFailedDefault.Error())
require.Empty(t, ctx.Artifacts.List())
}
func TestSkipBuild(t *testing.T) {
folder := testlib.Mktmp(t)
config := config.Project{

View File

@ -12,7 +12,6 @@ import (
"github.com/caarlos0/log"
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/git"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/pkg/context"
@ -46,10 +45,6 @@ func (Pipe) Skip(ctx *context.Context) (bool, error) {
if ctx.Snapshot {
return true, nil
}
if ctx.Config.Changelog.Skip != "" {
deprecate.Notice(ctx, "changelog.skip")
ctx.Config.Changelog.Disable = ctx.Config.Changelog.Skip
}
return tmpl.New(ctx).Bool(ctx.Config.Changelog.Disable)
}

View File

@ -719,13 +719,12 @@ func TestSkip(t *testing.T) {
t.Run("skip/disable", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Changelog: config.Changelog{
Skip: "{{gt .Patch 0}}",
Disable: "{{gt .Patch 0}}",
},
}, testctx.WithSemver(0, 0, 1, ""))
b, err := Pipe{}.Skip(ctx)
require.NoError(t, err)
require.True(t, b)
require.Equal(t, ctx.Config.Changelog.Skip, ctx.Config.Changelog.Disable)
})
t.Run("disable on patches", func(t *testing.T) {

View File

@ -10,7 +10,6 @@ import (
"os"
"path"
"path/filepath"
"reflect"
"sort"
"strings"
@ -18,7 +17,6 @@ import (
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/commitauthor"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/internal/yaml"
@ -56,10 +54,6 @@ func (Pipe) Default(ctx *context.Context) error {
if krew.Goamd64 == "" {
krew.Goamd64 = "v1"
}
if !reflect.DeepEqual(krew.Index, config.RepoRef{}) {
krew.Repository = krew.Index
deprecate.Notice(ctx, "krews.index")
}
}
return nil

View File

@ -967,7 +967,7 @@ func TestDefault(t *testing.T) {
ProjectName: "myproject",
Krews: []config.Krew{
{
Index: config.RepoRef{
Repository: config.RepoRef{
Git: config.GitRepoRef{
URL: "foo/bar",
},
@ -981,7 +981,6 @@ func TestDefault(t *testing.T) {
require.NotEmpty(t, ctx.Config.Krews[0].CommitAuthor.Email)
require.NotEmpty(t, ctx.Config.Krews[0].CommitMessageTemplate)
require.Equal(t, "foo/bar", ctx.Config.Krews[0].Repository.Git.URL)
require.True(t, ctx.Deprecated)
}
func TestGHFolder(t *testing.T) {

View File

@ -8,14 +8,12 @@ import (
"os"
"path"
"path/filepath"
"reflect"
"strings"
"github.com/caarlos0/log"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/commitauthor"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/skips"
"github.com/goreleaser/goreleaser/internal/tmpl"
@ -63,7 +61,7 @@ type Pipe struct{}
func (Pipe) String() string { return "scoop manifests" }
func (Pipe) ContinueOnError() bool { return true }
func (Pipe) Skip(ctx *context.Context) bool {
return skips.Any(ctx, skips.Scoop) || (ctx.Config.Scoop.Repository.Name == "" && len(ctx.Config.Scoops) == 0)
return skips.Any(ctx, skips.Scoop) || len(ctx.Config.Scoops) == 0
}
// Run creates the scoop manifest locally.
@ -86,21 +84,11 @@ func (Pipe) Publish(ctx *context.Context) error {
// Default sets the pipe defaults.
func (Pipe) Default(ctx *context.Context) error {
if !reflect.DeepEqual(ctx.Config.Scoop.Bucket, config.RepoRef{}) ||
!reflect.DeepEqual(ctx.Config.Scoop.Repository, config.RepoRef{}) {
deprecate.Notice(ctx, "scoop")
ctx.Config.Scoops = append(ctx.Config.Scoops, ctx.Config.Scoop)
}
for i := range ctx.Config.Scoops {
scoop := &ctx.Config.Scoops[i]
if scoop.Name == "" {
scoop.Name = ctx.Config.ProjectName
}
if scoop.Folder != "" {
deprecate.Notice(ctx, "scoops.folder")
scoop.Directory = scoop.Folder
}
scoop.CommitAuthor = commitauthor.Default(scoop.CommitAuthor)
if scoop.CommitMessageTemplate == "" {
scoop.CommitMessageTemplate = "Scoop update for {{ .ProjectName }} version {{ .Tag }}"
@ -108,10 +96,6 @@ func (Pipe) Default(ctx *context.Context) error {
if scoop.Goamd64 == "" {
scoop.Goamd64 = "v1"
}
if !reflect.DeepEqual(scoop.Bucket, config.RepoRef{}) {
scoop.Repository = scoop.Bucket
deprecate.Notice(ctx, "scoops.bucket")
}
}
return nil
}

View File

@ -48,33 +48,9 @@ func TestDefault(t *testing.T) {
require.NotEmpty(t, ctx.Config.Scoops[0].CommitMessageTemplate)
}
func TestDefaultDeprecated(t *testing.T) {
testlib.Mktmp(t)
ctx := testctx.NewWithCfg(
config.Project{
ProjectName: "barr",
Scoop: config.Scoop{
Bucket: config.RepoRef{
Name: "foo",
},
},
},
testctx.GitHubTokenType,
)
require.NoError(t, Pipe{}.Default(ctx))
require.Len(t, ctx.Config.Scoops, 1)
require.Equal(t, ctx.Config.ProjectName, ctx.Config.Scoops[0].Name)
require.NotEmpty(t, ctx.Config.Scoops[0].CommitAuthor.Name)
require.NotEmpty(t, ctx.Config.Scoops[0].CommitAuthor.Email)
require.NotEmpty(t, ctx.Config.Scoops[0].CommitMessageTemplate)
require.Equal(t, "foo", ctx.Config.Scoops[0].Repository.Name)
require.True(t, ctx.Deprecated)
}
func Test_doRun(t *testing.T) {
folder := t.TempDir()
file := filepath.Join(folder, "archive")
directory := t.TempDir()
file := filepath.Join(directory, "archive")
require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644))
type args struct {
@ -119,7 +95,7 @@ func Test_doRun(t *testing.T) {
Owner: "test",
Name: "test",
},
Folder: "scoops",
Directory: "scoops",
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
}},
@ -162,7 +138,7 @@ func Test_doRun(t *testing.T) {
Name: "test",
},
IDs: []string{"id2"},
Folder: "scoops",
Directory: "scoops",
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
}},
@ -198,16 +174,18 @@ func Test_doRun(t *testing.T) {
config.Project{
Dist: t.TempDir(),
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
},
Folder: "scoops",
Directory: "scoops",
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -233,7 +211,8 @@ func Test_doRun(t *testing.T) {
config.Project{
ProjectName: "git-run-pipe",
Dist: t.TempDir(),
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Name: "test",
Branch: "main",
@ -242,11 +221,12 @@ func Test_doRun(t *testing.T) {
PrivateKey: testlib.MakeNewSSHKey(t, ""),
},
},
Folder: "scoops",
Directory: "scoops",
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -263,8 +243,8 @@ func Test_doRun(t *testing.T) {
tb.Helper()
content := testlib.CatFileFromBareRepositoryOnBranch(
tb,
a.ctx.Config.Scoop.Repository.Git.URL,
a.ctx.Config.Scoop.Repository.Branch,
a.ctx.Config.Scoops[0].Repository.Git.URL,
a.ctx.Config.Scoops[0].Repository.Branch,
"scoops/git-run-pipe.json",
)
golden.RequireEqualJSON(tb, content)
@ -276,7 +256,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -285,6 +266,7 @@ func Test_doRun(t *testing.T) {
Homepage: "https://github.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -323,7 +305,8 @@ func Test_doRun(t *testing.T) {
config.Project{
GitHubURLs: config.GitHubURLs{Download: "https://api.custom.github.enterprise.com"},
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -332,6 +315,7 @@ func Test_doRun(t *testing.T) {
Homepage: "https://github.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -355,7 +339,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -364,6 +349,7 @@ func Test_doRun(t *testing.T) {
Homepage: "https://gitlab.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -396,7 +382,8 @@ func Test_doRun(t *testing.T) {
config.Project{
GitHubURLs: config.GitHubURLs{Download: "https://api.custom.gitlab.enterprise.com"},
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -405,6 +392,7 @@ func Test_doRun(t *testing.T) {
Homepage: "https://gitlab.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -436,7 +424,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -445,6 +434,7 @@ func Test_doRun(t *testing.T) {
Homepage: "https://github.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -462,7 +452,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
SkipUpload: "auto",
Repository: config.RepoRef{
Owner: "test",
@ -472,6 +463,7 @@ func Test_doRun(t *testing.T) {
Homepage: "https://github.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1-pre.1"),
testctx.WithVersion("1.0.1-pre.1"),
@ -493,7 +485,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
SkipUpload: "true",
Repository: config.RepoRef{
Owner: "test",
@ -503,6 +496,7 @@ func Test_doRun(t *testing.T) {
Homepage: "https://github.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -523,7 +517,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -532,6 +527,7 @@ func Test_doRun(t *testing.T) {
Homepage: "https://github.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -549,7 +545,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -557,6 +554,7 @@ func Test_doRun(t *testing.T) {
Name: "{{.Nope}}",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -576,7 +574,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -584,6 +583,7 @@ func Test_doRun(t *testing.T) {
Description: "{{.Nope}}",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -603,7 +603,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -611,6 +612,7 @@ func Test_doRun(t *testing.T) {
Homepage: "{{.Nope}}",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -630,7 +632,8 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -638,6 +641,7 @@ func Test_doRun(t *testing.T) {
SkipUpload: "{{.Nope}}",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -657,16 +661,18 @@ func Test_doRun(t *testing.T) {
testctx.NewWithCfg(
config.Project{
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "{{ .Env.aaaaaa }}",
Name: "test",
},
Folder: "scoops",
Directory: "scoops",
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -693,7 +699,7 @@ func Test_doRun(t *testing.T) {
Name: "{{ .Env.FOO }}",
Branch: "{{ .Env.BRANCH }}",
},
Folder: "scoops",
Directory: "scoops",
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
}},
@ -734,10 +740,10 @@ func Test_doRun(t *testing.T) {
}
func TestRunPipePullRequest(t *testing.T) {
folder := t.TempDir()
directory := t.TempDir()
ctx := testctx.NewWithCfg(
config.Project{
Dist: folder,
Dist: directory,
ProjectName: "foo",
Scoops: []config.Scoop{{
Name: "{{.Env.FOO}}",
@ -757,7 +763,7 @@ func TestRunPipePullRequest(t *testing.T) {
testctx.WithCurrentTag("v1.2.1"),
testctx.WithEnv(map[string]string{"FOO": "foobar"}),
)
path := filepath.Join(folder, "dist/foo_windows_amd64/foo.exe")
path := filepath.Join(directory, "dist/foo_windows_amd64/foo.exe")
ctx.Artifacts.Add(&artifact.Artifact{
Name: "foo_windows_amd64.tar.gz",
Path: path,
@ -786,8 +792,8 @@ func TestRunPipePullRequest(t *testing.T) {
}
func Test_buildManifest(t *testing.T) {
folder := t.TempDir()
file := filepath.Join(folder, "archive")
directory := t.TempDir()
file := filepath.Join(directory, "archive")
require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644))
tests := []struct {
@ -808,7 +814,8 @@ func Test_buildManifest(t *testing.T) {
Name: "test",
},
},
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -818,6 +825,7 @@ func Test_buildManifest(t *testing.T) {
Persist: []string{"data", "config", "test.ini"},
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -837,7 +845,8 @@ func Test_buildManifest(t *testing.T) {
Name: "test",
},
},
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -849,6 +858,7 @@ func Test_buildManifest(t *testing.T) {
PostInstall: []string{"Write-Host 'Running postinstall command'"},
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -862,7 +872,8 @@ func Test_buildManifest(t *testing.T) {
Download: "https://github.com",
},
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -874,6 +885,7 @@ func Test_buildManifest(t *testing.T) {
Persist: []string{"data.cfg", "etc"},
},
},
},
testctx.WithCurrentTag("v1.0.1"),
testctx.GitHubTokenType,
testctx.WithVersion("1.0.1"),
@ -887,7 +899,8 @@ func Test_buildManifest(t *testing.T) {
Download: "https://gitlab.com",
},
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -899,6 +912,7 @@ func Test_buildManifest(t *testing.T) {
Persist: []string{"data.cfg", "etc"},
},
},
},
testctx.GitHubTokenType,
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
@ -977,12 +991,13 @@ func Test_buildManifest(t *testing.T) {
}
}
func getScoopPipeSkipCtx(folder string) (*context.Context, string) {
func getScoopPipeSkipCtx(directory string) (*context.Context, string) {
ctx := testctx.NewWithCfg(
config.Project{
Dist: folder,
Dist: directory,
ProjectName: "run-pipe",
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Owner: "test",
Name: "test",
@ -992,11 +1007,12 @@ func getScoopPipeSkipCtx(folder string) (*context.Context, string) {
Name: "run-pipe",
},
},
},
testctx.WithCurrentTag("v1.0.1"),
testctx.WithVersion("1.0.1"),
)
path := filepath.Join(folder, "bin.tar.gz")
path := filepath.Join(directory, "bin.tar.gz")
ctx.Artifacts.Add(&artifact.Artifact{
Name: "bin.tar.gz",
@ -1027,9 +1043,9 @@ func getScoopPipeSkipCtx(folder string) (*context.Context, string) {
}
func TestRunPipeScoopWithSkipUpload(t *testing.T) {
folder := t.TempDir()
ctx, path := getScoopPipeSkipCtx(folder)
ctx.Config.Scoop.SkipUpload = "true"
directory := t.TempDir()
ctx, path := getScoopPipeSkipCtx(directory)
ctx.Config.Scoops[0].SkipUpload = "true"
f, err := os.Create(path)
require.NoError(t, err)
@ -1040,14 +1056,14 @@ func TestRunPipeScoopWithSkipUpload(t *testing.T) {
require.NoError(t, runAll(ctx, cli))
require.EqualError(t, publishAll(ctx, cli), `scoop.skip_upload is true`)
distFile := filepath.Join(folder, "scoop", ctx.Config.Scoop.Name+".json")
distFile := filepath.Join(directory, "scoop", ctx.Config.Scoops[0].Name+".json")
_, err = os.Stat(distFile)
require.NoError(t, err, "file should exist: "+distFile)
}
func TestWrapInDirectory(t *testing.T) {
folder := t.TempDir()
file := filepath.Join(folder, "archive")
directory := t.TempDir()
file := filepath.Join(directory, "archive")
require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644))
ctx := testctx.NewWithCfg(
@ -1105,21 +1121,25 @@ func TestSkip(t *testing.T) {
})
t.Run("skip flag", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Name: "a",
},
},
},
}, testctx.Skip(skips.Scoop))
require.True(t, Pipe{}.Skip(ctx))
})
t.Run("dont skip", func(t *testing.T) {
ctx := testctx.NewWithCfg(config.Project{
Scoop: config.Scoop{
Scoops: []config.Scoop{
{
Repository: config.RepoRef{
Name: "a",
},
},
},
})
require.False(t, Pipe{}.Skip(ctx))
})

View File

@ -9,7 +9,6 @@ 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/gio"
"github.com/goreleaser/goreleaser/internal/git"
"github.com/goreleaser/goreleaser/internal/tmpl"
@ -129,13 +128,8 @@ func (Pipe) Default(ctx *context.Context) error {
if archive.Format == "" {
archive.Format = "tar.gz"
}
if archive.NameTemplate == "" {
archive.NameTemplate = "{{ .ProjectName }}-{{ .Version }}"
}
if archive.Enabled && archive.RLCP != "" {
deprecate.Notice(ctx, "source.rlcp")
}
return nil
}

View File

@ -246,15 +246,6 @@ type Homebrew struct {
Goarm string `yaml:"goarm,omitempty" json:"goarm,omitempty" jsonschema:"oneof_type=string;integer"`
Goamd64 string `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
Service string `yaml:"service,omitempty" json:"service,omitempty"`
// Deprecated: use Repository instead.
Tap RepoRef `yaml:"tap,omitempty" json:"tap,omitempty" jsonschema:"deprecated=true,description=use repository instead"`
// Deprecated: use Service instead.
Plist string `yaml:"plist,omitempty" json:"plist,omitempty" jsonschema:"deprecated=true,description=use service instead"`
// Deprecated: use Directory instead.
Folder string `yaml:"folder,omitempty" json:"folder,omitempty" jsonschema:"deprecated=true"`
}
type Nix struct {
@ -365,9 +356,6 @@ type Krew struct {
Goarm string `yaml:"goarm,omitempty" json:"goarm,omitempty" jsonschema:"oneof_type=string;integer"`
Goamd64 string `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
SkipUpload string `yaml:"skip_upload,omitempty" json:"skip_upload,omitempty" jsonschema:"oneof_type=string;boolean"`
// Deprecated: use Repository instead.
Index RepoRef `yaml:"index,omitempty" json:"index,omitempty" jsonschema:"deprecated=true,description=use repository instead"`
}
// Ko contains the ko section
@ -411,12 +399,6 @@ type Scoop struct {
Depends []string `yaml:"depends,omitempty" json:"depends,omitempty"`
Shortcuts [][]string `yaml:"shortcuts,omitempty" json:"shortcuts,omitempty"`
Goamd64 string `yaml:"goamd64,omitempty" json:"goamd64,omitempty"`
// Deprecated: use Repository instead.
Bucket RepoRef `yaml:"bucket,omitempty" json:"bucket,omitempty" jsonschema:"deprecated=true,description=use repository instead"`
// Deprecated: use Directory instead.
Folder string `yaml:"folder,omitempty" json:"folder,omitempty" jsonschema:"deprecated=true"`
}
// CommitAuthor is the author of a Git commit.
@ -724,12 +706,6 @@ type Archive struct {
Files []File `yaml:"files,omitempty" json:"files,omitempty"`
Meta bool `yaml:"meta,omitempty" json:"meta,omitempty"`
AllowDifferentBinaryCount bool `yaml:"allow_different_binary_count,omitempty" json:"allow_different_binary_count,omitempty"`
// Deprecated: don't need to set this anymore.
RLCP string `yaml:"rlcp,omitempty" json:"rlcp,omitempty" jsonschema:"oneof_type=string;boolean,deprecated=true,description=you can now remove this"`
// Deprecated: use StripBinaryDirectory instead.
StripParentBinaryFolder bool `yaml:"strip_parent_binary_folder,omitempty" json:"strip_parent_binary_folder,omitempty" jsonschema:"deprecated=true"`
}
type ReleaseNotesMode string
@ -1114,9 +1090,6 @@ type Changelog struct {
Format string `yaml:"format,omitempty" json:"format,omitempty"`
Groups []ChangelogGroup `yaml:"groups,omitempty" json:"groups,omitempty"`
Abbrev int `yaml:"abbrev,omitempty" json:"abbrev,omitempty"`
// Deprecated: use disable instead.
Skip string `yaml:"skip,omitempty" json:"skip,omitempty" jsonschema:"oneof_type=string;boolean,deprecated=true,description=use disable instead"`
}
// ChangelogGroup holds the grouping criteria for the changelog.
@ -1156,15 +1129,6 @@ type Blob struct {
CacheControl []string `yaml:"cache_control,omitempty" json:"cache_control,omitempty"`
ContentDisposition string `yaml:"content_disposition,omitempty" json:"content_disposition,omitempty"`
IncludeMeta bool `yaml:"include_meta,omitempty" json:"include_meta,omitempty"`
// Deprecated: use disable_ssl instead
OldDisableSSL bool `yaml:"disableSSL,omitempty" json:"disableSSL,omitempty" jsonschema:"deprecated=true,description=use disable_ssl instead"` //nolint:tagliatelle
// Deprecated: use kms_key instead
OldKMSKey string `yaml:"kmskey,omitempty" json:"kmskey,omitempty" jsonschema:"deprecated=true,description=use kms_key instead"`
// Deprecated: use Directory instead.
Folder string `yaml:"folder,omitempty" json:"folder,omitempty" jsonschema:"deprecated=true"`
}
// Upload configuration.
@ -1208,9 +1172,6 @@ type Source struct {
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`
PrefixTemplate string `yaml:"prefix_template,omitempty" json:"prefix_template,omitempty"`
Files []File `yaml:"files,omitempty" json:"files,omitempty"`
// Deprecated: don't need to set this anymore.
RLCP string `yaml:"rlcp,omitempty" json:"rlcp,omitempty" jsonschema:"oneof_type=string;boolean,deprecated=true,description=you can now remove this"`
}
// Project includes all project configuration.
@ -1269,12 +1230,6 @@ type Project struct {
// should be set if using Gitea
GiteaURLs GiteaURLs `yaml:"gitea_urls,omitempty" json:"gitea_urls,omitempty"`
// Deprecated: use Scoops instead.
Scoop Scoop `yaml:"scoop,omitempty" json:"scoop,omitempty" jsonschema:"deprecated=true,description=use scoops instead"`
// Deprecated: use Builds instead.
SingleBuild Build `yaml:"build,omitempty" json:"build,omitempty" jsonschema:"deprecated=true,description=use builds instead"`
}
type ProjectMetadata struct {

View File

@ -10,6 +10,7 @@ import (
func TestUnmarshalHomebrewDependency(t *testing.T) {
t.Run("string arr", func(t *testing.T) {
conf := `
version: 2
brews:
- name: foo
dependencies:
@ -31,6 +32,7 @@ brews:
t.Run("mixed", func(t *testing.T) {
conf := `
version: 2
brews:
- name: foo
dependencies:
@ -57,6 +59,7 @@ brews:
t.Run("mixed", func(t *testing.T) {
conf := `
version: 2
brews:
- name: foo
dependencies:
@ -67,6 +70,6 @@ brews:
buf := strings.NewReader(conf)
_, err := LoadReader(buf)
require.EqualError(t, err, "yaml: unmarshal errors:\n line 6: field namer not found in type config.homebrewDependency")
require.EqualError(t, err, "yaml: unmarshal errors:\n line 7: field namer not found in type config.homebrewDependency")
})
}

View File

@ -60,12 +60,12 @@ func TestFileNotFound(t *testing.T) {
func TestInvalidFields(t *testing.T) {
_, err := Load("testdata/invalid_config.yml")
require.EqualError(t, err, "yaml: unmarshal errors:\n line 2: field invalid_yaml not found in type config.Build")
require.EqualError(t, err, "yaml: unmarshal errors:\n line 3: field invalid_yaml not found in type config.Build")
}
func TestInvalidYaml(t *testing.T) {
_, err := Load("testdata/invalid.yml")
require.EqualError(t, err, "yaml: line 1: did not find expected node content")
require.EqualError(t, err, "yaml: line 2: did not find expected node content")
}
func TestConfigWithAnchors(t *testing.T) {
@ -78,17 +78,31 @@ func TestVersion(t *testing.T) {
_, err := LoadReader(bytes.NewReader(nil))
require.NoError(t, err)
})
t.Run("do not allow no version with errors", func(t *testing.T) {
_, err := LoadReader(strings.NewReader("nope: nope"))
require.Error(t, err)
require.ErrorIs(t, err, VersionError{0})
})
t.Run("allow v0", func(t *testing.T) {
_, err := LoadReader(strings.NewReader("version: 0"))
require.NoError(t, err)
})
t.Run("do not allow v0 with errors", func(t *testing.T) {
_, err := LoadReader(strings.NewReader("version: 0\nnope: nope"))
require.Error(t, err)
require.ErrorIs(t, err, VersionError{0})
})
t.Run("allow v1", func(t *testing.T) {
_, err := LoadReader(strings.NewReader("version: 1"))
require.NoError(t, err)
})
t.Run("do not allow v2", func(t *testing.T) {
_, err := LoadReader(strings.NewReader("version: 2"))
t.Run("do not allow v1 with errors", func(t *testing.T) {
_, err := LoadReader(strings.NewReader("version: 1\nnope: nope"))
require.Error(t, err)
require.ErrorIs(t, err, VersionError{2})
require.ErrorIs(t, err, VersionError{1})
})
t.Run("allow v2", func(t *testing.T) {
_, err := LoadReader(strings.NewReader("version: 2\nbuilds: []"))
require.NoError(t, err)
})
}

View File

@ -5,6 +5,7 @@ import (
"io"
"os"
"github.com/caarlos0/log"
"github.com/goreleaser/goreleaser/internal/logext"
"github.com/goreleaser/goreleaser/internal/yaml"
)
@ -18,7 +19,7 @@ type VersionError struct {
func (e VersionError) Error() string {
return fmt.Sprintf(
"only configurations files on %s are supported, yours is %s, please update your configuration",
logext.Keyword("version: 1"),
logext.Keyword("version: 2"),
logext.Keyword(fmt.Sprintf("version: %d", e.current)),
)
}
@ -41,11 +42,18 @@ func LoadReader(fd io.Reader) (config Project, err error) {
}
var versioned Versioned
_ = yaml.Unmarshal(data, &versioned)
if versioned.Version != 0 && versioned.Version != 1 {
return config, VersionError{versioned.Version}
if err := yaml.Unmarshal(data, &versioned); err != nil {
return config, err
}
validVersion := versioned.Version == 2
if !validVersion {
log.Warn(VersionError{versioned.Version}.Error())
}
err = yaml.UnmarshalStrict(data, &config)
if err != nil && !validVersion {
return config, VersionError{versioned.Version}
}
return config, err
}

View File

@ -1,3 +1,4 @@
version: 2
project_name: &anchor_name This string will appear as the value of two keys.
build:
binary: *anchor_name
builds:
- binary: *anchor_name

View File

@ -1 +1,2 @@
version: 2
this_is_not_valid: [

View File

@ -1,3 +1,3 @@
build:
invalid_yaml: 1
version: 2
builds:
- invalid_yaml: 1

View File

@ -15,6 +15,8 @@ goreleaser check
## Active deprecation notices
None so far!
<!--
Template for new deprecations:
@ -39,9 +41,11 @@ Description.
-->
## Removed in v2
### archives.strip_parent_binary_folder
> since 2024-03-29 (v1.25)
> since 2024-03-29 (v1.25), removed 2024-05-26 (v2.0)
Property was renamed to be consistent across all configurations.
@ -63,7 +67,7 @@ Property was renamed to be consistent across all configurations.
### blobs.folder
> since 2024-03-29 (v1.25)
> since 2024-03-29 (v1.25), removed 2024-05-26 (v2.0)
Property was renamed to be consistent across all configurations.
@ -85,7 +89,7 @@ Property was renamed to be consistent across all configurations.
### brews.folder
> since 2024-03-29 (v1.25)
> since 2024-03-29 (v1.25), removed 2024-05-26 (v2.0)
Property was renamed to be consistent across all configurations.
@ -107,7 +111,7 @@ Property was renamed to be consistent across all configurations.
### scoops.folder
> since 2024-03-29 (v1.25)
> since 2024-03-29 (v1.25), removed 2024-05-26 (v2.0)
Property was renamed to be consistent across all configurations.
@ -129,7 +133,7 @@ Property was renamed to be consistent across all configurations.
### furies.skip
> since 2024-03-03 (v1.25)
> since 2024-03-03 (v1.25), removed 2024-05-26 (v2.0)
Changed to `disable` to conform with all other pipes.
@ -149,7 +153,7 @@ Changed to `disable` to conform with all other pipes.
### changelog.skip
> since 2024-01-14 (v1.24)
> since 2024-01-14 (v1.24), removed 2024-05-26 (v2.0)
Changed to `disable` to conform with all other pipes.
@ -169,7 +173,7 @@ Changed to `disable` to conform with all other pipes.
### blobs.kmskey
> since 2024-01-07 (v1.24)
> since 2024-01-07 (v1.24), removed 2024-05-26 (v2.0)
Changed to `kms_key` to conform with all other options.
@ -189,7 +193,7 @@ Changed to `kms_key` to conform with all other options.
### blobs.disableSSL
> since 2024-01-07 (v1.24)
> since 2024-01-07 (v1.24), removed 2024-05-26 (v2.0)
Changed to `disable_ssl` to conform with all other options.
@ -209,7 +213,7 @@ Changed to `disable_ssl` to conform with all other options.
### `--skip`
> since 2023-09-14 (v1.21)
> since 2023-09-14 (v1.21), removed 2024-05-26 (v2.0)
The following `goreleaser release` flags were deprecated:
@ -255,7 +259,7 @@ the valid options, and shell autocompletion should work properly as well.
### scoops.bucket
> since 2023-06-13 (v1.19.0)
> since 2023-06-13 (v1.19.0), removed 2024-05-26 (v2.0)
Replace `bucket` with `repository`.
@ -281,7 +285,7 @@ Replace `bucket` with `repository`.
### krews.index
> since 2023-06-13 (v1.19.0)
> since 2023-06-13 (v1.19.0), removed 2024-05-26 (v2.0)
Replace `index` with `repository`.
@ -307,7 +311,7 @@ Replace `index` with `repository`.
### brews.tap
> since 2023-06-13 (v1.19.0)
> since 2023-06-13 (v1.19.0), removed 2024-05-26 (v2.0)
Replace `tap` with `repository`.
@ -333,7 +337,7 @@ Replace `tap` with `repository`.
### archives.rlcp
> since 2023-06-06 (v1.19.0)
> since 2023-06-06 (v1.19.0), removed 2024-05-26 (v2.0)
This option is now default and can't be changed. You can remove it from your
configuration files.
@ -342,7 +346,7 @@ See [this](#archivesrlcp_1) for more info.
### source.rlcp
> since 2023-06-06 (v1.19.0)
> since 2023-06-06 (v1.19.0), removed 2024-05-26 (v2.0)
This option is now default and can't be changed. You can remove it from your
configuration files.
@ -351,7 +355,7 @@ See [this](#sourcerlcp_1) for more info.
### brews.plist
> since 2023-06-06 (v1.19.0)
> since 2023-06-06 (v1.19.0), removed 2024-05-26 (v2.0)
`plist` is deprecated by Homebrew, and now on GoReleaser too. Use `service`
instead.
@ -382,7 +386,7 @@ instead.
### --debug
> since 2023-05-16 (v1.19.0)
> since 2023-05-16 (v1.19.0), removed 2024-05-26 (v2.0)
`--debug` has been deprecated in favor of `--verbose`.
@ -400,7 +404,7 @@ instead.
### scoop
> since 2023-04-30 (v1.18.0)
> since 2023-04-30 (v1.18.0), removed 2024-05-26 (v2.0)
GoReleaser now allows many `scoop` configurations, so it should be pluralized
[accordingly](/customization/scoop).
@ -421,7 +425,7 @@ GoReleaser now allows many `scoop` configurations, so it should be pluralized
### build
> since 2023-02-09 (v1.16.0)
> since 2023-02-09 (v1.16.0), removed 2024-05-26 (v2.0)
This option was still being supported, even though undocumented, for a couple
of years now. It's finally time to sunset it.
@ -445,7 +449,7 @@ Simply use the pluralized form, `builds`, according to the
### --rm-dist
> since 2023-01-17 (v1.15.0)
> since 2023-01-17 (v1.15.0), removed 2024-05-26 (v2.0)
`--rm-dist` has been deprecated in favor of `--clean`.
@ -463,7 +467,7 @@ Simply use the pluralized form, `builds`, according to the
### nfpms.maintainer
> since 2022-05-07 (v1.9.0)
> since 2022-05-07 (v1.9.0), removed 2024-05-26 (v2.0)
nFPM will soon make mandatory setting the maintainer field.
@ -481,10 +485,10 @@ nFPM will soon make mandatory setting the maintainer field.
- maintainer: 'Name <email>'
```
## Expired deprecation notices
The following options were deprecated in the past and were already removed.
## Removed in v1
### archives.rlcp
> since 2022-12-23 (v1.14.0), removed 2023-06-06 (v1.19.0)
@ -813,6 +817,8 @@ ignore:
If you try to use new versions of GoReleaser with Go 1.15 or older, it will warn about it until this deprecation warning expires, after that your build will likely fail.
## Removed in v0.\*
### Skipping SemVer Validations
> since 2021-02-28 (v0.158.0), removed 2021-09-22 (v0.180.0)