diff options
-rw-r--r-- | releaser/git.go | 2 | ||||
-rw-r--r-- | releaser/releasenotes_writer.go | 6 | ||||
-rw-r--r-- | releaser/releaser.go | 47 |
3 files changed, 39 insertions, 16 deletions
diff --git a/releaser/git.go b/releaser/git.go index 654ea78f0..4962c3693 100644 --- a/releaser/git.go +++ b/releaser/git.go @@ -152,7 +152,7 @@ func git(args ...string) (string, error) { cmd := exec.Command("git", args...) out, err := cmd.CombinedOutput() if err != nil { - return "", fmt.Errorf("git failed: %q: %q", err, out) + return "", fmt.Errorf("git failed: %q: %q (%q)", err, out, args) } return string(out), nil } diff --git a/releaser/releasenotes_writer.go b/releaser/releasenotes_writer.go index 9e3e6414d..d892eb7fa 100644 --- a/releaser/releasenotes_writer.go +++ b/releaser/releasenotes_writer.go @@ -160,7 +160,7 @@ func writeReleaseNotes(version string, infos gitInfos, to io.Writer) error { } func fetchThemeCount() (int, error) { - resp, err := http.Get("https://github.com/gohugoio/hugoThemes/blob/master/.gitmodules") + resp, err := http.Get("https://raw.githubusercontent.com/gohugoio/hugoThemes/master/.gitmodules") if err != nil { return 0, err } @@ -186,14 +186,14 @@ func writeReleaseNotesToTmpFile(version string, infos gitInfos) (string, error) } func getRelaseNotesDocsTempDirAndName(version string) (string, string) { - return hugoFilepath("docs/temp"), fmt.Sprintf("%s-relnotes.md", version) + return hugoFilepath("temp"), fmt.Sprintf("%s-relnotes.md", version) } func getRelaseNotesDocsTempFilename(version string) string { return filepath.Join(getRelaseNotesDocsTempDirAndName(version)) } -func writeReleaseNotesToDocsTemp(version string, infos gitInfos) (string, error) { +func writeReleaseNotesToTemp(version string, infos gitInfos) (string, error) { docsTempPath, name := getRelaseNotesDocsTempDirAndName(version) os.Mkdir(docsTempPath, os.ModePerm) diff --git a/releaser/releaser.go b/releaser/releaser.go index 17529acf2..230a498e6 100644 --- a/releaser/releaser.go +++ b/releaser/releaser.go @@ -128,7 +128,7 @@ func (r *ReleaseHandler) Run() error { } if r.shouldPrepareReleasenotes() { - releaseNotesFile, err := writeReleaseNotesToDocsTemp(version, gitCommits) + releaseNotesFile, err := writeReleaseNotesToTemp(version, gitCommits) if err != nil { return err } @@ -142,13 +142,24 @@ func (r *ReleaseHandler) Run() error { } if r.shouldPrepareVersions() { - if err := bumpVersions(newVersion); err != nil { + // Make sure the docs submodule is up to date. + if _, err := git("submodule", "update", "--remote", "--merge"); err != nil { + return err + } + // TODO(bep) the above may not have changed anything. + if _, err := git("commit", "-a", "-m", fmt.Sprintf("%s Update /docs [ci skip]", commitPrefix)); err != nil { return err } - if _, err := git("commit", "-a", "-m", fmt.Sprintf("%s Bump versions for release of %s\n\n[ci skip]", commitPrefix, newVersion)); err != nil { + if err := bumpVersions(newVersion); err != nil { return err } + + for _, repo := range []string{"docs", "."} { + if _, err := git("-C", repo, "commit", "-a", "-m", fmt.Sprintf("%s Bump versions for release of %s\n\n[ci skip]", commitPrefix, newVersion)); err != nil { + return err + } + } } if !r.shouldRelease() { @@ -164,19 +175,29 @@ func (r *ReleaseHandler) Run() error { return err } - if _, err := git("add", docFile); err != nil { + if _, err := git("-C", "docs", "add", docFile); err != nil { return err } - if _, err := git("commit", "-m", fmt.Sprintf("%s Add relase notes to /docs for release of %s\n\n[ci skip]", commitPrefix, newVersion)); err != nil { + if _, err := git("-C", "docs", "commit", "-m", fmt.Sprintf("%s Add relase notes to /docs for release of %s\n\n[ci skip]", commitPrefix, newVersion)); err != nil { return err } - if _, err := git("tag", "-a", tag, "-m", fmt.Sprintf("%s %s [ci deploy]", commitPrefix, newVersion)); err != nil { - return err - } + for i, repo := range []string{"docs", "."} { + if i == 1 { + if _, err := git("add", "docs"); err != nil { + return err + } + if _, err := git("commit", "-m", fmt.Sprintf("%s Update /docs to %s [ci skip]", commitPrefix, newVersion)); err != nil { + return err + } + } + if _, err := git("-C", repo, "tag", "-a", tag, "-m", fmt.Sprintf("%s %s [ci deploy]", commitPrefix, newVersion)); err != nil { + return err + } - if _, err := git("push", "origin", tag); err != nil { - return err + if _, err := git("-C", repo, "push", "origin", tag); err != nil { + return err + } } if err := r.release(releaseNotesFile); err != nil { @@ -192,8 +213,10 @@ func (r *ReleaseHandler) Run() error { return err } - if _, err := git("commit", "-a", "-m", fmt.Sprintf("%s Prepare repository for %s\n\n[ci skip]", commitPrefix, finalVersion)); err != nil { - return err + for _, repo := range []string{"docs", "."} { + if _, err := git("-C", repo, "commit", "-a", "-m", fmt.Sprintf("%s Prepare repository for %s\n\n[ci skip]", commitPrefix, finalVersion)); err != nil { + return err + } } return nil |