1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-03 13:11:48 +02:00
Carlos Alexandro Becker 69c8a502db
chore(deps): bump github.com/golangci/golangci-lint from 1.23.7 to 1.27.0 (#1563)
* chore(deps): bump github.com/golangci/golangci-lint from 1.23.7 to 1.27.0

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

* fix: tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2020-05-26 00:48:10 -03:00

42 lines
969 B
Go

package semver
import (
"github.com/Masterminds/semver/v3"
"github.com/apex/log"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/pkg/errors"
)
// 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 {
if ctx.Snapshot {
return pipe.ErrSnapshotEnabled
}
if ctx.SkipValidate {
log.WithError(err).
WithField("tag", ctx.Git.CurrentTag).
Warn("current tag is not a semantic tag")
return pipe.ErrSkipValidateEnabled
}
return errors.Wrapf(err, "failed to parse tag %s as semver", ctx.Git.CurrentTag)
}
ctx.Semver = context.Semver{
Major: sv.Major(),
Minor: sv.Minor(),
Patch: sv.Patch(),
Prerelease: sv.Prerelease(),
}
return nil
}