1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00

32 lines
648 B
Go
Raw Normal View History

2019-01-19 16:57:58 -02:00
package semver
import (
"fmt"
"github.com/Masterminds/semver/v3"
2019-01-19 16:57:58 -02:00
"github.com/goreleaser/goreleaser/pkg/context"
)
// Pipe is a global hook pipe.
2019-01-19 16:57:58 -02:00
type Pipe struct{}
// String is the name of this pipe.
2019-01-19 16:57:58 -02:00
func (Pipe) String() string {
return "parsing tag"
2019-01-19 16:57:58 -02:00
}
// Run executes the hooks.
2019-01-19 16:57:58 -02:00
func (Pipe) Run(ctx *context.Context) error {
sv, err := semver.NewVersion(ctx.Git.CurrentTag)
if err != nil {
return fmt.Errorf("failed to parse tag '%s' as semver: %w", ctx.Git.CurrentTag, err)
2019-01-19 16:57:58 -02:00
}
ctx.Semver = context.Semver{
Major: sv.Major(),
Minor: sv.Minor(),
Patch: sv.Patch(),
Prerelease: sv.Prerelease(),
}
return nil
}