diff --git a/README.md b/README.md index 82a57d8..059e887 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,9 @@ There are release and release candidate repositories in Bintray HMRC for standar `java -jar target/scala-2.11/releaser-assembly-x.x.x.jar` artifact release-candidate-version release-version ##### Extra flags -- `-d | --dryRun`: perform a dry run of a relase. Downloads files and transforms but does not upload or create releases on github.com. Useful during development -- `--github-name-override`: provide a different github repository to the bintray package. The default is to assume the github repository has the same name as the Bintry repository and this flag allows the user to provide a differnt github.com repository name. +- `-d | --dryRun`: perform a dry run of a release. Downloads files and transforms but does not upload or create releases on github.com. Useful during development +- `--github-name-override`: provide a different github repository to the bintray package. The default is to assume the github repository has the same name as the Bintry repository and this flag allows the user to provide a different github.com repository name. +- `--release-notes`: custom release notes appended at the bottom of the default #### Configuration Parameters You can specify custom timeouts to be passed to the play.ws libraries that this project uses with the following System properties (-Dproperty.name=value) diff --git a/src/main/scala/uk/gov/hmrc/releaser/ArgParser.scala b/src/main/scala/uk/gov/hmrc/releaser/ArgParser.scala index 551d432..2c5c664 100644 --- a/src/main/scala/uk/gov/hmrc/releaser/ArgParser.scala +++ b/src/main/scala/uk/gov/hmrc/releaser/ArgParser.scala @@ -25,7 +25,8 @@ object ArgParser{ githubNameOverride:Option[String] = None, tag:Boolean = true, verbose:Boolean = false, - dryRun:Boolean = false) + dryRun:Boolean = false, + releaseNotes: Option[String] = None) val currentVersion = getClass.getPackage.getImplementationVersion @@ -41,6 +42,8 @@ object ArgParser{ c.copy(releaseType = ReleaseType.withName(x)) } validate { x => if (ReleaseType.stringValues.contains(x)) success else failure(releaseTypeErrorMessage(x)) } text "the release type. Permitted values are: " + ReleaseType.stringValues.mkString(" ") + opt[String]("release-notes") action { (x, c) => + c.copy(releaseNotes = Some(x)) } text "release notes" opt[Boolean]("tag") action { (x, c) => c.copy(tag = x) } text "tag in github" opt[String]("github-name-override") action { (x, c) => diff --git a/src/main/scala/uk/gov/hmrc/releaser/Coordinator.scala b/src/main/scala/uk/gov/hmrc/releaser/Coordinator.scala index 3befb3f..9e66656 100644 --- a/src/main/scala/uk/gov/hmrc/releaser/Coordinator.scala +++ b/src/main/scala/uk/gov/hmrc/releaser/Coordinator.scala @@ -36,7 +36,8 @@ class Coordinator(stageDir: Path, def start(artefactName:String, gitRepo:Repo, releaseCandidateVersion: ReleaseCandidateVersion, - releaseType: ReleaseType.Value): Try[ReleaseVersion] = { + releaseType: ReleaseType.Value, + releaseNotes: Option[String]): Try[ReleaseVersion] = { for { targetVersion <- VersionNumberCalculator.calculateTarget(releaseCandidateVersion, releaseType) @@ -51,7 +52,7 @@ class Coordinator(stageDir: Path, transd <- transformFiles(repo, map, remotes) _ <- uploadFiles(repo, map.targetArtefact, transd) _ <- bintrayConnector.publish(map.targetArtefact) - _ <- githubConnector.createGithubTagAndRelease(new DateTime(), commitSha, commitAuthor, commitDate, artefactName, gitRepo, releaseCandidateVersion.value, targetVersion.value) + _ <- githubConnector.createGithubTagAndRelease(new DateTime(), commitSha, commitAuthor, commitDate, artefactName, gitRepo, releaseCandidateVersion.value, targetVersion.value, releaseNotes) } yield targetVersion } diff --git a/src/main/scala/uk/gov/hmrc/releaser/Releaser.scala b/src/main/scala/uk/gov/hmrc/releaser/Releaser.scala index 82aedcf..3874740 100644 --- a/src/main/scala/uk/gov/hmrc/releaser/Releaser.scala +++ b/src/main/scala/uk/gov/hmrc/releaser/Releaser.scala @@ -41,12 +41,12 @@ object Releaser extends Logger { parser.parse(args, Config()) match { case Some(config) => val githubName = config.githubNameOverride.getOrElse(config.artefactName) - run(config.artefactName, ReleaseCandidateVersion(config.rcVersion), config.releaseType, githubName, config.dryRun) + run(config.artefactName, ReleaseCandidateVersion(config.rcVersion), config.releaseType, githubName, config.releaseNotes, config.dryRun) case None => -1 } } - def run(artefactName: String, rcVersion: ReleaseCandidateVersion, releaseType: ReleaseType.Value, gitHubName: String, dryRun: Boolean = false): Int = { + def run(artefactName: String, rcVersion: ReleaseCandidateVersion, releaseType: ReleaseType.Value, gitHubName: String, releaseNotes: Option[String], dryRun: Boolean = false): Int = { val githubCredsFile = System.getProperty("user.home") + "/.github/.credentials" val bintrayCredsFile = System.getProperty("user.home") + "/.bintray/.credentials" @@ -69,7 +69,7 @@ object Releaser extends Logger { val bintrayRepoConnector = new DefaultBintrayRepoConnector(directories.workDir, new BintrayHttp(bintrayCredsOpt.get), new FileDownloader) val coordinator = new Coordinator(directories.stageDir, metaDataProvider, gitHubDetails, bintrayRepoConnector) - val result = coordinator.start(artefactName, Repo(gitHubName), rcVersion, releaseType) + val result = coordinator.start(artefactName, Repo(gitHubName), rcVersion, releaseType, releaseNotes) result match { case Success(targetVersion) => diff --git a/src/main/scala/uk/gov/hmrc/releaser/github/GithubConnector.scala b/src/main/scala/uk/gov/hmrc/releaser/github/GithubConnector.scala index f245d41..d619376 100644 --- a/src/main/scala/uk/gov/hmrc/releaser/github/GithubConnector.scala +++ b/src/main/scala/uk/gov/hmrc/releaser/github/GithubConnector.scala @@ -68,11 +68,12 @@ class GithubConnector(githubHttp : GithubHttp, releaserVersion : String, comitte def createGithubTagAndRelease(tagDate: DateTime, commitSha: CommitSha, commitAuthor: String, commitDate: DateTime, - artefactName: String, gitRepo: Repo, releaseCandidateVersion: String, version: String): Try[Unit] = + artefactName: String, gitRepo: Repo, releaseCandidateVersion: String, version: String, + releaseNotes: Option[String]): Try[Unit] = for ( tagSha <- createTagObject(tagDate, gitRepo, version, commitSha); _ <- createTagRef(gitRepo, version, tagSha); - _ <- createRelease(commitSha, commitAuthor, commitDate, artefactName, gitRepo, releaseCandidateVersion, version)) + _ <- createRelease(commitSha, commitAuthor, commitDate, artefactName, gitRepo, releaseCandidateVersion, version, releaseNotes)) yield () private def createTagObject(tagDate: DateTime, repo:Repo, tag: String, commitSha:CommitSha): Try[CommitSha] = { @@ -95,11 +96,12 @@ class GithubConnector(githubHttp : GithubHttp, releaserVersion : String, comitte private def createRelease(commitSha: CommitSha, commitAuthor: String, commitDate: DateTime, artefactName: String, - gitRepo: Repo, releaseCandidateVersion: String, version: String): Try[Unit] = { + gitRepo: Repo, releaseCandidateVersion: String, version: String, + releaseNotes: Option[String]): Try[Unit] = { log.debug(s"creating release from $commitSha version " + version) val url = buildReleasePostUrl(gitRepo) - val message = buildMessage(artefactName, version, releaserVersion, releaseCandidateVersion, commitSha, commitAuthor, commitDate) + val message = buildMessage(artefactName, version, releaserVersion, releaseCandidateVersion, commitSha, commitAuthor, commitDate, releaseNotes) val body = buildReleaseBody(message, version) githubHttp.postUnit(url, body) @@ -120,12 +122,19 @@ class GithubConnector(githubHttp : GithubHttp, releaserVersion : String, comitte Json.toJson(GitRelease(version, tagName, message, draft = false, prerelease = false)) } + private def customReleaseNotes(releaseNotesOpt: Option[String]) = + releaseNotesOpt.map(releaseNotes => + s"""| + |$releaseNotes""".stripMargin + ).getOrElse("") + private def buildMessage( name: String, version: String, releaserVersion: String, releaseCandidateVersion: String, - commitSha: CommitSha, commitAuthor: String, commitDate: DateTime) = + commitSha: CommitSha, commitAuthor: String, commitDate: DateTime, + releaseNotes: Option[String]) = s""" |Release : $name $version |Release candidate : $name $releaseCandidateVersion @@ -134,7 +143,8 @@ class GithubConnector(githubHttp : GithubHttp, releaserVersion : String, comitte |Last commit author : $commitAuthor |Last commit time : ${DateTimeFormat.longDateTime().print(commitDate)} | - |Release and tag created by [Releaser](https://github.com/hmrc/releaser) $releaserVersion""".stripMargin + |Release and tag created by [Releaser](https://github.com/hmrc/releaser) $releaserVersion + |${customReleaseNotes(releaseNotes)}""".stripMargin private def buildCommitGetUrl(repo:Repo, sha:CommitSha)={ s"https://api.github.com/repos/hmrc/${repo.value}/git/commits/$sha" @@ -161,5 +171,5 @@ class DryRunGithubConnector(releaserVersion: String) extends GithubTagAndRelease def createGithubTagAndRelease(tagDate: DateTime, commitSha: CommitSha, commitAuthor: String, commitDate: DateTime, - artefactName: String, gitRepo: Repo, releaseCandidateVersion: String, version: String): Try[Unit] = Success(Unit) + artefactName: String, gitRepo: Repo, releaseCandidateVersion: String, version: String, releaseNotes: Option[String]): Try[Unit] = Success(Unit) } diff --git a/src/main/scala/uk/gov/hmrc/releaser/github/GithubTagAndRelease.scala b/src/main/scala/uk/gov/hmrc/releaser/github/GithubTagAndRelease.scala index 9b10955..587f655 100644 --- a/src/main/scala/uk/gov/hmrc/releaser/github/GithubTagAndRelease.scala +++ b/src/main/scala/uk/gov/hmrc/releaser/github/GithubTagAndRelease.scala @@ -22,10 +22,16 @@ import scala.util.Try trait GithubTagAndRelease { - def verifyGithubTagExists(repo:Repo, sha:CommitSha): Try[Unit] + def verifyGithubTagExists(repo: Repo, sha: CommitSha): Try[Unit] - def createGithubTagAndRelease(tagDate: DateTime, commitSha: CommitSha, - commitAuthor: String, commitDate: DateTime, - artefactName: String, gitRepo: Repo, releaseCandidateVersion: String, version: String): Try[Unit] + def createGithubTagAndRelease(tagDate: DateTime, + commitSha: CommitSha, + commitAuthor: String, + commitDate: DateTime, + artefactName: String, + gitRepo: Repo, + releaseCandidateVersion: String, + version: String, + releaseNotes: Option[String]): Try[Unit] } diff --git a/src/test/scala/uk/gov/hmrc/releaser/CoordinatorSpecs.scala b/src/test/scala/uk/gov/hmrc/releaser/CoordinatorSpecs.scala index bcc6bed..2b07258 100644 --- a/src/test/scala/uk/gov/hmrc/releaser/CoordinatorSpecs.scala +++ b/src/test/scala/uk/gov/hmrc/releaser/CoordinatorSpecs.scala @@ -57,7 +57,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try bintrayFiles = Set(s"$root/libr_2.11-1.3.0-1-g21312cc.pom", s"$root/libr_2.11-1.3.0-1-g21312cc-assembly.jar")) val coordinator = new Coordinator(tempDir(), metaDataProvider, new FakeGithubTagAndRelease, fakeRepoConnector) - coordinator.start("libr", Repo("libr"), ReleaseCandidateVersion("1.3.0-1-g21312cc"), ReleaseType.HOTFIX) match { + coordinator.start("libr", Repo("libr"), ReleaseCandidateVersion("1.3.0-1-g21312cc"), ReleaseType.HOTFIX, None) match { case Failure(e) => log.error(s"Test failed with: ${e.getMessage} - ${e.toString}") fail(e) @@ -106,7 +106,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try s"$root/help-frontend_2.11-1.26.0-3-gd7ed03c-sources.jar")) val coordinator = new Coordinator(tempDir(), metaDataProvider, new FakeGithubTagAndRelease, fakeRepoConnector) - coordinator.start("help-frontend", Repo("help-frontend"), ReleaseCandidateVersion("1.26.0-3-gd7ed03c"), ReleaseType.MAJOR) match { + coordinator.start("help-frontend", Repo("help-frontend"), ReleaseCandidateVersion("1.26.0-3-gd7ed03c"), ReleaseType.MAJOR, None) match { case Failure(e) => log.error(s"Test failed with: ${e.getMessage} - ${e.toString}") fail(e) @@ -143,7 +143,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try bintrayFiles = Set(s"$root/time_2.11-1.3.0-1-g21312cc.pom")) val coordinator = new Coordinator(tempDir(), metaDataProvider, new FakeGithubTagAndRelease, fakeRepoConnector) - coordinator.start("time", Repo("time"), ReleaseCandidateVersion("1.3.0-1-g21312cc"), ReleaseType.MINOR) match { + coordinator.start("time", Repo("time"), ReleaseCandidateVersion("1.3.0-1-g21312cc"), ReleaseType.MINOR, None) match { case Failure(e) => log.error(s"Test failed with: ${e.getMessage} - ${e.toString}") fail(e) @@ -184,7 +184,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try )) val coordinator = new Coordinator(tempDir(), metaDataProvider, new FakeGithubTagAndRelease, fakeBintrayRepoConnector) - coordinator.start("time", Repo("time"), ReleaseCandidateVersion("1.3.0-1-g21312cc"), ReleaseType.MINOR) match { + coordinator.start("time", Repo("time"), ReleaseCandidateVersion("1.3.0-1-g21312cc"), ReleaseType.MINOR, None) match { case Failure(e) => log.error(s"Test failed with: ${e.getMessage} - ${e.toString}") fail(e) @@ -228,7 +228,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try s"$root/paye-estimator_sjs0.6_2.11-0.1.0-1-g1906708-javadoc.jar")) val coordinator = new Coordinator(tempDir(), metaDataProvider, new FakeGithubTagAndRelease, fakeRepoConnector) - coordinator.start("paye-estimator", Repo("paye-estimator"), ReleaseCandidateVersion("0.1.0-1-g1906708"), ReleaseType.MINOR) match { + coordinator.start("paye-estimator", Repo("paye-estimator"), ReleaseCandidateVersion("0.1.0-1-g1906708"), ReleaseType.MINOR, None) match { case Failure(e) => log.error(s"Test failed with: ${e.getMessage} - ${e.toString}") fail(e) @@ -272,7 +272,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try s"$root/paye-estimator_sjs0.6_2.11-0.1.0-1-g1906708.zip")) val coordinator = new Coordinator(tempDir(), metaDataProvider, new FakeGithubTagAndRelease, fakeRepoConnector) - coordinator.start("paye-estimator", Repo("paye-estimator"), ReleaseCandidateVersion("0.1.0-1-g1906708"), ReleaseType.MINOR) match { + coordinator.start("paye-estimator", Repo("paye-estimator"), ReleaseCandidateVersion("0.1.0-1-g1906708"), ReleaseType.MINOR, None) match { case Failure(e) => log.error(s"Test failed with: ${e.getMessage} - ${e.toString}") fail(e) @@ -305,7 +305,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try bintrayFiles = Set(s"$root/time_2.11-1.3.0-1-g21312cc.pom")) val coordinator = new Coordinator(tempDir(), metaDataProvider, taggerAndReleaser, fakeRepoConnector) - coordinator.start("time", Repo("time"), aReleaseCandidateVersion, ReleaseType.MINOR) match { + coordinator.start("time", Repo("time"), aReleaseCandidateVersion, ReleaseType.MINOR, None) match { case Failure(e) => e shouldBe expectedException case Success(s) => fail(s"Should have failed with $expectedException") } @@ -320,7 +320,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try bintrayFiles = Set(s"$root/time_2.11-1.3.0-1-g21312cc.pom"), targetExists = true) val coordinator = new Coordinator(tempDir(), mock[MetaDataProvider], new FakeGithubTagAndRelease, fakeRepoConnector) - coordinator.start("time", Repo("time"), aReleaseCandidateVersion, ReleaseType.MINOR) match { + coordinator.start("time", Repo("time"), aReleaseCandidateVersion, ReleaseType.MINOR, None) match { case Failure(e) => e shouldBe an [IllegalArgumentException] case Success(s) => fail(s"Should have failed with an IllegalArgumentException") } @@ -333,7 +333,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try } val coordinator = new Coordinator(tempDir(), mock[MetaDataProvider], new FakeGithubTagAndRelease, fakeRepoConnector) - coordinator.start("a", Repo("a"), aReleaseCandidateVersion, ReleaseType.MINOR) match { + coordinator.start("a", Repo("a"), aReleaseCandidateVersion, ReleaseType.MINOR, None) match { case Failure(e) => e.getMessage shouldBe "Didn't find a release candidate repository for 'a' in repos List(release-candidates, sbt-plugin-release-candidates)" case Success(s) => fail(s"Should have failed") } @@ -357,7 +357,7 @@ class CoordinatorSpecs extends WordSpec with Matchers with OptionValues with Try } val coordinator = new Coordinator(tempDir(), metaDataProvider, new FakeGithubTagAndRelease, fakeRepoConnector) - coordinator.start("sbt-bobby", Repo("sbt-bobby"), ReleaseCandidateVersion("0.8.1-4-ge733d26"), ReleaseType.HOTFIX) match { + coordinator.start("sbt-bobby", Repo("sbt-bobby"), ReleaseCandidateVersion("0.8.1-4-ge733d26"), ReleaseType.HOTFIX, None) match { case Failure(e) => log.error(s"Test failed with: ${e.getMessage} - ${e.toString}") fail(e) diff --git a/src/test/scala/uk/gov/hmrc/releaser/github/FakeGithubTagAndRelease.scala b/src/test/scala/uk/gov/hmrc/releaser/github/FakeGithubTagAndRelease.scala index 7e97e0c..182a44a 100644 --- a/src/test/scala/uk/gov/hmrc/releaser/github/FakeGithubTagAndRelease.scala +++ b/src/test/scala/uk/gov/hmrc/releaser/github/FakeGithubTagAndRelease.scala @@ -22,7 +22,7 @@ import scala.util.{Success, Try} class FakeGithubTagAndRelease extends GithubTagAndRelease { override def createGithubTagAndRelease(tagDate: DateTime, commitSha: CommitSha, commitAuthor: String, commitDate: DateTime, - artefactName: String, gitRepo: Repo, releaseCandidateVersion: String, version: String): Try[Unit] = Success(Unit) + artefactName: String, gitRepo: Repo, releaseCandidateVersion: String, version: String, releaseNotes: Option[String]): Try[Unit] = Success(Unit) override def verifyGithubTagExists(repo: Repo, sha: CommitSha): Try[Unit] = Success(Unit) } diff --git a/src/test/scala/uk/gov/hmrc/releaser/github/GithubConnectorSpecs.scala b/src/test/scala/uk/gov/hmrc/releaser/github/GithubConnectorSpecs.scala index 8f46352..5e67b27 100644 --- a/src/test/scala/uk/gov/hmrc/releaser/github/GithubConnectorSpecs.scala +++ b/src/test/scala/uk/gov/hmrc/releaser/github/GithubConnectorSpecs.scala @@ -30,19 +30,18 @@ import scala.util.Success class GithubConnectorSpecs extends WordSpec with Matchers with TryValues with OptionValues with MockitoSugar { val repo = Repo("myRepo") - val mockHttpConnector = mock[GithubHttp] - val releaserVersion = "6.6.6" - val connector = new GithubConnector( - mockHttpConnector, - releaserVersion, - new GithubCommitter("hmrc-web-operations", "hmrc-web-operations@digital.hmrc.gov.uk")) - "GithubConnector" should { "Create the github tag object, tag reg and release" in { + val mockHttpConnector = mock[GithubHttp] + val connector = new GithubConnector( + mockHttpConnector, + releaserVersion, + new GithubCommitter("hmrc-web-operations", "hmrc-web-operations@digital.hmrc.gov.uk")) + val repoName = "myRepo" val artifactName = "myArtefact" val rcVersion = "0.9.0-abcdef" @@ -84,7 +83,8 @@ class GithubConnectorSpecs extends WordSpec with Matchers with TryValues with Op |Last commit author : $author |Last commit time : ${GithubConnector.releaseMessageDateTimeFormat.print(commitDate)} | - |Release and tag created by [Releaser](https://github.com/hmrc/releaser) $releaserVersion""".stripMargin)) + |Release and tag created by [Releaser](https://github.com/hmrc/releaser) $releaserVersion + |""".stripMargin)) val expectedReleaseBody = Json.parse(s""" @@ -106,12 +106,99 @@ class GithubConnectorSpecs extends WordSpec with Matchers with TryValues with Op when(mockHttpConnector.postUnit(meq(s"https://api.github.com/repos/hmrc/$repoName/releases"), meq(expectedReleaseBody))) .thenReturn(Success(())) - val result = connector.createGithubTagAndRelease(tagDate, sha, author, commitDate, artifactName, Repo(repoName), rcVersion, releaseVersion) + val result = connector.createGithubTagAndRelease(tagDate, sha, author, commitDate, artifactName, Repo(repoName), rcVersion, releaseVersion, None) + + result shouldBe Success(()) + } + + "Create the github tag object, tag reg and release with custom release notes" in { + + val mockHttpConnector = mock[GithubHttp] + val connector = new GithubConnector( + mockHttpConnector, + releaserVersion, + new GithubCommitter("hmrc-web-operations", "hmrc-web-operations@digital.hmrc.gov.uk")) + + val repoName = "myRepo" + val artifactName = "myArtefact" + val rcVersion = "0.9.0-abcdef" + val releaseVersion = "1.0.0" + val sha = "c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c" + val author = "charleskubicek" + val commitDate = new DateTime(2011, 6, 17, 14, 53, 35, UTC) + val tagDate = new DateTime(2011, 6, 17, 14, 53, 35, UTC) + + val expectedTagObjectBody = + Json.parse(s""" + |{ + | "tag": "v$releaseVersion", + | "message": "tag of $releaseVersion", + | "object": "$sha", + | "tagger": { + | "name": "hmrc-web-operations", + | "email": "hmrc-web-operations@digital.hmrc.gov.uk", + | "date": "2011-06-17T14:53:35Z" + | }, + | "type": "commit" + |} + """.stripMargin) + + val expectedTagRefBody = + Json.parse(s""" + |{ + | "ref": "refs/tags/v$releaseVersion", + | "sha": "$sha" + |} + """.stripMargin) + + val expectedMessage = Json.stringify(new JsString ( + s""" + |Release : $artifactName $releaseVersion + |Release candidate : $artifactName $rcVersion + | + |Last commit sha : $sha + |Last commit author : $author + |Last commit time : ${GithubConnector.releaseMessageDateTimeFormat.print(commitDate)} + | + |Release and tag created by [Releaser](https://github.com/hmrc/releaser) $releaserVersion + | + |some custom release notes line 1 + |some custom release notes line 2 + |""".stripMargin)) + + val expectedReleaseBody = + Json.parse(s""" + |{ + | "name": "$releaseVersion", + | "tag_name": "v$releaseVersion", + | "body": $expectedMessage, + | "draft" : false, + | "prerelease" : false + |} + """.stripMargin) + + when(mockHttpConnector.post[CommitSha](any())(meq(s"https://api.github.com/repos/hmrc/$repoName/git/tags"), meq(expectedTagObjectBody))) + .thenReturn(Success(new CommitSha(sha))) + + when(mockHttpConnector.postUnit(meq(s"https://api.github.com/repos/hmrc/$repoName/git/refs"), meq(expectedTagRefBody))) + .thenReturn(Success(())) + + when(mockHttpConnector.postUnit(meq(s"https://api.github.com/repos/hmrc/$repoName/releases"), meq(expectedReleaseBody))) + .thenReturn(Success(())) + + val result = connector.createGithubTagAndRelease(tagDate, sha, author, commitDate, artifactName, Repo(repoName), rcVersion, releaseVersion, Some("some custom release notes line 1\nsome custom release notes line 2\n")) result shouldBe Success(()) } "Verify that a commit exists" in { + + val mockHttpConnector = mock[GithubHttp] + val connector = new GithubConnector( + mockHttpConnector, + releaserVersion, + new GithubCommitter("hmrc-web-operations", "hmrc-web-operations@digital.hmrc.gov.uk")) + val repoName = "myRepo" val sha = "c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c"