shithub: hugo

Download patch

ref: 00e2fe077acbb469fe9b10b6bccad3080c0456ed
parent: ccb8300d380636d75a39f4133284eb0109e836c3
author: Bjørn Erik Pedersen <[email protected]>
date: Thu Jun 15 16:36:40 EDT 2017

releaser: Adapt release logic to docs submodule

--- a/releaser/git.go
+++ b/releaser/git.go
@@ -152,7 +152,7 @@
 	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
 }
--- a/releaser/releasenotes_writer.go
+++ b/releaser/releasenotes_writer.go
@@ -160,7 +160,7 @@
 }
 
 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,7 +186,7 @@
 }
 
 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 {
@@ -193,7 +193,7 @@
 	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)
 
--- a/releaser/releaser.go
+++ b/releaser/releaser.go
@@ -128,7 +128,7 @@
 	}
 
 	if r.shouldPrepareReleasenotes() {
-		releaseNotesFile, err := writeReleaseNotesToDocsTemp(version, gitCommits)
+		releaseNotesFile, err := writeReleaseNotesToTemp(version, gitCommits)
 		if err != nil {
 			return err
 		}
@@ -142,13 +142,24 @@
 	}
 
 	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 @@
 		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 @@
 		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