You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	feat: publish snaps
This commit is contained in:
		
				
					committed by
					
						 Carlos Alexandro Becker
						Carlos Alexandro Becker
					
				
			
			
				
	
			
			
			
						parent
						
							24c6401341
						
					
				
				
					commit
					fac4b621b0
				
			| @@ -22,8 +22,12 @@ const ( | ||||
| 	UploadableBinary | ||||
| 	// Binary is a binary (output of a gobuild) | ||||
| 	Binary | ||||
| 	// LinuxPackage is a linux package generated by nfpm or snapcraft | ||||
| 	// LinuxPackage is a linux package generated by nfpm | ||||
| 	LinuxPackage | ||||
| 	// PublishableSnapcraft is a snap package yet to be published | ||||
| 	PublishableSnapcraft | ||||
| 	// Snapcraft is a published snap package | ||||
| 	Snapcraft | ||||
| 	// PublishableDockerImage is a Docker image yet to be published | ||||
| 	PublishableDockerImage | ||||
| 	// DockerImage is a published Docker image | ||||
|   | ||||
| @@ -14,6 +14,7 @@ import ( | ||||
| 	"github.com/goreleaser/goreleaser/internal/pipe/release" | ||||
| 	"github.com/goreleaser/goreleaser/internal/pipe/s3" | ||||
| 	"github.com/goreleaser/goreleaser/internal/pipe/scoop" | ||||
| 	"github.com/goreleaser/goreleaser/internal/pipe/snapcraft" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/context" | ||||
| 	"github.com/pkg/errors" | ||||
| ) | ||||
| @@ -41,6 +42,7 @@ var publishers = []Publisher{ | ||||
| 	brew.Pipe{}, | ||||
| 	scoop.Pipe{}, | ||||
| 	docker.Pipe{}, | ||||
| 	snapcraft.Pipe{}, | ||||
| } | ||||
|  | ||||
| var bold = color.New(color.Bold) | ||||
|   | ||||
| @@ -11,14 +11,13 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/apex/log" | ||||
| 	yaml "gopkg.in/yaml.v2" | ||||
|  | ||||
| 	"github.com/goreleaser/goreleaser/internal/artifact" | ||||
| 	"github.com/goreleaser/goreleaser/internal/linux" | ||||
| 	"github.com/goreleaser/goreleaser/internal/pipe" | ||||
| 	"github.com/goreleaser/goreleaser/internal/semerrgroup" | ||||
| 	"github.com/goreleaser/goreleaser/internal/tmpl" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/context" | ||||
| 	yaml "gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| // ErrNoSnapcraft is shown when snapcraft cannot be found in $PATH | ||||
| @@ -103,6 +102,21 @@ func (Pipe) Run(ctx *context.Context) error { | ||||
| 	return g.Wait() | ||||
| } | ||||
|  | ||||
| // Publish packages | ||||
| func (Pipe) Publish(ctx *context.Context) error { | ||||
| 	snaps := ctx.Artifacts.Filter(artifact.ByType(artifact.PublishableSnapcraft)).List() | ||||
| 	var g = semerrgroup.New(ctx.Parallelism) | ||||
| 	for _, snap := range snaps { | ||||
| 		snap := snap | ||||
| 		g.Go(func() error { | ||||
| 			// TODO | ||||
| 			log.Info(snap.Path) | ||||
| 			return nil | ||||
| 		}) | ||||
| 	} | ||||
| 	return g.Wait() | ||||
| } | ||||
|  | ||||
| func create(ctx *context.Context, arch string, binaries []artifact.Artifact) error { | ||||
| 	var log = log.WithField("arch", arch) | ||||
| 	folder, err := tmpl.New(ctx). | ||||
| @@ -182,7 +196,7 @@ func create(ctx *context.Context, arch string, binaries []artifact.Artifact) err | ||||
| 		return fmt.Errorf("failed to generate snap package: %s", string(out)) | ||||
| 	} | ||||
| 	ctx.Artifacts.Add(artifact.Artifact{ | ||||
| 		Type:   artifact.LinuxPackage, | ||||
| 		Type:   artifact.PublishableSnapcraft, | ||||
| 		Name:   folder + ".snap", | ||||
| 		Path:   snap, | ||||
| 		Goos:   binaries[0].Goos, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user