Skip to content

Commit

Permalink
fix: upload gcs blobs to bucket root (#2409)
Browse files Browse the repository at this point in the history
* fix: upload gcs blobs to bucket root

* test: blob upload to bucket root

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: Adam Bouqdib <adam@abemedia.co.uk>
  • Loading branch information
caarlos0 and abemedia committed Aug 17, 2021
1 parent 43b91b6 commit 3966921
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
37 changes: 37 additions & 0 deletions internal/pipe/blob/blob_minio_test.go
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions internal/pipe/blob/upload.go
Expand Up @@ -6,6 +6,7 @@ import (
"net/url"
"os"
"path"
"strings"

"github.com/apex/log"
"github.com/goreleaser/goreleaser/internal/artifact"
Expand Down Expand Up @@ -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 {
Expand Down

1 comment on commit 3966921

@vercel
Copy link

@vercel vercel bot commented on 3966921 Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.