diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77ec43b..f42b984 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,11 @@ on: tags: [v*] env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: @@ -23,8 +28,9 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.12.10, 2.13.6, 3.1.2] - java: [adopt@1.8, adopt@1.11] + scala: [2.12.15, 2.13.8, 3.2.1] + java: [temurin@8] + project: [rootJVM] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -32,10 +38,21 @@ jobs: with: fetch-depth: 0 - - name: Setup Java and Scala - uses: olafurpg/setup-scala@v12 + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 with: - java-version: ${{ matrix.java }} + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} - name: Cache sbt uses: actions/cache@v2 @@ -49,25 +66,34 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - name: Setup Ruby - if: matrix.scala == '2.13.6' - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.0.1 + - name: Check that workflows are up to date + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' 'project /' githubWorkflowCheck - - name: Install microsite dependencies - if: matrix.scala == '2.13.6' - run: | - gem install saas - gem install jekyll -v 4.2.0 + - name: Test + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' test - - name: Check that workflows are up to date - run: sbt --client '++${{ matrix.scala }}; githubWorkflowCheck' + - name: Check binary compatibility + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' mimaReportBinaryIssues - - run: sbt --client '++${{ matrix.scala }}; test; mimaReportBinaryIssues' + - name: Generate API documentation + if: matrix.java == 'temurin@8' + run: sbt 'project ${{ matrix.project }}' '++${{ matrix.scala }}' doc - - if: matrix.scala == '2.13.6' - run: sbt --client '++${{ matrix.scala }}; site/makeMicrosite' + - name: Make target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: mkdir -p target .js/target site/target .jvm/target .native/target core/target example/target project/target + + - name: Compress target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + run: tar cf targets.tar target .js/target site/target .jvm/target .native/target core/target example/target project/target + + - name: Upload target directories + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') + uses: actions/upload-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} + path: targets.tar publish: name: Publish Artifacts @@ -76,8 +102,8 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [3.1.2] - java: [adopt@1.8] + scala: [2.13.8] + java: [temurin@8] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -85,10 +111,21 @@ jobs: with: fetch-depth: 0 - - name: Setup Java and Scala - uses: olafurpg/setup-scala@v12 + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 with: - java-version: ${{ matrix.java }} + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} - name: Cache sbt uses: actions/cache@v2 @@ -102,27 +139,99 @@ jobs: ~/Library/Caches/Coursier/v1 key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - uses: olafurpg/setup-gpg@v3 + - name: Download target directories (2.12.15, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJVM + + - name: Inflate target directories (2.12.15, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootJVM) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJVM + + - name: Inflate target directories (2.13.8, rootJVM) + run: | + tar xf targets.tar + rm targets.tar - - name: Setup Ruby - uses: ruby/setup-ruby@v1 + - name: Download target directories (3.2.1, rootJVM) + uses: actions/download-artifact@v2 with: - ruby-version: 3.0.1 + name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.1-rootJVM - - name: Install microsite dependencies + - name: Inflate target directories (3.2.1, rootJVM) run: | - gem install saas - gem install jekyll -v 4.2.0 + tar xf targets.tar + rm targets.tar + + - name: Import signing key + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == '' + run: echo $PGP_SECRET | base64 -di | gpg --import + + - name: Import signing key and strip passphrase + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != '' + run: | + echo "$PGP_SECRET" | base64 -di > /tmp/signing-key.gpg + echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg + (echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1) + + - name: Publish + run: sbt '++${{ matrix.scala }}' tlRelease + + site: + name: Generate Site + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.8] + java: [temurin@8] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v1 + with: + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v2 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} - - name: Publish artifacts to Sonatype - env: - PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} - PGP_SECRET: ${{ secrets.PGP_SECRET }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - run: sbt --client '++${{ matrix.scala }}; ci-release' + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - - uses: christopherdavenport/create-ghpages-ifnotexists@v1 + - name: Generate site + run: sbt '++${{ matrix.scala }}' site/tlSite - - name: Publish microsite - run: sbt --client '++${{ matrix.scala }}; site/publishMicrosite' \ No newline at end of file + - name: Publish site + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + uses: peaceiris/actions-gh-pages@v3.8.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: site/target/docs/site + keep_files: true diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml index b535fcc..547aaa4 100644 --- a/.github/workflows/clean.yml +++ b/.github/workflows/clean.yml @@ -56,4 +56,4 @@ jobs: printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size ghapi -X DELETE $REPO/actions/artifacts/$id done - done \ No newline at end of file + done diff --git a/build.sbt b/build.sbt index 5c8038c..33fd1c1 100644 --- a/build.sbt +++ b/build.sbt @@ -1,22 +1,29 @@ -import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} +ThisBuild / tlBaseVersion := "0.4" -ThisBuild / crossScalaVersions := Seq("2.12.10", "2.13.6", "3.1.2") +ThisBuild / organization := "io.chrisdavenport" +ThisBuild / organizationName := "Christopher Davenport" +ThisBuild / licenses := Seq(License.MIT) +ThisBuild / developers := List( + // your GitHub handle and name + tlGitHubDev("christopherdavenport", "Christopher Davenport") +) -val catsV = "2.7.0" -val catsEffectV = "3.3.12" -val fs2V = "3.2.7" -val http4sV = "0.23.0" -val circeV = "0.14.2" -val catsEffectTestingV = "1.4.0" -val log4catsV = "2.3.1" -val logbackClassicV = "1.2.11" +ThisBuild / tlCiReleaseBranches := Seq("main") -val specs2V = "4.12.3" +ThisBuild / scalaVersion := "2.13.8" +ThisBuild / versionScheme := Some("early-semver") +ThisBuild / crossScalaVersions := Seq("2.12.15", "2.13.8", "3.2.1") +val catsV = "2.8.0" +val catsEffectV = "3.4.2" +val fs2V = "3.4.0" +val http4sV = "0.23.16" +val circeV = "0.14.3" +val catsEffectTestingV = "1.5.0" +val log4catsV = "2.5.0" +val logbackClassicV = "1.2.11" -lazy val `github` = project.in(file(".")) - .disablePlugins(MimaPlugin) - .enablePlugins(NoPublishPlugin) +lazy val `github` = tlCrossRootProject .aggregate(core, example) lazy val core = project.in(file("core")) @@ -24,14 +31,6 @@ lazy val core = project.in(file("core")) .settings( name := "github", scalacOptions -= "-Xfatal-warnings", - scalacOptions ++= { - if (isDotty.value) Seq("-language:postfixOps") - else Seq() - }, - mimaVersionCheckExcludedVersions := { - if (isDotty.value) Set("0.3.0") - else Set() - }, buildInfoKeys := Seq[BuildInfoKey](version), buildInfoPackage := "io.chrisdavenport.github", libraryDependencies ++= Seq( @@ -47,9 +46,7 @@ lazy val core = project.in(file("core")) "io.circe" %% "circe-core" % circeV, // "io.circe" %% "circe-literal" % circeV % Test, "io.circe" %% "circe-parser" % circeV % Test, - - ("org.specs2" %% "specs2-core" % specs2V % Test).cross(CrossVersion.for3Use2_13), - ("org.specs2" %% "specs2-scalacheck" % specs2V % Test).cross(CrossVersion.for3Use2_13), + "org.typelevel" %% "cats-effect-testing-specs2" % catsEffectTestingV % Test ) ) @@ -61,16 +58,12 @@ lazy val example = project.in(file("example")) .settings( libraryDependencies ++= Seq( // For Testing As I go - "org.http4s" %% "http4s-blaze-client" % http4sV, + "org.http4s" %% "http4s-ember-client" % http4sV, "org.typelevel" %% "log4cats-slf4j" % log4catsV, "ch.qos.logback" % "logback-classic" % logbackClassicV, ) ) lazy val site = project.in(file("site")) - .disablePlugins(MimaPlugin) - .enablePlugins(NoPublishPlugin) - .enablePlugins(DavenverseMicrositePlugin) - .settings( - micrositeDescription := "Github Integration for Scala", - ) \ No newline at end of file + .enablePlugins(TypelevelSitePlugin) + .dependsOn(core) \ No newline at end of file diff --git a/core/src/main/scala/io/chrisdavenport/github/data/Repositories.scala b/core/src/main/scala/io/chrisdavenport/github/data/Repositories.scala index a99d97a..3f35710 100644 --- a/core/src/main/scala/io/chrisdavenport/github/data/Repositories.scala +++ b/core/src/main/scala/io/chrisdavenport/github/data/Repositories.scala @@ -183,7 +183,7 @@ object Repositories { "public" -> a.isPublic.asJson, "has_issues" -> a.hasIssues.asJson, "has_wiki" -> a.hasWiki.asJson, - "has_downloads" -> a.hasDownloads.asJson + "has_downloads" -> a.hasDownloads.asJson, "visibility" -> a.visibility.asJson ).dropNullValues } diff --git a/core/src/test/scala/io/chrisdavenport/github/endpoints/GistsSpec.scala b/core/src/test/scala/io/chrisdavenport/github/endpoints/GistsSpec.scala index 43aae97..3d2b079 100644 --- a/core/src/test/scala/io/chrisdavenport/github/endpoints/GistsSpec.scala +++ b/core/src/test/scala/io/chrisdavenport/github/endpoints/GistsSpec.scala @@ -59,15 +59,15 @@ class GistsSpec extends Specification with CatsEffect with JsonFiles { .take(1) .compile .toList - .map(_ must not beEmpty) + .map(_ must not(beEmpty)) } "list all public gists" in { - Gists.allPublic[IO](None, None).run(client).take(1).compile.toList.map(_ must not beEmpty) + Gists.allPublic[IO](None, None).run(client).take(1).compile.toList.map(_ must not(beEmpty)) } "list starred gists" in { - Gists.starred[IO](None, OAuth("")).run(client).take(1).compile.toList.map(_ must not beEmpty) + Gists.starred[IO](None, OAuth("")).run(client).take(1).compile.toList.map(_ must not(beEmpty)) } "get a single gist" in { diff --git a/core/src/test/scala/io/chrisdavenport/github/endpoints/repositories/ForksSpec.scala b/core/src/test/scala/io/chrisdavenport/github/endpoints/repositories/ForksSpec.scala index 6e2f670..295e737 100644 --- a/core/src/test/scala/io/chrisdavenport/github/endpoints/repositories/ForksSpec.scala +++ b/core/src/test/scala/io/chrisdavenport/github/endpoints/repositories/ForksSpec.scala @@ -262,7 +262,7 @@ class ForksSpec extends Specification with CatsEffect { .run(Client.fromHttpApp(routes.orNotFound)) .compile .last - .map { _ must not beEmpty } + .map { _ must not(beNone) } } } } diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..01b261c --- /dev/null +++ b/docs/index.md @@ -0,0 +1,12 @@ +# github - Github Integration for Scala [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/github_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/github_2.12) + +## Quick Start + +To use github in an existing SBT project with Scala 2.11 or a later version, add the following dependencies to your +`build.sbt` depending on your needs: + +```scala +libraryDependencies ++= Seq( + "io.chrisdavenport" %% "github" % "" +) +``` \ No newline at end of file diff --git a/example/src/main/scala/io/chrisdavenport/github/GetFileContent.scala b/example/src/main/scala/io/chrisdavenport/github/GetFileContent.scala index 7545ecd..c2129c3 100644 --- a/example/src/main/scala/io/chrisdavenport/github/GetFileContent.scala +++ b/example/src/main/scala/io/chrisdavenport/github/GetFileContent.scala @@ -2,14 +2,14 @@ package io.chrisdavenport.github // import cats.implicits._ import cats.effect._ -import org.http4s.blaze.client.BlazeClientBuilder +import org.http4s.ember.client.EmberClientBuilder import java.{util => ju} import endpoints.repositories.Content object GetFileContent extends IOApp { def run(args: List[String]): IO[ExitCode] = { for { - c <- BlazeClientBuilder[IO](scala.concurrent.ExecutionContext.global).resource + c <- EmberClientBuilder.default[IO].build out <- Resource.eval( Content.contentsFor[IO]( "ChristopherDavenport", diff --git a/example/src/main/scala/io/chrisdavenport/github/Main.scala b/example/src/main/scala/io/chrisdavenport/github/Main.scala index 7326474..04d4adc 100644 --- a/example/src/main/scala/io/chrisdavenport/github/Main.scala +++ b/example/src/main/scala/io/chrisdavenport/github/Main.scala @@ -5,7 +5,7 @@ import cats.effect._ import cats.data.Kleisli import org.http4s.client.Client -import org.http4s.blaze.client.BlazeClientBuilder +import org.http4s.ember.client.EmberClientBuilder import scala.concurrent.duration._ import org.typelevel.log4cats.slf4j.Slf4jLogger import scodec.bits._ @@ -15,7 +15,7 @@ object Main extends IOApp { def run(args: List[String]): IO[ExitCode] = { val logger = Slf4jLogger.getLogger[IO] for { - c <- BlazeClientBuilder[IO](scala.concurrent.ExecutionContext.global).resource + c <- EmberClientBuilder.default[IO].build home <- Resource.eval(IO(sys.env("HOME"))) .map(_.trim()) authLine <- Resource.eval(IO(scala.io.Source.fromFile(home |+| "/Documents/.token_test").getLines().toList.head)) diff --git a/example/src/main/scala/io/chrisdavenport/github/PullRequests.scala b/example/src/main/scala/io/chrisdavenport/github/PullRequests.scala index e258b4a..3d41c39 100644 --- a/example/src/main/scala/io/chrisdavenport/github/PullRequests.scala +++ b/example/src/main/scala/io/chrisdavenport/github/PullRequests.scala @@ -1,7 +1,7 @@ package io.chrisdavenport.github import cats.effect._ -import org.http4s.blaze.client.BlazeClientBuilder +import org.http4s.ember.client.EmberClientBuilder import io.chrisdavenport.github.endpoints.PullRequests @@ -9,7 +9,7 @@ object PullRequestsExample extends IOApp { def run(args: List[String]): IO[ExitCode] = { for { - c <- BlazeClientBuilder[IO](scala.concurrent.ExecutionContext.global).resource + c <- EmberClientBuilder.default[IO].build out <- PullRequests.pullRequestsFor[IO]( "ChristopherDavenport", diff --git a/project/build.properties b/project/build.properties index c8fcab5..22af262 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.6.2 +sbt.version=1.7.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index ddda31d..5368488 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,4 @@ -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.1") -addSbtPlugin("io.chrisdavenport" % "sbt-davenverse" % "0.1.4") +addSbtPlugin("org.typelevel" % "sbt-typelevel-ci-release" % "0.4.9") +addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "0.4.9") +addSbtPlugin("org.typelevel" % "sbt-typelevel-settings" % "0.4.9") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") \ No newline at end of file diff --git a/site/docs/index.md b/site/docs/index.md deleted file mode 100644 index 661be5e..0000000 --- a/site/docs/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: home - ---- - -# github - Github Integration for Scala [![Build Status](https://travis-ci.com/ChristopherDavenport/github.svg?branch=master)](https://travis-ci.com/ChristopherDavenport/github) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/github_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/github_2.12) - -## Quick Start - -To use github in an existing SBT project with Scala 2.11 or a later version, add the following dependencies to your -`build.sbt` depending on your needs: - -```scala -libraryDependencies ++= Seq( - "io.chrisdavenport" %% "github" % "" -) -``` \ No newline at end of file