diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-05-22 16:04:40 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-05-22 16:04:40 +0300 |
commit | baa414ae414e8b0da365cfb756af0177dbdc003f (patch) | |
tree | 2b8dbdc182051dbafb05e1dc3f82ad481bc86dc2 /releaser/releaser.go | |
parent | cdf32f08c7aa5a362c75b541821983a970ffd2ef (diff) |
releaser: Add a new step
When doing it step-by-step, we need to update the version numbers in its own step.
Diffstat (limited to 'releaser/releaser.go')
-rw-r--r-- | releaser/releaser.go | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/releaser/releaser.go b/releaser/releaser.go index 088b52ec1..afb5fcddb 100644 --- a/releaser/releaser.go +++ b/releaser/releaser.go @@ -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,17 +141,19 @@ func (r *ReleaseHandler) Run() error { } } - if !r.shouldRelease() { - fmt.Println("Skip release ... Use --state=2 to continue.") - return nil - } + if r.shouldPrepareVersions() { + if err := bumpVersions(newVersion); 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 { + 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=3 to continue.") + return nil } releaseNotesFile := getRelaseNotesDocsTempFilename(version) |