1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00
goreleaser/pipeline/env/env.go
Carlos Alexandro Becker bd70d5ef42
improved some logs
2017-06-22 10:47:34 -03:00

40 lines
908 B
Go

// Package env implements the Pipe interface providing validation of
// missing environment variables needed by the release process.
package env
import (
"errors"
"os"
"github.com/apex/log"
"github.com/goreleaser/goreleaser/context"
)
// ErrMissingToken indicates an error when GITHUB_TOKEN is missing in the environment
var ErrMissingToken = errors.New("missing GITHUB_TOKEN")
// Pipe for env
type Pipe struct{}
// Description of the pipe
func (Pipe) Description() string {
return "Loading environment variables"
}
// Run the pipe
func (Pipe) Run(ctx *context.Context) (err error) {
ctx.Token = os.Getenv("GITHUB_TOKEN")
if !ctx.Publish {
log.Warn("github token not validated because publishing has been disabled")
return nil
}
if !ctx.Validate {
log.Warn("skipped validations because --skip-validate is set")
return nil
}
if ctx.Token == "" {
return ErrMissingToken
}
return
}