diff options
Diffstat (limited to 'releaser/releasenotes_writer.go')
-rw-r--r-- | releaser/releasenotes_writer.go | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/releaser/releasenotes_writer.go b/releaser/releasenotes_writer.go index 9dbdf61a8..ced9254af 100644 --- a/releaser/releasenotes_writer.go +++ b/releaser/releasenotes_writer.go @@ -193,29 +193,49 @@ func getReleaseNotesDocsTempFilename(version string) string { return filepath.Join(getReleaseNotesDocsTempDirAndName(version)) } -func writeReleaseNotesToTemp(version string, infos gitInfos) (string, error) { +func (r *ReleaseHandler) writeReleaseNotesToTemp(version string, infos gitInfos) (string, error) { + docsTempPath, name := getReleaseNotesDocsTempDirAndName(version) - os.Mkdir(docsTempPath, os.ModePerm) - f, err := os.Create(filepath.Join(docsTempPath, name)) - if err != nil { - return "", err - } + var ( + w io.WriteCloser + ) - defer f.Close() + if !r.try { + os.Mkdir(docsTempPath, os.ModePerm) - if err := writeReleaseNotes(version, infos, f); err != nil { + f, err := os.Create(filepath.Join(docsTempPath, name)) + if err != nil { + return "", err + } + + name = f.Name() + + defer f.Close() + + w = f + + } else { + w = os.Stdout + } + + if err := writeReleaseNotes(version, infos, w); err != nil { return "", err } - return f.Name(), nil + return name, nil } -func writeReleaseNotesToDocs(title, sourceFilename string) (string, error) { +func (r *ReleaseHandler) writeReleaseNotesToDocs(title, sourceFilename string) (string, error) { targetFilename := filepath.Base(sourceFilename) contentDir := hugoFilepath("docs/content/release-notes") targetFullFilename := filepath.Join(contentDir, targetFilename) + + if r.try { + return targetFullFilename, nil + } + os.Mkdir(contentDir, os.ModePerm) b, err := ioutil.ReadFile(sourceFilename) |