1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-07-17 01:42:37 +02:00

Reduce the number of concurrent builds

With many GOOS OARCH combos, the CPU is glowing.
This commit is contained in:
Bjørn Erik Pedersen
2017-04-21 14:40:25 +02:00
parent 880b2c22ed
commit 6db75f7ca9

View File

@ -28,9 +28,11 @@ func (Pipe) Run(ctx *context.Context) error {
if err := runHook(ctx.Config.Build.Hooks.Pre); err != nil { if err := runHook(ctx.Config.Build.Hooks.Pre); err != nil {
return err return err
} }
sem := make(chan bool, 4)
var g errgroup.Group var g errgroup.Group
for _, goos := range ctx.Config.Build.Goos { for _, goos := range ctx.Config.Build.Goos {
for _, goarch := range ctx.Config.Build.Goarch { for _, goarch := range ctx.Config.Build.Goarch {
sem <- true
goos := goos goos := goos
goarch := goarch goarch := goarch
if !valid(goos, goarch) { if !valid(goos, goarch) {
@ -42,6 +44,9 @@ func (Pipe) Run(ctx *context.Context) error {
} }
ctx.Archives[goos+goarch] = name ctx.Archives[goos+goarch] = name
g.Go(func() error { g.Go(func() error {
defer func() {
<-sem
}()
return build(name, goos, goarch, ctx) return build(name, goos, goarch, ctx)
}) })
} }