Skip to content

Commit

Permalink
Merge pull request #39 from sangria-graphql/automate-releases
Browse files Browse the repository at this point in the history
automate releases
  • Loading branch information
nickhudkins authored Apr 20, 2021
2 parents 47f832f + 1f11830 commit e0da182
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 16 deletions.
72 changes: 71 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
branches: ['*']
push:
branches: ['*']
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -58,4 +59,73 @@ jobs:
run: sbt ++${{ matrix.scala }} githubWorkflowCheck

- name: Build project
run: sbt ++${{ matrix.scala }} test
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: [[email protected]]
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ classes

# files
*.iml
.metals/
.vscode/
30 changes: 16 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,25 @@ scalacOptions ++= Seq("-deprecation", "-feature")
scalacOptions ++= Seq("-target:jvm-1.8")
javacOptions ++= Seq("-source", "8", "-target", "8")

git.remoteRepo := "[email protected]: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
}

Expand Down
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit e0da182

Please sign in to comment.