From 1a4c2b89daba604428f979b28e25726cd998707e Mon Sep 17 00:00:00 2001 From: Mark Canlas Date: Mon, 2 Jan 2023 15:58:16 -0500 Subject: [PATCH] use gha packages --- .github/workflows/ci.yml | 2 ++ build.sbt | 11 ++--------- project/GitHubPackages.scala | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 project/GitHubPackages.scala diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e97371..a9a7a9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,3 +15,5 @@ jobs: cache: sbt - run: sbt 'scalafixAll --check' scalafmtCheck +test + env: + GH_PACKAGES_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }} diff --git a/build.sbt b/build.sbt index 2cb6c21..0bc798e 100644 --- a/build.sbt +++ b/build.sbt @@ -18,12 +18,5 @@ lazy val demo = .dependsOn(core) .withEfectMonad .settings(libraryDependencies += "com.htmlism" %% "rufio-zio" % "76-c565ab28") - -ThisBuild / resolvers += "mcanlas/rufio" at "https://maven.pkg.github.com/mcanlas/rufio/" - -ThisBuild / credentials += Credentials( - "GitHub Package Registry", - "maven.pkg.github.com", - "mcanlas", - sys.env("GH_PACKAGES_TOKEN") -) + .withGitHubPackagesCredentials + .withResolver("rufio") diff --git a/project/GitHubPackages.scala b/project/GitHubPackages.scala new file mode 100644 index 0000000..0b2d9fc --- /dev/null +++ b/project/GitHubPackages.scala @@ -0,0 +1,36 @@ +import sbt._ +import sbt.Keys._ + +/** + * Automatically enriches projects with the following settings (despite the word "override"). + */ +object GitHubPackages extends AutoPlugin { + + /** + * Thus plug-in will automatically be enabled; it has no requirements. + */ + override def trigger: PluginTrigger = AllRequirements + + val autoImport = ThingsToAutoImport + + object ThingsToAutoImport { + implicit class PackagesOps(p: Project) { + def withGitHubPackagesCredentials: Project = + p + .settings( + credentials += Credentials( + "GitHub Package Registry", + "maven.pkg.github.com", + "mcanlas", + sys.env("GH_PACKAGES_TOKEN") + ) + ) + + def withResolver(project: String): Project = + p + .settings( + resolvers += s"mcanlas/$project" at s"https://maven.pkg.github.com/mcanlas/$project/" + ) + } + } +}