mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
releaser: Adapt release logic to docs submodule
This commit is contained in:
parent
ccb8300d38
commit
00e2fe077a
3 changed files with 39 additions and 16 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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,14 +142,25 @@ func (r *ReleaseHandler) Run() error {
|
|||
}
|
||||
|
||||
if r.shouldPrepareVersions() {
|
||||
// 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 := bumpVersions(newVersion); 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 {
|
||||
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() {
|
||||
fmt.Println("Skip release ... Use --state=3 to continue.")
|
||||
|
@ -164,20 +175,30 @@ 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 {
|
||||
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 {
|
||||
if _, err := git("-C", repo, "push", "origin", tag); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := r.release(releaseNotesFile); err != nil {
|
||||
return err
|
||||
|
@ -192,9 +213,11 @@ 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 {
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue