mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
releaser: Add a new step
When doing it step-by-step, we need to update the version numbers in its own step.
This commit is contained in:
parent
cdf32f08c7
commit
baa414ae41
2 changed files with 27 additions and 16 deletions
|
@ -31,7 +31,12 @@ import (
|
|||
const commitPrefix = "releaser:"
|
||||
|
||||
type ReleaseHandler struct {
|
||||
patch int
|
||||
patch int
|
||||
|
||||
// If set, we do the relases in 3 steps:
|
||||
// 1: Create and write a draft release notes
|
||||
// 2: Prepare files for new version.
|
||||
// 3: Release
|
||||
step int
|
||||
skipPublish bool
|
||||
}
|
||||
|
@ -41,13 +46,17 @@ func (r ReleaseHandler) shouldRelease() bool {
|
|||
}
|
||||
|
||||
func (r ReleaseHandler) shouldContinue() bool {
|
||||
return r.step == 2
|
||||
return r.step == 3
|
||||
}
|
||||
|
||||
func (r ReleaseHandler) shouldPrepare() bool {
|
||||
func (r ReleaseHandler) shouldPrepareReleasenotes() bool {
|
||||
return r.step < 1 || r.step == 1
|
||||
}
|
||||
|
||||
func (r ReleaseHandler) shouldPrepareVersions() bool {
|
||||
return r.step < 1 || r.step == 2
|
||||
}
|
||||
|
||||
func (r ReleaseHandler) calculateVersions(current helpers.HugoVersion) (helpers.HugoVersion, helpers.HugoVersion) {
|
||||
var (
|
||||
newVersion = current
|
||||
|
@ -111,14 +120,14 @@ func (r *ReleaseHandler) Run() error {
|
|||
|
||||
var gitCommits gitInfos
|
||||
|
||||
if r.shouldPrepare() || r.shouldRelease() {
|
||||
if r.shouldPrepareReleasenotes() || r.shouldRelease() {
|
||||
gitCommits, err = getGitInfos(changeLogFromTag, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if r.shouldPrepare() {
|
||||
if r.shouldPrepareReleasenotes() {
|
||||
releaseNotesFile, err := writeReleaseNotesToDocsTemp(version, gitCommits)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -132,19 +141,21 @@ func (r *ReleaseHandler) Run() error {
|
|||
}
|
||||
}
|
||||
|
||||
if r.shouldPrepareVersions() {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if !r.shouldRelease() {
|
||||
fmt.Println("Skip release ... Use --state=2 to continue.")
|
||||
fmt.Println("Skip release ... Use --state=3 to continue.")
|
||||
return nil
|
||||
}
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
||||
releaseNotesFile := getRelaseNotesDocsTempFilename(version)
|
||||
|
||||
// Write the release notes to the docs site as well.
|
||||
|
|
|
@ -51,7 +51,7 @@ func TestCalculateVersions(t *testing.T) {
|
|||
"0.21-DEV",
|
||||
},
|
||||
{
|
||||
New(0, 2, true),
|
||||
New(0, 3, true),
|
||||
startVersion,
|
||||
"0.20",
|
||||
"0.21-DEV",
|
||||
|
@ -63,7 +63,7 @@ func TestCalculateVersions(t *testing.T) {
|
|||
"0.20-DEV",
|
||||
},
|
||||
{
|
||||
New(3, 2, true),
|
||||
New(3, 3, true),
|
||||
startVersion.Next(),
|
||||
"0.21",
|
||||
"0.21-DEV",
|
||||
|
|
Loading…
Reference in a new issue