mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-08 03:31:59 +02:00
fe7e2123bd
* feat: replacing logs Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: tests et al Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * feat: update termenv/lipgloss Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * wip: output Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: pin dep Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: update Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: tests Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: tests Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: deps Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * fix: dep Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
38 lines
1016 B
Go
38 lines
1016 B
Go
// Package snapshot provides the snapshotting functionality to goreleaser.
|
|
package snapshot
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/caarlos0/log"
|
|
"github.com/goreleaser/goreleaser/internal/tmpl"
|
|
"github.com/goreleaser/goreleaser/pkg/context"
|
|
)
|
|
|
|
// Pipe for checksums.
|
|
type Pipe struct{}
|
|
|
|
func (Pipe) String() string { return "snapshotting" }
|
|
func (Pipe) Skip(ctx *context.Context) bool { return !ctx.Snapshot }
|
|
|
|
// Default sets the pipe defaults.
|
|
func (Pipe) Default(ctx *context.Context) error {
|
|
if ctx.Config.Snapshot.NameTemplate == "" {
|
|
ctx.Config.Snapshot.NameTemplate = "{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}"
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (Pipe) Run(ctx *context.Context) error {
|
|
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
|
|
log.WithField("version", ctx.Version).Infof("building snapshot...")
|
|
return nil
|
|
}
|