1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
Carlos Alexandro Becker 08e307ea8d
Revert "fix: skip defaults for skipped pipes (#4210)"
This reverts commit dccd68c1265c969dc9ff2681f70d8347287b0c56.

This breaks `continue` on goreleaser-pro.

Will re-work this for the next release.
2023-08-09 02:43:34 +00:00

47 lines
1.3 KiB
Go

// Package defaults implements the Pipe interface providing default values
// for missing configuration.
package defaults
import (
"fmt"
"strings"
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/middleware/errhandler"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/goreleaser/goreleaser/pkg/defaults"
)
// Pipe that sets the defaults.
type Pipe struct{}
func (Pipe) String() string { return "setting defaults" }
// Run the pipe.
func (Pipe) Run(ctx *context.Context) error {
if ctx.Config.Dist == "" {
ctx.Config.Dist = "dist"
}
if ctx.Config.GitHubURLs.Download == "" {
ctx.Config.GitHubURLs.Download = client.DefaultGitHubDownloadURL
}
if ctx.Config.GitLabURLs.Download == "" {
ctx.Config.GitLabURLs.Download = client.DefaultGitLabDownloadURL
}
if ctx.Config.GiteaURLs.Download == "" {
apiURL, err := tmpl.New(ctx).Apply(ctx.Config.GiteaURLs.API)
if err != nil {
return fmt.Errorf("templating Gitea API URL: %w", err)
}
ctx.Config.GiteaURLs.Download = strings.TrimSuffix(strings.ReplaceAll(apiURL, "/api/v1", ""), "/")
}
for _, defaulter := range defaults.Defaulters {
if err := errhandler.Handle(defaulter.Default)(ctx); err != nil {
return err
}
}
return nil
}