github.com/triarius/goreleaser@v1.12.5/internal/pipe/blob/blob.go (about) 1 // Package blob provides the pipe implementation that uploads files to "blob" providers, such as s3, gcs and azure. 2 package blob 3 4 import ( 5 "fmt" 6 7 "github.com/triarius/goreleaser/internal/semerrgroup" 8 "github.com/triarius/goreleaser/pkg/context" 9 ) 10 11 // Pipe for blobs. 12 type Pipe struct{} 13 14 // String returns the description of the pipe. 15 func (Pipe) String() string { return "blobs" } 16 func (Pipe) Skip(ctx *context.Context) bool { return len(ctx.Config.Blobs) == 0 } 17 18 // Default sets the pipe defaults. 19 func (Pipe) Default(ctx *context.Context) error { 20 for i := range ctx.Config.Blobs { 21 blob := &ctx.Config.Blobs[i] 22 23 if blob.Bucket == "" || blob.Provider == "" { 24 return fmt.Errorf("bucket or provider cannot be empty") 25 } 26 if blob.Folder == "" { 27 blob.Folder = "{{ .ProjectName }}/{{ .Tag }}" 28 } 29 } 30 return nil 31 } 32 33 // Publish to specified blob bucket url. 34 func (Pipe) Publish(ctx *context.Context) error { 35 g := semerrgroup.New(ctx.Parallelism) 36 for _, conf := range ctx.Config.Blobs { 37 conf := conf 38 g.Go(func() error { 39 return doUpload(ctx, conf) 40 }) 41 } 42 return g.Wait() 43 }