diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d596a9..da3abfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,9 +9,10 @@ name: Continuous Integration on: pull_request: - branches: ['**'] + branches: [main] push: - branches: ['**'] + branches: [main] + tags: [v*] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -68,3 +69,91 @@ jobs: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} COVERALLS_FLAG_NAME: Scala ${{ matrix.scala }} run: sbt ++${{ matrix.scala }} coverageReport coverageAggregate coveralls + + - name: Compress target directories + run: tar cf targets.tar target project/target + + - name: Upload target directories + uses: actions/upload-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }} + path: targets.tar + + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.8] + java: [temurin@11] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java (temurin@11) + if: matrix.java == 'temurin@11' + uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: 11 + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: 17 + + - 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') }} + + - name: Download target directories (2.12.15) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.12.15-${{ matrix.java }} + + - name: Inflate target directories (2.12.15) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.11.12) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.11.12-${{ matrix.java }} + + - name: Inflate target directories (2.11.12) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.8) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.13.8-${{ matrix.java }} + + - name: Inflate target directories (2.13.8) + run: | + tar xf targets.tar + rm targets.tar + + - env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + run: sbt ++${{ matrix.scala }} ci-release diff --git a/build.sbt b/build.sbt index 8a6765a..345a3f8 100644 --- a/build.sbt +++ b/build.sbt @@ -55,10 +55,8 @@ licenses := Seq( ) ) homepage := Some(url("https://github.com/johanandren/futiles")) -publishMavenStyle := true Test / publishArtifact := false pomIncludeRepository := { _ => false } -publishTo := sonatypePublishTo.value scmInfo := Some( ScmInfo(url("https://github.com/johanandren/futiles"), "git@github.com:johanandren/futiles.git") @@ -73,8 +71,21 @@ ThisBuild / githubWorkflowJavaVersions := List( JavaSpec.temurin("17") ) -// Disable publish for now -ThisBuild / githubWorkflowPublishTargetBranches := Seq() +ThisBuild / githubWorkflowTargetBranches := Seq("main") +ThisBuild / githubWorkflowTargetTags ++= Seq("v*") +ThisBuild / githubWorkflowPublishTargetBranches := + Seq(RefPredicate.StartsWith(Ref.Tag("v"))) +ThisBuild / githubWorkflowPublish := Seq( + WorkflowStep.Sbt( + List("ci-release"), + env = Map( + "PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}", + "PGP_SECRET" -> "${{ secrets.PGP_SECRET }}", + "SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}", + "SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}" + ) + ) +) ThisBuild / githubWorkflowBuild := Seq( WorkflowStep.Sbt(List("clean", "coverage", "test"), name = Some("Build project")) diff --git a/project/plugins.sbt b/project/plugins.sbt index b9b4fbe..971d12b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,3 +3,4 @@ addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.1") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") diff --git a/version.sbt b/version.sbt deleted file mode 100644 index ad8b703..0000000 --- a/version.sbt +++ /dev/null @@ -1 +0,0 @@ -ThisBuild / version := "2.0.2-SNAPSHOT"