1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/internal/client/name.go
2018-04-01 15:57:25 -03:00

41 lines
723 B
Go

package client
import (
"bytes"
"text/template"
"time"
"github.com/goreleaser/goreleaser/context"
)
var (
timeNow = time.Now
)
func releaseTitle(ctx *context.Context) (string, error) {
var out bytes.Buffer
t, err := template.New("github").
Option("missingkey=error").
Funcs(mkFuncMap()).
Parse(ctx.Config.Release.NameTemplate)
if err != nil {
return "", err
}
err = t.Execute(&out, struct {
ProjectName, Tag, Version string
}{
ProjectName: ctx.Config.ProjectName,
Tag: ctx.Git.CurrentTag,
Version: ctx.Version,
})
return out.String(), err
}
func mkFuncMap() template.FuncMap {
return template.FuncMap{
"time": func(s string) string {
return timeNow().Format(s)
},
}
}