From 09bcdc0ca789bdc0f172611e205165fa7a78f1df Mon Sep 17 00:00:00 2001 From: Adam Bouqdib Date: Fri, 30 Jul 2021 19:31:07 +0100 Subject: [PATCH 1/2] fix: upload gcs blobs to bucket root --- internal/pipe/blob/upload.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/pipe/blob/upload.go b/internal/pipe/blob/upload.go index cd1019d10d6..06ab7367edd 100644 --- a/internal/pipe/blob/upload.go +++ b/internal/pipe/blob/upload.go @@ -6,6 +6,7 @@ import ( "net/url" "os" "path" + "strings" "github.com/apex/log" "github.com/goreleaser/goreleaser/internal/artifact" @@ -67,6 +68,7 @@ func doUpload(ctx *context.Context, conf config.Blob) error { if err != nil { return err } + folder = strings.TrimPrefix(folder, "/") bucketURL, err := urlFor(ctx, conf) if err != nil { From f2b6db2903dd84210f73d4a752615e44d4b453e1 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 16 Aug 2021 23:15:18 -0300 Subject: [PATCH 2/2] test: blob upload to bucket root Signed-off-by: Carlos Alexandro Becker --- internal/pipe/blob/blob_minio_test.go | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/internal/pipe/blob/blob_minio_test.go b/internal/pipe/blob/blob_minio_test.go index a0c062e32b7..1d85c12c9ef 100644 --- a/internal/pipe/blob/blob_minio_test.go +++ b/internal/pipe/blob/blob_minio_test.go @@ -127,6 +127,43 @@ func TestMinioUploadCustomBucketID(t *testing.T) { require.NoError(t, Pipe{}.Publish(ctx)) } +func TestMinioUploadRootFolder(t *testing.T) { + listen := randomListen(t) + folder := t.TempDir() + tgzpath := filepath.Join(folder, "bin.tar.gz") + debpath := filepath.Join(folder, "bin.deb") + require.NoError(t, os.WriteFile(tgzpath, []byte("fake\ntargz"), 0o744)) + require.NoError(t, os.WriteFile(debpath, []byte("fake\ndeb"), 0o744)) + ctx := context.New(config.Project{ + Dist: folder, + ProjectName: "testupload", + Blobs: []config.Blob{ + { + Provider: "s3", + Bucket: "test", + Folder: "/", + Endpoint: "http://" + listen, + }, + }, + }) + ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"} + ctx.Artifacts.Add(&artifact.Artifact{ + Type: artifact.UploadableArchive, + Name: "bin.tar.gz", + Path: tgzpath, + }) + ctx.Artifacts.Add(&artifact.Artifact{ + Type: artifact.LinuxPackage, + Name: "bin.deb", + Path: debpath, + }) + name := "root_folder" + start(t, name, listen) + prepareEnv() + require.NoError(t, Pipe{}.Default(ctx)) + require.NoError(t, Pipe{}.Publish(ctx)) +} + func TestMinioUploadInvalidCustomBucketID(t *testing.T) { listen := randomListen(t) folder := t.TempDir()