From 1f11830679bdab2c09fda7e4fc3ffdf989ca07cb Mon Sep 17 00:00:00 2001 From: Nick Hudkins Date: Mon, 19 Apr 2021 17:00:29 -0400 Subject: [PATCH] automate releases --- .github/workflows/ci.yml | 72 +++++++++++++++++++++++++++++++++++++++- .gitignore | 2 ++ build.sbt | 30 +++++++++-------- version.sbt | 1 - 4 files changed, 89 insertions(+), 16 deletions(-) delete mode 100644 version.sbt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff4865e..e753ce5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ on: branches: ['*'] push: branches: ['*'] + tags: [v*] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -58,4 +59,73 @@ jobs: run: sbt ++${{ matrix.scala }} githubWorkflowCheck - name: Build project - run: sbt ++${{ matrix.scala }} test \ No newline at end of file + run: sbt ++${{ matrix.scala }} test + + - 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.5] + java: [adopt@1.8] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java and Scala + uses: olafurpg/setup-scala@v10 + with: + java-version: ${{ matrix.java }} + + - 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.13) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.12.13-${{ matrix.java }} + + - name: Inflate target directories (2.12.13) + run: | + tar xf targets.tar + rm targets.tar + + - name: Download target directories (2.13.5) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.13.5-${{ matrix.java }} + + - name: Inflate target directories (2.13.5) + 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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7cafe1c..f72bca4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ classes # files *.iml +.metals/ +.vscode/ diff --git a/build.sbt b/build.sbt index 41929dc..0aad30b 100644 --- a/build.sbt +++ b/build.sbt @@ -20,23 +20,25 @@ scalacOptions ++= Seq("-deprecation", "-feature") scalacOptions ++= Seq("-target:jvm-1.8") javacOptions ++= Seq("-source", "8", "-target", "8") -git.remoteRepo := "git@github.com:sangria-graphql/sangria-streaming-api.git" - // Publishing -releaseCrossBuild := true -releasePublishArtifactsAction := PgpKeys.publishSigned.value -publishMavenStyle := true -publishArtifact in Test := false -pomIncludeRepository := (_ ⇒ false) -publishTo := Some( - if (version.value.trim.endsWith("SNAPSHOT")) - "snapshots".at("https://oss.sonatype.org/content/repositories/snapshots") - else - "releases".at("https://oss.sonatype.org/service/local/staging/deploy/maven2")) +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 }}" + ) + ) +) // nice *magenta* prompt! - -shellPrompt in ThisBuild := { state ⇒ +ThisBuild / shellPrompt := { state ⇒ scala.Console.MAGENTA + Project.extract(state).currentRef.project + "> " + scala.Console.RESET } diff --git a/version.sbt b/version.sbt deleted file mode 100644 index ba08e96..0000000 --- a/version.sbt +++ /dev/null @@ -1 +0,0 @@ -version in ThisBuild := "1.0.3-SNAPSHOT"