From 02c17129365d78d851ae0f49e44415d11be93cdb Mon Sep 17 00:00:00 2001 From: Mark Tomko Date: Tue, 27 Dec 2022 10:22:52 +0100 Subject: [PATCH] Replace sbt-github-packages with call to maven --- build.sbt | 29 ++++++++++++++++++++++------- project/plugins.sbt | 1 - settings.xml | 29 +++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 settings.xml diff --git a/build.sbt b/build.sbt index 1e7e3a4..89fc770 100644 --- a/build.sbt +++ b/build.sbt @@ -117,12 +117,24 @@ lazy val assemblySettings = List( assembly / mainClass := Some("org.broadinstitute.gpp.poolq3.PoolQ") ) -lazy val publishSettings = List( - // Publish to GitHub Packages: - githubOwner := "broadinstitute", - githubRepository := artifactId, - githubTokenSource := TokenSource.Environment("GITHUB_TOKEN") || TokenSource.GitConfig("github.token") -) +lazy val publishToGithubPackages = taskKey[Unit]("Publish jar to Github Packages") + +publishToGithubPackages := { + if (!sys.env.keySet.contains("GITHUB_TOKEN")) throw new Exception("You must set environmental variable GITHUB_TOKEN") + val mvn = + s"""mvn deploy:deploy-file + |-Durl=https://maven.pkg.github.com/poolq + |-DrepositoryId=github + |-Dfile=${(Compile / packageBin).value} + |-DpomFile=${(Compile / makePom).value} + |-Dsources=${(Compile / packageSrc).value} + |-Djavadoc=${(Compile / packageDoc).value} + |--settings=settings.xml""".stripLineEnd + + println(s"Executing shell command $mvn") + import scala.sys.process._ + if (mvn.! != 0) throw new Exception("publish failed") +} lazy val poolq = project .in(file(".")) @@ -144,4 +156,7 @@ lazy val poolq = project ) .settings(headerSettings: _*) .settings(assemblySettings: _*) - .settings(publishSettings: _*) + .settings( + // override the normal publish tasks with the maven task + publish := publishToGithubPackages.value + ) diff --git a/project/plugins.sbt b/project/plugins.sbt index d6f5adc..576a486 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,5 @@ addSbtPlugin("ch.epfl.scala" % "sbt-missinglink" % "0.3.3") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.4") -addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16") diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000..fa5296f --- /dev/null +++ b/settings.xml @@ -0,0 +1,29 @@ + + + github + + + + github + + + github + https://maven.pkg.github.com/poolq + + true + + + + + + + + github + broadinstitute + ${GITHUB_TOKEN} + + +