Add template filepath for release tool

This allows a project to have a TEMPLATE file in the root of the repo to
be used with the release tool.  If they don't have this file and did not
specify a custom file then it will use the compiled in template in the
release tool.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-10-30 13:15:56 -04:00
parent 5fb3a0e0cf
commit adc502b790
3 changed files with 37 additions and 2 deletions

View File

@@ -61,6 +61,11 @@ This tool should be ran from the root of the project repository for a new releas
Name: "dry,n",
Usage: "run the release tooling as a dry run to print the release notes to stdout",
},
cli.StringFlag{
Name: "template,t",
Usage: "template filepath to use in place of the default",
Value: defaultTemplateFile,
},
}
app.Action = func(context *cli.Context) error {
var (
@@ -100,8 +105,13 @@ This tool should be ran from the root of the project repository for a new releas
r.Changes = changes
r.Version = tag
tmpl, err := getTemplate(context)
if err != nil {
return err
}
if context.Bool("dry") {
t, err := template.New("release-notes").Parse(releaseNotes)
t, err := template.New("release-notes").Parse(tmpl)
if err != nil {
return err
}