github.com/amane3/goreleaser@v0.182.0/internal/pipe/publish/publish.go (about)

     1  // Package publish contains the publishing pipe.
     2  package publish
     3  
     4  import (
     5  	"fmt"
     6  
     7  	"github.com/amane3/goreleaser/internal/middleware"
     8  	"github.com/amane3/goreleaser/internal/pipe/artifactory"
     9  	"github.com/amane3/goreleaser/internal/pipe/blob"
    10  	"github.com/amane3/goreleaser/internal/pipe/brew"
    11  	"github.com/amane3/goreleaser/internal/pipe/custompublishers"
    12  	"github.com/amane3/goreleaser/internal/pipe/docker"
    13  	"github.com/amane3/goreleaser/internal/pipe/milestone"
    14  	"github.com/amane3/goreleaser/internal/pipe/release"
    15  	"github.com/amane3/goreleaser/internal/pipe/scoop"
    16  	"github.com/amane3/goreleaser/internal/pipe/snapcraft"
    17  	"github.com/amane3/goreleaser/internal/pipe/upload"
    18  	"github.com/amane3/goreleaser/pkg/context"
    19  )
    20  
    21  // Pipe that publishes artifacts.
    22  type Pipe struct{}
    23  
    24  func (Pipe) String() string {
    25  	return "publishing"
    26  }
    27  
    28  // Publisher should be implemented by pipes that want to publish artifacts.
    29  type Publisher interface {
    30  	fmt.Stringer
    31  
    32  	// Default sets the configuration defaults
    33  	Publish(ctx *context.Context) error
    34  }
    35  
    36  // nolint: gochecknoglobals
    37  var publishers = []Publisher{
    38  	blob.Pipe{},
    39  	upload.Pipe{},
    40  	custompublishers.Pipe{},
    41  	artifactory.Pipe{},
    42  	docker.Pipe{},
    43  	docker.ManifestPipe{},
    44  	snapcraft.Pipe{},
    45  	// This should be one of the last steps
    46  	release.Pipe{},
    47  	// brew and scoop use the release URL, so, they should be last
    48  	brew.Pipe{},
    49  	scoop.Pipe{},
    50  	milestone.Pipe{},
    51  }
    52  
    53  // Run the pipe.
    54  func (Pipe) Run(ctx *context.Context) error {
    55  	for _, publisher := range publishers {
    56  		if err := middleware.Logging(
    57  			publisher.String(),
    58  			middleware.ErrHandler(publisher.Publish),
    59  			middleware.ExtraPadding,
    60  		)(ctx); err != nil {
    61  			return fmt.Errorf("%s: failed to publish artifacts: %w", publisher.String(), err)
    62  		}
    63  	}
    64  	return nil
    65  }