1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +02:00
Weslei Juan Novaes Pereira f9b693edf0
feat: add hooks to universal binaries (#2684)
* add hooks for universal binaries

* task fmt
2021-11-23 15:53:12 -03:00

33 lines
799 B
Go

// Package skip can skip an entire Action.
package skip
import (
"fmt"
"github.com/apex/log"
"github.com/goreleaser/goreleaser/internal/middleware"
"github.com/goreleaser/goreleaser/pkg/context"
)
// Skipper defines a method to skip an entire Piper.
type Skipper interface {
// Skip returns true if the Piper should be skipped.
Skip(ctx *context.Context) bool
fmt.Stringer
}
// Maybe returns an action that skips immediately if the given p is a Skipper
// and its Skip method returns true.
func Maybe(skipper interface{}, next middleware.Action) middleware.Action {
if skipper, ok := skipper.(Skipper); ok {
return func(ctx *context.Context) error {
if skipper.Skip(ctx) {
log.Debugf("skipped %s", skipper.String())
return nil
}
return next(ctx)
}
}
return next
}