Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to skip scm release uploads #3282

Merged
merged 3 commits into from Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.