Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Aug 6, 2022
1 parent 36aabe2 commit 5a43334
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/pipe/release/release.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions internal/pipe/release/release_test.go
Expand Up @@ -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{})))
})
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Expand Up @@ -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"`
Expand Down
6 changes: 6 additions & 0 deletions www/docs/customization/release.md
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions www/docs/static/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a43334

Please sign in to comment.