mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
fix: s3: honor skip upload (#738)
refs https://github.com/goreleaser/goreleaser/issues/737
This commit is contained in:
parent
ba62d25bdd
commit
82493e2928
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||||
"github.com/goreleaser/goreleaser/internal/semerrgroup"
|
"github.com/goreleaser/goreleaser/internal/semerrgroup"
|
||||||
"github.com/goreleaser/goreleaser/internal/tmpl"
|
"github.com/goreleaser/goreleaser/internal/tmpl"
|
||||||
|
"github.com/goreleaser/goreleaser/pipeline"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Pipe for Artifactory
|
// Pipe for Artifactory
|
||||||
@ -47,6 +48,9 @@ func (Pipe) Default(ctx *context.Context) error {
|
|||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
func (Pipe) Run(ctx *context.Context) error {
|
func (Pipe) Run(ctx *context.Context) error {
|
||||||
|
if ctx.SkipPublish {
|
||||||
|
return pipeline.ErrSkipPublishEnabled
|
||||||
|
}
|
||||||
var g = semerrgroup.New(ctx.Parallelism)
|
var g = semerrgroup.New(ctx.Parallelism)
|
||||||
for _, conf := range ctx.Config.S3 {
|
for _, conf := range ctx.Config.S3 {
|
||||||
conf := conf
|
conf := conf
|
||||||
|
@ -13,7 +13,9 @@ import (
|
|||||||
"github.com/goreleaser/goreleaser/config"
|
"github.com/goreleaser/goreleaser/config"
|
||||||
"github.com/goreleaser/goreleaser/context"
|
"github.com/goreleaser/goreleaser/context"
|
||||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||||
|
"github.com/goreleaser/goreleaser/pipeline"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDescription(t *testing.T) {
|
func TestDescription(t *testing.T) {
|
||||||
@ -53,6 +55,34 @@ func TestDefaults(t *testing.T) {
|
|||||||
}}, ctx.Config.S3)
|
}}, ctx.Config.S3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSkipPublish(t *testing.T) {
|
||||||
|
folder, err := ioutil.TempDir("", "goreleasertest")
|
||||||
|
require.NoError(t, err)
|
||||||
|
artifactPath := filepath.Join(folder, "foo.tar.gz")
|
||||||
|
require.NoError(t, ioutil.WriteFile(artifactPath, []byte("fake\ntargz"), 0744))
|
||||||
|
var ctx = context.New(config.Project{
|
||||||
|
Dist: folder,
|
||||||
|
ProjectName: "testupload",
|
||||||
|
S3: []config.S3{
|
||||||
|
{
|
||||||
|
Bucket: "test",
|
||||||
|
Endpoint: "http://fake.s3.example",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
|
||||||
|
ctx.Artifacts.Add(artifact.Artifact{
|
||||||
|
Type: artifact.UploadableArchive,
|
||||||
|
Name: "foo.tar.gz",
|
||||||
|
Path: artifactPath,
|
||||||
|
})
|
||||||
|
ctx.SkipPublish = true
|
||||||
|
require.NoError(t, Pipe{}.Default(ctx))
|
||||||
|
err = Pipe{}.Run(ctx)
|
||||||
|
assert.True(t, pipeline.IsSkip(err))
|
||||||
|
assert.EqualError(t, err, pipeline.ErrSkipPublishEnabled.Error())
|
||||||
|
}
|
||||||
|
|
||||||
func TestUpload(t *testing.T) {
|
func TestUpload(t *testing.T) {
|
||||||
folder, err := ioutil.TempDir("", "goreleasertest")
|
folder, err := ioutil.TempDir("", "goreleasertest")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user