1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
Carlos Alexandro Becker 65ffbf1921
refactor: replace pkg/errors.Wrap with fmt.Errorf (#1812)
* refactor: remove pkg/errors

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* refactor: remove pkg/errors

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-09-21 17:47:51 +00:00

41 lines
942 B
Go

// Package snapshot provides the snapshotting functionality to goreleaser.
package snapshot
import (
"fmt"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/tmpl"
"github.com/goreleaser/goreleaser/pkg/context"
)
// Pipe for checksums.
type Pipe struct{}
func (Pipe) String() string {
return "snapshotting"
}
// Default sets the pipe defaults.
func (Pipe) Default(ctx *context.Context) error {
if ctx.Config.Snapshot.NameTemplate == "" {
ctx.Config.Snapshot.NameTemplate = "{{ .Tag }}-SNAPSHOT-{{ .ShortCommit }}"
}
return nil
}
func (Pipe) Run(ctx *context.Context) error {
if !ctx.Snapshot {
return pipe.Skip("not a snapshot")
}
name, err := tmpl.New(ctx).Apply(ctx.Config.Snapshot.NameTemplate)
if err != nil {
return fmt.Errorf("failed to generate snapshot name: %w", err)
}
if name == "" {
return fmt.Errorf("empty snapshot name")
}
ctx.Version = name
return nil
}