mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-26 04:22:05 +02:00
feat: docker in parallel
This commit is contained in:
parent
60001bf63c
commit
32ca896a24
@ -141,6 +141,8 @@ func And(filters ...Filter) Filter {
|
|||||||
// is accepted.
|
// is accepted.
|
||||||
// You can compose filters by using the And and Or filters.
|
// You can compose filters by using the And and Or filters.
|
||||||
func (artifacts *Artifacts) Filter(filter Filter) Artifacts {
|
func (artifacts *Artifacts) Filter(filter Filter) Artifacts {
|
||||||
|
// TODO: this could be done lazily and the real job could be done in the
|
||||||
|
// #List() method maybe?
|
||||||
var result = New()
|
var result = New()
|
||||||
for _, a := range artifacts.items {
|
for _, a := range artifacts.items {
|
||||||
if filter(a) {
|
if filter(a) {
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"github.com/goreleaser/goreleaser/config"
|
"github.com/goreleaser/goreleaser/config"
|
||||||
"github.com/goreleaser/goreleaser/context"
|
"github.com/goreleaser/goreleaser/context"
|
||||||
@ -69,31 +70,40 @@ func (Pipe) Run(ctx *context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doRun(ctx *context.Context) error {
|
func doRun(ctx *context.Context) error {
|
||||||
// TODO: could be done in parallel.
|
var g errgroup.Group
|
||||||
|
sem := make(chan bool, ctx.Parallelism)
|
||||||
for _, docker := range ctx.Config.Dockers {
|
for _, docker := range ctx.Config.Dockers {
|
||||||
log.WithField("docker", docker).Debug("looking for binaries matching")
|
docker := docker
|
||||||
var binaries = ctx.Artifacts.Filter(
|
sem <- true
|
||||||
artifact.And(
|
g.Go(func() error {
|
||||||
artifact.ByGoos(docker.Goos),
|
defer func() {
|
||||||
artifact.ByGoarch(docker.Goarch),
|
<-sem
|
||||||
artifact.ByGoarm(docker.Goarm),
|
}()
|
||||||
artifact.ByType(artifact.Binary),
|
log.WithField("docker", docker).Debug("looking for binaries matching")
|
||||||
func(a artifact.Artifact) bool {
|
var binaries = ctx.Artifacts.Filter(
|
||||||
return a.Extra["Binary"] == docker.Binary
|
artifact.And(
|
||||||
},
|
artifact.ByGoos(docker.Goos),
|
||||||
),
|
artifact.ByGoarch(docker.Goarch),
|
||||||
).List()
|
artifact.ByGoarm(docker.Goarm),
|
||||||
if len(binaries) == 0 {
|
artifact.ByType(artifact.Binary),
|
||||||
log.Warn("no binaries found")
|
func(a artifact.Artifact) bool {
|
||||||
}
|
return a.Extra["Binary"] == docker.Binary
|
||||||
for _, binary := range binaries {
|
},
|
||||||
var err = process(ctx, docker, binary)
|
),
|
||||||
if err != nil && !pipeline.IsSkip(err) {
|
).List()
|
||||||
return err
|
if len(binaries) == 0 {
|
||||||
|
log.Warn("no binaries found")
|
||||||
}
|
}
|
||||||
}
|
for _, binary := range binaries {
|
||||||
|
var err = process(ctx, docker, binary)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return nil
|
return g.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func tagName(ctx *context.Context, docker config.Docker) (string, error) {
|
func tagName(ctx *context.Context, docker config.Docker) (string, error) {
|
||||||
@ -167,10 +177,8 @@ func link(src, dest string) error {
|
|||||||
func publish(ctx *context.Context, docker config.Docker, image, latest string) error {
|
func publish(ctx *context.Context, docker config.Docker, image, latest string) error {
|
||||||
// TODO: improve this so it can log it to stdout
|
// TODO: improve this so it can log it to stdout
|
||||||
if !ctx.Publish {
|
if !ctx.Publish {
|
||||||
return pipeline.Skip("--skip-publish is set")
|
log.Warn("skipping push because --skip-publish is set")
|
||||||
}
|
return nil
|
||||||
if ctx.Config.Release.Draft {
|
|
||||||
return pipeline.Skip("release is marked as draft")
|
|
||||||
}
|
}
|
||||||
if err := dockerPush(ctx, image); err != nil {
|
if err := dockerPush(ctx, image); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user