| 
									
										
										
										
											2018-10-05 09:22:53 -03:00
										 |  |  | // Package publish contains the publishing pipe. | 
					
						
							|  |  |  | package publish | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-22 01:56:16 -02:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/middleware" | 
					
						
							| 
									
										
										
										
											2018-10-16 22:29:02 -03:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/artifactory" | 
					
						
							| 
									
										
										
										
											2019-06-05 15:51:01 +02:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/blob" | 
					
						
							| 
									
										
										
										
											2018-10-10 12:47:31 -03:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/brew" | 
					
						
							| 
									
										
										
										
											2020-05-10 17:03:49 +01:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/custompublishers" | 
					
						
							| 
									
										
										
										
											2018-10-20 13:45:31 -03:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/docker" | 
					
						
							| 
									
										
										
										
											2020-07-09 16:40:37 -04:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/milestone" | 
					
						
							| 
									
										
										
										
											2018-10-16 20:39:10 -03:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/release" | 
					
						
							| 
									
										
										
										
											2018-10-10 12:47:31 -03:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/scoop" | 
					
						
							| 
									
										
										
										
											2018-10-20 14:25:46 -03:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/snapcraft" | 
					
						
							| 
									
										
										
										
											2019-11-18 10:34:17 -03:00
										 |  |  | 	"github.com/goreleaser/goreleaser/internal/pipe/upload" | 
					
						
							| 
									
										
										
										
											2018-10-05 09:22:53 -03:00
										 |  |  | 	"github.com/goreleaser/goreleaser/pkg/context" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 00:48:10 -03:00
										 |  |  | // Pipe that publishes artifacts. | 
					
						
							| 
									
										
										
										
											2018-10-05 09:22:53 -03:00
										 |  |  | type Pipe struct{} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (Pipe) String() string { | 
					
						
							| 
									
										
										
										
											2018-11-03 15:25:01 -03:00
										 |  |  | 	return "publishing" | 
					
						
							| 
									
										
										
										
											2018-10-05 09:22:53 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 00:48:10 -03:00
										 |  |  | // Publisher should be implemented by pipes that want to publish artifacts. | 
					
						
							| 
									
										
										
										
											2018-10-05 09:22:53 -03:00
										 |  |  | type Publisher interface { | 
					
						
							|  |  |  | 	fmt.Stringer | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Default sets the configuration defaults | 
					
						
							|  |  |  | 	Publish(ctx *context.Context) error | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-07 22:04:49 -02:00
										 |  |  | // nolint: gochecknoglobals | 
					
						
							| 
									
										
										
										
											2018-10-10 12:47:31 -03:00
										 |  |  | var publishers = []Publisher{ | 
					
						
							| 
									
										
										
										
											2019-06-05 15:51:01 +02:00
										 |  |  | 	blob.Pipe{}, | 
					
						
							| 
									
										
										
										
											2019-11-18 10:34:17 -03:00
										 |  |  | 	upload.Pipe{}, | 
					
						
							| 
									
										
										
										
											2020-05-10 17:03:49 +01:00
										 |  |  | 	custompublishers.Pipe{}, | 
					
						
							| 
									
										
										
										
											2018-10-16 22:29:02 -03:00
										 |  |  | 	artifactory.Pipe{}, | 
					
						
							| 
									
										
										
										
											2018-10-20 13:45:31 -03:00
										 |  |  | 	docker.Pipe{}, | 
					
						
							| 
									
										
										
										
											2020-11-28 16:26:37 -03:00
										 |  |  | 	docker.ManifestPipe{}, | 
					
						
							| 
									
										
										
										
											2018-10-20 14:25:46 -03:00
										 |  |  | 	snapcraft.Pipe{}, | 
					
						
							| 
									
										
										
										
											2018-10-27 13:36:26 -03:00
										 |  |  | 	// This should be one of the last steps | 
					
						
							| 
									
										
										
										
											2018-10-25 11:46:30 +01:00
										 |  |  | 	release.Pipe{}, | 
					
						
							| 
									
										
										
										
											2018-10-27 13:36:26 -03:00
										 |  |  | 	// brew and scoop use the release URL, so, they should be last | 
					
						
							|  |  |  | 	brew.Pipe{}, | 
					
						
							|  |  |  | 	scoop.Pipe{}, | 
					
						
							| 
									
										
										
										
											2020-07-09 16:40:37 -04:00
										 |  |  | 	milestone.Pipe{}, | 
					
						
							| 
									
										
										
										
											2018-10-10 12:47:31 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-10-05 09:22:53 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 00:48:10 -03:00
										 |  |  | // Run the pipe. | 
					
						
							| 
									
										
										
										
											2018-10-05 09:22:53 -03:00
										 |  |  | func (Pipe) Run(ctx *context.Context) error { | 
					
						
							|  |  |  | 	for _, publisher := range publishers { | 
					
						
							| 
									
										
										
										
											2019-01-22 01:56:16 -02:00
										 |  |  | 		if err := middleware.Logging( | 
					
						
							|  |  |  | 			publisher.String(), | 
					
						
							|  |  |  | 			middleware.ErrHandler(publisher.Publish), | 
					
						
							|  |  |  | 			middleware.ExtraPadding, | 
					
						
							|  |  |  | 		)(ctx); err != nil { | 
					
						
							| 
									
										
										
										
											2020-09-21 14:47:51 -03:00
										 |  |  | 			return fmt.Errorf("%s: failed to publish artifacts: %w", publisher.String(), err) | 
					
						
							| 
									
										
										
										
											2018-10-05 09:22:53 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return nil | 
					
						
							|  |  |  | } |