diff --git a/out_command.go b/out_command.go index 40220b9..dbb9ea9 100644 --- a/out_command.go +++ b/out_command.go @@ -79,6 +79,7 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err existingRelease.Name = github.String(name) existingRelease.Body = github.String(body) existingRelease.TargetCommitish = github.String(targetCommitish) + existingRelease.Draft = github.Bool(draft) for _, asset := range existingRelease.Assets { fmt.Fprintf(c.writer, "clearing existing asset: %s\n", *asset.Name) diff --git a/out_command_test.go b/out_command_test.go index 2fa92a4..762e718 100644 --- a/out_command_test.go +++ b/out_command_test.go @@ -112,6 +112,34 @@ var _ = Describe("Out Command", func() { Ω(githubClient.DeleteReleaseAssetArgsForCall(1)).Should(Equal(existingAssets[1])) }) + Context("when not set as a draft release", func() { + BeforeEach(func() { + request.Source.Drafts = false + }) + + It("updates the existing release to a non-draft", func() { + Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1)) + + updatedRelease := githubClient.UpdateReleaseArgsForCall(0) + Ω(*updatedRelease.Name).Should(Equal("v0.3.12")) + Ω(*updatedRelease.Draft).Should(Equal(false)) + }) + }) + + Context("when set as a draft release", func() { + BeforeEach(func() { + request.Source.Drafts = true + }) + + It("updates the existing release to a draft", func() { + Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1)) + + updatedRelease := githubClient.UpdateReleaseArgsForCall(0) + Ω(*updatedRelease.Name).Should(Equal("v0.3.12")) + Ω(*updatedRelease.Draft).Should(Equal(true)) + }) + }) + Context("when a commitish is not supplied", func() { It("updates the existing release", func() { Ω(githubClient.UpdateReleaseCallCount()).Should(Equal(1))