Skip to content

Commit e1923bf

Browse files
authored
Merge pull request #215 from mdedetrich/add-sbt-ci-release
2 parents 4d4cd31 + 599db85 commit e1923bf

File tree

3 files changed

+83
-5
lines changed

3 files changed

+83
-5
lines changed

.github/workflows/ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
branches: [master]
1313
push:
1414
branches: [master]
15+
tags: [v*]
1516

1617
env:
1718
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -55,3 +56,64 @@ jobs:
5556

5657
- name: Build project
5758
run: sbt ++${{ matrix.scala }} test
59+
60+
- name: Compress target directories
61+
run: tar cf targets.tar target project/target
62+
63+
- name: Upload target directories
64+
uses: actions/upload-artifact@v2
65+
with:
66+
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
67+
path: targets.tar
68+
69+
publish:
70+
name: Publish Artifacts
71+
needs: [build]
72+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
73+
strategy:
74+
matrix:
75+
os: [ubuntu-latest]
76+
scala: [2.12.15]
77+
java: [temurin@8]
78+
runs-on: ${{ matrix.os }}
79+
steps:
80+
- name: Checkout current branch (full)
81+
uses: actions/checkout@v2
82+
with:
83+
fetch-depth: 0
84+
85+
- name: Setup Java (temurin@8)
86+
if: matrix.java == 'temurin@8'
87+
uses: actions/setup-java@v2
88+
with:
89+
distribution: temurin
90+
java-version: 8
91+
92+
- name: Cache sbt
93+
uses: actions/cache@v2
94+
with:
95+
path: |
96+
~/.sbt
97+
~/.ivy2/cache
98+
~/.coursier/cache/v1
99+
~/.cache/coursier/v1
100+
~/AppData/Local/Coursier/Cache/v1
101+
~/Library/Caches/Coursier/v1
102+
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
103+
104+
- name: Download target directories (2.12.15)
105+
uses: actions/download-artifact@v2
106+
with:
107+
name: target-${{ matrix.os }}-2.12.15-${{ matrix.java }}
108+
109+
- name: Inflate target directories (2.12.15)
110+
run: |
111+
tar xf targets.tar
112+
rm targets.tar
113+
114+
- env:
115+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
116+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
117+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
118+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
119+
run: sbt ++${{ matrix.scala }} ci-release

build.sbt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,26 @@ scriptedLaunchOpts ++= java.lang.management.ManagementFactory.getRuntimeMXBean.g
3737
Seq("-Xmx", "-Xms", "-XX", "-Dfile").exists(a.startsWith)
3838
)
3939

40-
packageSrc / publishArtifact := false
40+
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
41+
ThisBuild / githubWorkflowPublishTargetBranches :=
42+
Seq(RefPredicate.StartsWith(Ref.Tag("v")))
43+
ThisBuild / githubWorkflowPublish := Seq(
44+
WorkflowStep.Sbt(
45+
List("ci-release"),
46+
env = Map(
47+
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
48+
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
49+
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
50+
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
51+
)
52+
)
53+
)
4154

42-
// Disable publish for now
43-
ThisBuild / githubWorkflowPublishTargetBranches := Seq()
55+
ThisBuild / publishMavenStyle := true
56+
ThisBuild / publishTo := sonatypePublishTo.value
57+
ThisBuild / test / publishArtifact := false
58+
ThisBuild / pomIncludeRepository := (_ => false)
59+
sonatypeProfileName := "com.lightbend"
4460

4561
ThisBuild / githubWorkflowJavaVersions := List(
4662
JavaSpec.temurin("8")

project/plugins.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
21
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
3-
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.5")
2+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
43
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
4+
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")

0 commit comments

Comments
 (0)