From 5a433347ac05932bcb8e761d359d6710eba80822 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sat, 6 Aug 2022 18:59:59 -0300 Subject: [PATCH] feat: allow to skip scm release uploads (#3282) * feat: allow to skip scm release uploads refs #3268 * chore: schema update Signed-off-by: Carlos A Becker --- internal/pipe/release/release.go | 5 +++++ internal/pipe/release/release_test.go | 12 ++++++++++++ pkg/config/config.go | 1 + www/docs/customization/release.md | 6 ++++++ www/docs/static/schema.json | 3 +++ 5 files changed, 27 insertions(+) diff --git a/internal/pipe/release/release.go b/internal/pipe/release/release.go index 960556c3d1b..ca2aa996437 100644 --- a/internal/pipe/release/release.go +++ b/internal/pipe/release/release.go @@ -11,6 +11,7 @@ import ( "github.com/goreleaser/goreleaser/internal/client" "github.com/goreleaser/goreleaser/internal/extrafiles" "github.com/goreleaser/goreleaser/internal/git" + "github.com/goreleaser/goreleaser/internal/pipe" "github.com/goreleaser/goreleaser/internal/semerrgroup" "github.com/goreleaser/goreleaser/pkg/config" "github.com/goreleaser/goreleaser/pkg/context" @@ -110,6 +111,10 @@ func doPublish(ctx *context.Context, client client.Client) error { return err } + if ctx.Config.Release.SkipUpload { + return pipe.Skip("release.skip_upload is set") + } + extraFiles, err := extrafiles.Find(ctx, ctx.Config.Release.ExtraFiles) if err != nil { return err diff --git a/internal/pipe/release/release_test.go b/internal/pipe/release/release_test.go index 2414954e925..d739e053914 100644 --- a/internal/pipe/release/release_test.go +++ b/internal/pipe/release/release_test.go @@ -612,6 +612,18 @@ func TestSkip(t *testing.T) { require.True(t, Pipe{}.Skip(ctx)) }) + t.Run("skip upload", func(t *testing.T) { + ctx := context.New(config.Project{ + Release: config.Release{ + SkipUpload: true, + }, + }) + client := &client.Mock{} + testlib.AssertSkipped(t, doPublish(ctx, client)) + require.True(t, client.CreatedRelease) + require.False(t, client.UploadedFile) + }) + t.Run("dont skip", func(t *testing.T) { require.False(t, Pipe{}.Skip(context.New(config.Project{}))) }) diff --git a/pkg/config/config.go b/pkg/config/config.go index bec89af9d4d..87060a5bff0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -514,6 +514,7 @@ type Release struct { Gitea Repo `yaml:"gitea,omitempty" json:"gitea,omitempty"` Draft bool `yaml:"draft,omitempty" json:"draft,omitempty"` Disable bool `yaml:"disable,omitempty" json:"disable,omitempty"` + SkipUpload bool `yaml:"skip_upload,omitempty" json:"skip_upload,omitempty"` Prerelease string `yaml:"prerelease,omitempty" json:"prerelease,omitempty"` NameTemplate string `yaml:"name_template,omitempty" json:"name_template,omitempty"` IDs []string `yaml:"ids,omitempty" json:"ids,omitempty"` diff --git a/www/docs/customization/release.md b/www/docs/customization/release.md index 9b523dad519..0019d8c9bbe 100644 --- a/www/docs/customization/release.md +++ b/www/docs/customization/release.md @@ -76,6 +76,12 @@ release: # Defaults to false. disable: true + # Set this to true if you want to disable just the artifact upload to the SCM. + # If this is true, GoReleaser will still create the release with the changelog, but won't upload anything to it. + # + # Defaults to false. + skip_upload: true + # You can add extra pre-existing files to the release. # The filename on the release will be the last part of the path (base). # If another file with the same name exists, the last one found will be used. diff --git a/www/docs/static/schema.json b/www/docs/static/schema.json index 4ec69d44d91..3a8acbe26e2 100644 --- a/www/docs/static/schema.json +++ b/www/docs/static/schema.json @@ -1802,6 +1802,9 @@ "disable": { "type": "boolean" }, + "skip_upload": { + "type": "boolean" + }, "prerelease": { "type": "string" },