mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
releaser: Make it a one click release for patch releases
This commit is contained in:
parent
e393c6290e
commit
544f826dd6
2 changed files with 39 additions and 18 deletions
|
@ -31,19 +31,27 @@ import (
|
||||||
const (
|
const (
|
||||||
issueLinkTemplate = "[#%d](https://github.com/gohugoio/hugo/issues/%d)"
|
issueLinkTemplate = "[#%d](https://github.com/gohugoio/hugo/issues/%d)"
|
||||||
linkTemplate = "[%s](%s)"
|
linkTemplate = "[%s](%s)"
|
||||||
releaseNotesMarkdownTemplate = `
|
releaseNotesMarkdownTemplatePatchRelease = `
|
||||||
{{- $patchRelease := isPatch . -}}
|
|
||||||
{{- $contribsPerAuthor := .All.ContribCountPerAuthor -}}
|
|
||||||
{{- $docsContribsPerAuthor := .Docs.ContribCountPerAuthor -}}
|
|
||||||
{{- if $patchRelease }}
|
|
||||||
{{ if eq (len .All) 1 }}
|
{{ if eq (len .All) 1 }}
|
||||||
This is a bug-fix release with one important fix.
|
This is a bug-fix release with one important fix.
|
||||||
{{ else }}
|
{{ else }}
|
||||||
This is a bug-fix release with a couple of important fixes.
|
This is a bug-fix release with a couple of important fixes.
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
{{ range .All }}
|
||||||
This release represents **{{ len .All }} contributions by {{ len $contribsPerAuthor }} contributors** to the main Hugo code base.
|
{{- if .GitHubCommit -}}
|
||||||
|
* {{ .Subject }} {{ . | commitURL }} {{ . | authorURL }} {{ range .Issues }}{{ . | issue }}{{ end }}
|
||||||
|
{{ else -}}
|
||||||
|
* {{ .Subject }} {{ range .Issues }}{{ . | issue }}{{ end }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
|
releaseNotesMarkdownTemplate = `
|
||||||
|
{{- $contribsPerAuthor := .All.ContribCountPerAuthor -}}
|
||||||
|
{{- $docsContribsPerAuthor := .Docs.ContribCountPerAuthor -}}
|
||||||
|
|
||||||
|
This release represents **{{ len .All }} contributions by {{ len $contribsPerAuthor }} contributors** to the main Hugo code base.
|
||||||
|
|
||||||
{{- if gt (len $contribsPerAuthor) 3 -}}
|
{{- if gt (len $contribsPerAuthor) 3 -}}
|
||||||
{{- $u1 := index $contribsPerAuthor 0 -}}
|
{{- $u1 := index $contribsPerAuthor 0 -}}
|
||||||
|
@ -53,7 +61,6 @@ This release represents **{{ len .All }} contributions by {{ len $contribsPerAut
|
||||||
{{- $u1.AuthorLink }} leads the Hugo development with a significant amount of contributions, but also a big shoutout to {{ $u2.AuthorLink }}, {{ $u3.AuthorLink }}, and {{ $u4.AuthorLink }} for their ongoing contributions.
|
{{- $u1.AuthorLink }} leads the Hugo development with a significant amount of contributions, but also a big shoutout to {{ $u2.AuthorLink }}, {{ $u3.AuthorLink }}, and {{ $u4.AuthorLink }} for their ongoing contributions.
|
||||||
And a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) and [@onedrawingperday](https://github.com/onedrawingperday) for their relentless work on keeping the themes site in pristine condition and to [@kaushalmodi](https://github.com/kaushalmodi) for his great work on the documentation site.
|
And a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) and [@onedrawingperday](https://github.com/onedrawingperday) for their relentless work on keeping the themes site in pristine condition and to [@kaushalmodi](https://github.com/kaushalmodi) for his great work on the documentation site.
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{- if not $patchRelease }}
|
|
||||||
Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs),
|
Many have also been busy writing and fixing the documentation in [hugoDocs](https://github.com/gohugoio/hugoDocs),
|
||||||
which has received **{{ len .Docs }} contributions by {{ len $docsContribsPerAuthor }} contributors**.
|
which has received **{{ len .Docs }} contributions by {{ len $docsContribsPerAuthor }} contributors**.
|
||||||
{{- if gt (len $docsContribsPerAuthor) 3 -}}
|
{{- if gt (len $docsContribsPerAuthor) 3 -}}
|
||||||
|
@ -62,7 +69,7 @@ which has received **{{ len .Docs }} contributions by {{ len $docsContribsPerAut
|
||||||
{{- $u3 := index $docsContribsPerAuthor 2 -}}
|
{{- $u3 := index $docsContribsPerAuthor 2 -}}
|
||||||
{{- $u4 := index $docsContribsPerAuthor 3 }} A special thanks to {{ $u1.AuthorLink }}, {{ $u2.AuthorLink }}, {{ $u3.AuthorLink }}, and {{ $u4.AuthorLink }} for their work on the documentation site.
|
{{- $u4 := index $docsContribsPerAuthor 3 }} A special thanks to {{ $u1.AuthorLink }}, {{ $u2.AuthorLink }}, {{ $u3.AuthorLink }}, and {{ $u4.AuthorLink }} for their work on the documentation site.
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
|
||||||
Hugo now has:
|
Hugo now has:
|
||||||
|
|
||||||
{{ with .Repo -}}
|
{{ with .Repo -}}
|
||||||
|
@ -151,7 +158,13 @@ func writeReleaseNotes(version string, infosMain, infosDocs gitInfos, to io.Writ
|
||||||
changes.ThemeCount = themeCount
|
changes.ThemeCount = themeCount
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.New("").Funcs(templateFuncs).Parse(releaseNotesMarkdownTemplate)
|
mtempl := releaseNotesMarkdownTemplate
|
||||||
|
|
||||||
|
if !strings.HasSuffix(version, "0") {
|
||||||
|
mtempl = releaseNotesMarkdownTemplatePatchRelease
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpl, err := template.New("").Funcs(templateFuncs).Parse(mtempl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -225,9 +238,9 @@ func (r *ReleaseHandler) releaseNotesState(version string) (releaseNotesState, e
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ReleaseHandler) writeReleaseNotesToTemp(version string, infosMain, infosDocs gitInfos) (string, error) {
|
func (r *ReleaseHandler) writeReleaseNotesToTemp(version string, isPatch bool, infosMain, infosDocs gitInfos) (string, error) {
|
||||||
|
|
||||||
docsTempPath, name := getReleaseNotesDocsTempDirAndName(version, false)
|
docsTempPath, name := getReleaseNotesDocsTempDirAndName(version, isPatch)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
w io.WriteCloser
|
w io.WriteCloser
|
||||||
|
|
|
@ -94,6 +94,7 @@ func (r *ReleaseHandler) Run() error {
|
||||||
|
|
||||||
version := newVersion.String()
|
version := newVersion.String()
|
||||||
tag := "v" + version
|
tag := "v" + version
|
||||||
|
isPatch := newVersion.PatchLevel > 0
|
||||||
|
|
||||||
// Exit early if tag already exists
|
// Exit early if tag already exists
|
||||||
exists, err := tagExists(tag)
|
exists, err := tagExists(tag)
|
||||||
|
@ -128,8 +129,8 @@ func (r *ReleaseHandler) Run() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareRelaseNotes := relNotesState == releaseNotesNone
|
prepareRelaseNotes := isPatch || relNotesState == releaseNotesNone
|
||||||
shouldRelease := relNotesState == releaseNotesReady
|
shouldRelease := isPatch || relNotesState == releaseNotesReady
|
||||||
|
|
||||||
defer r.gitPush() // TODO(bep)
|
defer r.gitPush() // TODO(bep)
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ func (r *ReleaseHandler) Run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if prepareRelaseNotes {
|
if prepareRelaseNotes {
|
||||||
releaseNotesFile, err := r.writeReleaseNotesToTemp(version, gitCommits, gitCommitsDocs)
|
releaseNotesFile, err := r.writeReleaseNotesToTemp(version, isPatch, gitCommits, gitCommitsDocs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -160,7 +161,14 @@ func (r *ReleaseHandler) Run() error {
|
||||||
if _, err := r.git("add", releaseNotesFile); err != nil {
|
if _, err := r.git("add", releaseNotesFile); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err := r.git("commit", "-m", fmt.Sprintf("%s Add release notes draft for %s\n\nRename to *-ready.md to continue. [ci skip]", commitPrefix, newVersion)); err != nil {
|
|
||||||
|
commitMsg := fmt.Sprintf("%s Add release notes for %s", commitPrefix, newVersion)
|
||||||
|
if !isPatch {
|
||||||
|
commitMsg += "\n\nRename to *-ready.md to continue."
|
||||||
|
}
|
||||||
|
commitMsg += "\n[ci skip]"
|
||||||
|
|
||||||
|
if _, err := r.git("commit", "-m", commitMsg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue