Skip to content

Commit

Permalink
Merge pull request #50 from sangria-graphql/automate-releases
Browse files Browse the repository at this point in the history
automated release process
  • Loading branch information
yanns authored Apr 20, 2021
2 parents 02ea883 + 8edd163 commit 229a400
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 14 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/
25 changes: 15 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ libraryDependencies ++= Seq(
)

// 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 }}"
)
)
)

startYear := Some(2016)
organizationHomepage := Some(url("https://github.com/sangria-graphql"))
Expand Down
2 changes: 0 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.0.15")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit 229a400

Please sign in to comment.