1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/pipe/project/project.go

33 lines
837 B
Go
Raw Normal View History

// Package project sets "high level" defaults related to the project.
package project
import (
"fmt"
"github.com/goreleaser/goreleaser/pkg/context"
)
// Pipe implemens defaulter to set the project name.
type Pipe struct{}
func (Pipe) String() string {
return "project name"
}
// Default set project defaults.
func (Pipe) Default(ctx *context.Context) error {
if ctx.Config.ProjectName == "" {
switch {
case ctx.Config.Release.GitHub.Name != "":
ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
case ctx.Config.Release.GitLab.Name != "":
ctx.Config.ProjectName = ctx.Config.Release.GitLab.Name
case ctx.Config.Release.Gitea.Name != "":
ctx.Config.ProjectName = ctx.Config.Release.Gitea.Name
default:
return fmt.Errorf("couldn't guess project_name, please add it to your config")
}
}
return nil
}