From badee390f9a492475d7f09538a2f17fd955e90db Mon Sep 17 00:00:00 2001 From: Christopher Davenport Date: Tue, 18 Apr 2023 09:41:55 -0700 Subject: [PATCH] Update Build --- .github/workflows/ci.yml | 273 +++++++++++++++++++++++++++++------- .github/workflows/clean.yml | 2 +- build.sbt | 55 ++++---- docs/index.md | 12 ++ project/build.properties | 2 +- project/plugins.sbt | 13 +- site/Gemfile | 5 - site/docs/index.md | 17 --- 8 files changed, 281 insertions(+), 98 deletions(-) create mode 100644 docs/index.md delete mode 100644 site/Gemfile delete mode 100644 site/docs/index.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad9384d..dd01e3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,12 +9,17 @@ name: Continuous Integration on: pull_request: - branches: ['**'] + branches: ['**', '!update/**', '!pr/**'] push: - branches: ['**'] + branches: ['**', '!update/**', '!pr/**'] 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,22 +28,34 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.12.14, 2.13.6, 3.0.2] - java: [adopt@1.8, adopt@1.11] + scala: [2.12.15, 2.13.8, 3.2.2] + java: [temurin@8] + project: [rootJS, rootJVM, rootNative] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) - uses: actions/checkout@v2 + uses: actions/checkout@v3 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@v2 with: - java-version: ${{ matrix.java }} + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} - name: Cache sbt - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/.sbt @@ -49,25 +66,42 @@ 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 githubWorkflowCheck - - name: Install microsite dependencies - if: matrix.scala == '2.13.6' - run: | - gem install saas - gem install jekyll -v 4.2.0 + - name: scalaJSLink + if: matrix.project == 'rootJS' + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' Test/scalaJSLinkerResult - - name: Check that workflows are up to date - run: sbt --client '++${{ matrix.scala }}; githubWorkflowCheck' + - name: nativeLink + if: matrix.project == 'rootNative' + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' Test/nativeLink + + - name: Test + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' test + + - name: Check binary compatibility + if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest' + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' mimaReportBinaryIssues + + - name: Generate API documentation + if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest' + run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' doc - - run: sbt --client '++${{ matrix.scala }}; test; mimaReportBinaryIssues' + - 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 core/.native/target site/target core/.js/target core/.jvm/target .jvm/target .native/target project/target - - if: matrix.scala == '2.13.6' - run: sbt --client '++${{ matrix.scala }}; site/makeMicrosite' + - 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 core/.native/target site/target core/.js/target core/.jvm/target .jvm/target .native/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@v3 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.project }} + path: targets.tar publish: name: Publish Artifacts @@ -76,22 +110,33 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.13.6] - java: [adopt@1.8] + scala: [3.2.2] + java: [temurin@8] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) - uses: actions/checkout@v2 + uses: actions/checkout@v3 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@v2 with: - java-version: ${{ matrix.java }} + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} - name: Cache sbt - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/.sbt @@ -102,27 +147,159 @@ 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, rootJS) + uses: actions/download-artifact@v3 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootJS + + - name: Inflate target directories (2.12.15, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.12.15, rootJVM) + uses: actions/download-artifact@v3 + 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.12.15, rootNative) + uses: actions/download-artifact@v3 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-rootNative + + - name: Inflate target directories (2.12.15, rootNative) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootJS) + uses: actions/download-artifact@v3 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootJS + + - name: Inflate target directories (2.13.8, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8, rootJVM) + uses: actions/download-artifact@v3 + 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: Download target directories (2.13.8, rootNative) + uses: actions/download-artifact@v3 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-rootNative + + - name: Inflate target directories (2.13.8, rootNative) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.2.2, rootJS) + uses: actions/download-artifact@v3 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.2-rootJS - - name: Setup Ruby - uses: ruby/setup-ruby@v1 + - name: Inflate target directories (3.2.2, rootJS) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.2.2, rootJVM) + uses: actions/download-artifact@v3 with: - ruby-version: 3.0.1 + name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.2-rootJVM + + - name: Inflate target directories (3.2.2, rootJVM) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (3.2.2, rootNative) + uses: actions/download-artifact@v3 + with: + name: target-${{ matrix.os }}-${{ matrix.java }}-3.2.2-rootNative + + - name: Inflate target directories (3.2.2, rootNative) + run: | + 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: Install microsite dependencies + - name: Import signing key and strip passphrase + if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != '' run: | - gem install saas - gem install jekyll -v 4.2.0 + 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 }}' tlCiRelease + + site: + name: Generate Site + strategy: + matrix: + os: [ubuntu-latest] + scala: [3.2.2] + java: [temurin@8] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v2 + with: + distribution: temurin + java-version: 8 - - 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: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} + + - name: Cache sbt + uses: actions/cache@v3 + 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.9.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 4194889..a35bf4e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,43 +1,50 @@ -import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} +ThisBuild / tlBaseVersion := "0.1" // your current series x.y -val Scala213 = "2.13.6" +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") +) -ThisBuild / crossScalaVersions := Seq("2.12.14", Scala213, "3.0.2") -ThisBuild / scalaVersion := Scala213 -ThisBuild / testFrameworks += new TestFramework("munit.Framework") +ThisBuild / tlCiReleaseBranches := Seq("main") + +// true by default, set to false to publish to s01.oss.sonatype.org +ThisBuild / tlSonatypeUseLegacyHost := true + + +val catsV = "2.9.0" +val catsEffectV = "3.4.9" -val catsV = "2.7.0" -val catsEffectV = "3.3.11" -val munitCatsEffectV = "1.0.5" +val munitCatsEffectV = "2.0.0-M3" +ThisBuild / crossScalaVersions := Seq("2.12.15","2.13.8", "3.2.2") +ThisBuild / scalaVersion := "3.2.2" +ThisBuild / versionScheme := Some("early-semver") + +ThisBuild / testFrameworks += new TestFramework("munit.Framework") // Projects -lazy val `fiberlocal` = project.in(file(".")) - .disablePlugins(MimaPlugin) - .enablePlugins(NoPublishPlugin) - .aggregate(core.jvm, core.js) +lazy val `fiberlocal` = tlCrossRootProject + .aggregate(core) -lazy val core = crossProject(JVMPlatform, JSPlatform) +lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform) .crossType(CrossType.Pure) .in(file("core")) .settings( name := "fiberlocal", libraryDependencies ++= Seq( - "org.typelevel" %% "cats-core" % catsV, - "org.typelevel" %% "cats-effect" % catsEffectV, - "org.typelevel" %%% "munit-cats-effect-3" % munitCatsEffectV % Test, + "org.typelevel" %%% "cats-core" % catsV, + "org.typelevel" %%% "cats-effect" % catsEffectV, + "org.typelevel" %%% "munit-cats-effect" % munitCatsEffectV % Test, ) ).jsSettings( scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule)}, + ).nativeSettings( + tlVersionIntroduced := List("2.12", "2.13", "3").map(_ -> "0.1.2").toMap ) lazy val site = project.in(file("site")) - .disablePlugins(MimaPlugin) - .enablePlugins(DavenverseMicrositePlugin) + .enablePlugins(TypelevelSitePlugin) .dependsOn(core.jvm) - .settings{ - import microsites._ - Seq( - micrositeDescription := "FiberLocal Abstractions", - ) - } diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..0e9fd9d --- /dev/null +++ b/docs/index.md @@ -0,0 +1,12 @@ +# fiberlocal - FiberLocal Abstractions [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/fiberlocal_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/fiberlocal_2.12) + +## Quick Start + +To use fiberlocal 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" %% "fiberlocal" % "" +) +``` \ No newline at end of file diff --git a/project/build.properties b/project/build.properties index 10fd9ee..46e43a9 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=1.8.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index 105dbd3..2bb3ca4 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,11 @@ -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") -addSbtPlugin("io.chrisdavenport" % "sbt-davenverse" % "0.1.4") \ No newline at end of file +addSbtPlugin("org.typelevel" % "sbt-typelevel-ci-release" % "0.4.19") +addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "0.4.19") +addSbtPlugin("org.typelevel" % "sbt-typelevel-settings" % "0.4.19") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.1") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0") +addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.12") +addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0") + +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.7" ) + +addSbtPlugin("com.armanbilge" % "sbt-scala-native-config-brew-github-actions" % "0.1.3") \ No newline at end of file diff --git a/site/Gemfile b/site/Gemfile deleted file mode 100644 index a099c63..0000000 --- a/site/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -source 'http://rubygems.org' - -gem "jekyll", ">= 4.0.0" -gem "jekyll-relative-links" -gem "sass" \ No newline at end of file diff --git a/site/docs/index.md b/site/docs/index.md deleted file mode 100644 index 4028fdf..0000000 --- a/site/docs/index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: home - ---- - -# fiberlocal - FiberLocal Abstractions [![Build Status](https://travis-ci.com/ChristopherDavenport/fiberlocal.svg?branch=master)](https://travis-ci.com/ChristopherDavenport/fiberlocal) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/fiberlocal_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/fiberlocal_2.12) - -## Quick Start - -To use fiberlocal 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" %% "fiberlocal" % "" -) -``` \ No newline at end of file