mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-23 21:19:17 +02:00
<!-- Hi, thanks for contributing! Please make sure you read our CONTRIBUTING guide. Also, add tests and the respective documentation changes as well. --> <!-- If applied, this commit will... --> ... <!-- Why is this change being made? --> ... <!-- # Provide links to any relevant tickets, URLs or other resources --> ... --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
32 lines
651 B
Go
32 lines
651 B
Go
package semver
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/Masterminds/semver/v3"
|
|
"github.com/goreleaser/goreleaser/v2/pkg/context"
|
|
)
|
|
|
|
// Pipe is a global hook pipe.
|
|
type Pipe struct{}
|
|
|
|
// String is the name of this pipe.
|
|
func (Pipe) String() string {
|
|
return "parsing tag"
|
|
}
|
|
|
|
// Run executes the hooks.
|
|
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)
|
|
}
|
|
ctx.Semver = context.Semver{
|
|
Major: sv.Major(),
|
|
Minor: sv.Minor(),
|
|
Patch: sv.Patch(),
|
|
Prerelease: sv.Prerelease(),
|
|
}
|
|
return nil
|
|
}
|