Skip to content

Commit f76a5ec

Browse files
committed
Update template
Fix spacing on releases. Add tag prefix line Signed-off-by: Derek McGowan <[email protected]>
1 parent ac88082 commit f76a5ec

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

cmd/containerd-release/main.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import (
2424
"path/filepath"
2525
"regexp"
2626
"sort"
27+
"strings"
2728
"text/tabwriter"
2829
"text/template"
30+
"unicode"
2931

3032
"github.com/pkg/errors"
3133
"github.com/sirupsen/logrus"
@@ -84,6 +86,7 @@ type release struct {
8486
Changes []projectChange
8587
Contributors []string
8688
Dependencies []dependency
89+
Tag string
8790
Version string
8891
Downloads []download
8992
}
@@ -105,16 +108,24 @@ This tool should be ran from the root of the project repository for a new releas
105108
Usage: "show debug output",
106109
},
107110
cli.StringFlag{
108-
Name: "template,t",
111+
Name: "tag,t",
112+
Usage: "tag name for the release, defaults to release file name",
113+
},
114+
cli.StringFlag{
115+
Name: "template",
109116
Usage: "template filepath to use in place of the default",
110117
Value: defaultTemplateFile,
111118
},
112119
}
113120
app.Action = func(context *cli.Context) error {
114121
var (
115122
releasePath = context.Args().First()
116-
tag = parseTag(releasePath)
123+
tag = context.String("tag")
117124
)
125+
if tag == "" {
126+
tag = parseTag(releasePath)
127+
}
128+
version := strings.TrimLeft(tag, "v")
118129
if context.Bool("debug") {
119130
logrus.SetLevel(logrus.DebugLevel)
120131
}
@@ -226,7 +237,11 @@ This tool should be ran from the root of the project repository for a new releas
226237
r.Contributors = orderContributors(contributors)
227238
r.Dependencies = updatedDeps
228239
r.Changes = projectChanges
229-
r.Version = tag
240+
r.Tag = tag
241+
r.Version = version
242+
243+
// Remove trailing new lines
244+
r.Preface = strings.TrimRightFunc(r.Preface, unicode.IsSpace)
230245

231246
tmpl, err := getTemplate(context)
232247
if err != nil {

cmd/containerd-release/template.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ package main
1818

1919
const (
2020
defaultTemplateFile = "TEMPLATE"
21-
releaseNotes = `Welcome to the {{.Version}} release of {{.ProjectName}}!
22-
{{if .PreRelease -}}
21+
releaseNotes = `{{.ProjectName}} {{.Version}}
22+
23+
Welcome to the {{.Tag}} release of {{.ProjectName}}!
24+
{{- if .PreRelease }}
2325
*This is a pre-release of {{.ProjectName}}*
2426
{{- end}}
2527

0 commit comments

Comments
 (0)