mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
feat: allow Major, Minor and Patch fields on docker tags
This commit is contained in:
parent
e9351781cb
commit
675e2ea211
@ -11,6 +11,7 @@ import (
|
||||
"text/template"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/masterminds/semver"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
@ -119,13 +120,21 @@ func tagName(ctx *context.Context, tagTemplate string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
sv, err := semver.NewVersion(ctx.Git.CurrentTag)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
data := struct {
|
||||
Version, Tag string
|
||||
Env map[string]string
|
||||
Version, Tag string
|
||||
Major, Minor, Patch int64
|
||||
Env map[string]string
|
||||
}{
|
||||
Version: ctx.Version,
|
||||
Tag: ctx.Git.CurrentTag,
|
||||
Env: ctx.Env,
|
||||
Major: sv.Major(),
|
||||
Minor: sv.Minor(),
|
||||
Patch: sv.Patch(),
|
||||
}
|
||||
err = t.Execute(&out, data)
|
||||
return out.String(), err
|
||||
|
@ -65,6 +65,8 @@ func TestRunPipe(t *testing.T) {
|
||||
Binary: "mybin",
|
||||
TagTemplates: []string{
|
||||
"{{.Tag}}-{{.Env.FOO}}",
|
||||
"v{{.Major}}",
|
||||
"v{{.Major}}.{{.Minor}}",
|
||||
"latest",
|
||||
},
|
||||
Files: []string{
|
||||
@ -73,6 +75,8 @@ func TestRunPipe(t *testing.T) {
|
||||
},
|
||||
expect: []string{
|
||||
registry + "goreleaser/test_run_pipe:v1.0.0-123",
|
||||
registry + "goreleaser/test_run_pipe:v1",
|
||||
registry + "goreleaser/test_run_pipe:v1.0",
|
||||
registry + "goreleaser/test_run_pipe:latest",
|
||||
},
|
||||
err: "",
|
||||
|
Loading…
x
Reference in New Issue
Block a user