Update template

Fix spacing on releases.
Add tag prefix line

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan 2018-08-28 16:12:56 -07:00
parent ac88082399
commit f76a5ec83a
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB
2 changed files with 22 additions and 5 deletions

View File

@ -24,8 +24,10 @@ import (
"path/filepath" "path/filepath"
"regexp" "regexp"
"sort" "sort"
"strings"
"text/tabwriter" "text/tabwriter"
"text/template" "text/template"
"unicode"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -84,6 +86,7 @@ type release struct {
Changes []projectChange Changes []projectChange
Contributors []string Contributors []string
Dependencies []dependency Dependencies []dependency
Tag string
Version string Version string
Downloads []download Downloads []download
} }
@ -105,7 +108,11 @@ This tool should be ran from the root of the project repository for a new releas
Usage: "show debug output", Usage: "show debug output",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "template,t", Name: "tag,t",
Usage: "tag name for the release, defaults to release file name",
},
cli.StringFlag{
Name: "template",
Usage: "template filepath to use in place of the default", Usage: "template filepath to use in place of the default",
Value: defaultTemplateFile, Value: defaultTemplateFile,
}, },
@ -113,8 +120,12 @@ This tool should be ran from the root of the project repository for a new releas
app.Action = func(context *cli.Context) error { app.Action = func(context *cli.Context) error {
var ( var (
releasePath = context.Args().First() releasePath = context.Args().First()
tag = parseTag(releasePath) tag = context.String("tag")
) )
if tag == "" {
tag = parseTag(releasePath)
}
version := strings.TrimLeft(tag, "v")
if context.Bool("debug") { if context.Bool("debug") {
logrus.SetLevel(logrus.DebugLevel) logrus.SetLevel(logrus.DebugLevel)
} }
@ -226,7 +237,11 @@ This tool should be ran from the root of the project repository for a new releas
r.Contributors = orderContributors(contributors) r.Contributors = orderContributors(contributors)
r.Dependencies = updatedDeps r.Dependencies = updatedDeps
r.Changes = projectChanges r.Changes = projectChanges
r.Version = tag r.Tag = tag
r.Version = version
// Remove trailing new lines
r.Preface = strings.TrimRightFunc(r.Preface, unicode.IsSpace)
tmpl, err := getTemplate(context) tmpl, err := getTemplate(context)
if err != nil { if err != nil {

View File

@ -18,8 +18,10 @@ package main
const ( const (
defaultTemplateFile = "TEMPLATE" defaultTemplateFile = "TEMPLATE"
releaseNotes = `Welcome to the {{.Version}} release of {{.ProjectName}}! releaseNotes = `{{.ProjectName}} {{.Version}}
{{if .PreRelease -}}
Welcome to the {{.Tag}} release of {{.ProjectName}}!
{{- if .PreRelease }}
*This is a pre-release of {{.ProjectName}}* *This is a pre-release of {{.ProjectName}}*
{{- end}} {{- end}}