Skip to content

Commit cfaec74

Browse files
committed
Release native image concurrently
1 parent 4c980cb commit cfaec74

File tree

2 files changed

+72
-14
lines changed

2 files changed

+72
-14
lines changed

.github/workflows/ci.yml

+45-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,51 @@ jobs:
111111
tar xf targets.tar
112112
rm targets.tar
113113
114-
- run: sbt ++${{ matrix.scala }} ci-release
114+
- id: release
115+
run: sbt ++${{ matrix.scala }} ci-release
116+
117+
publish-native:
118+
name: Publish native images
119+
needs: [build]
120+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
121+
strategy:
122+
matrix:
123+
os: [macos-10.15]
124+
scala: [3.1.0]
125+
126+
runs-on: ${{ matrix.os }}
127+
steps:
128+
- name: Checkout current branch (full)
129+
uses: actions/checkout@v2
130+
with:
131+
fetch-depth: 0
132+
133+
- name: Setup Java and Scala
134+
uses: olafurpg/setup-scala@v13
135+
with:
136+
java-version: ${{ matrix.java }}
137+
138+
- name: Cache sbt
139+
uses: actions/cache@v2
140+
with:
141+
path: |
142+
~/.sbt
143+
~/.ivy2/cache
144+
~/.coursier/cache/v1
145+
~/.cache/coursier/v1
146+
~/AppData/Local/Coursier/Cache/v1
147+
~/Library/Caches/Coursier/v1
148+
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
149+
150+
- name: Download target directories (3.1.0)
151+
uses: actions/download-artifact@v2
152+
with:
153+
name: target-${{ matrix.os }}-3.1.0-${{ matrix.java }}
154+
155+
- name: Inflate target directories (3.1.0)
156+
run: |
157+
tar xf targets.tar
158+
rm targets.tar
115159
116160
- if: startsWith(github.ref, 'refs/tags/')
117161
run: sbt ++${{ matrix.scala }} nativeImage

build.sbt

+27-13
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,38 @@ ThisBuild / githubWorkflowOSes := Seq("macos-10.15")
2626

2727
ThisBuild / githubWorkflowPublish := Seq(
2828
WorkflowStep.Sbt(
29-
List("ci-release")
30-
),
31-
WorkflowStep.Sbt(
32-
List("nativeImage"),
33-
cond = Some("startsWith(github.ref, 'refs/tags/')")
34-
),
35-
WorkflowStep.Use(
36-
UseRef.Public("softprops", "action-gh-release", "v1"),
37-
params = Map("files" -> "target/native-image/spotify-next-${{ matrix.os }}"),
38-
cond = Some("startsWith(github.ref, 'refs/tags/')")
29+
List("ci-release"),
30+
id = Some("release")
3931
)
4032
)
4133
ThisBuild / githubWorkflowGeneratedCI ~= {
42-
_.map {
34+
_.flatMap {
4335
case job if job.id == "publish" =>
44-
job.copy(oses = List("macos-10.15"))
36+
job.copy(oses = List("macos-10.15")) ::
37+
job.copy(
38+
id = "publish-native",
39+
name = "Publish native images",
40+
oses = List("macos-10.15"),
41+
steps = job.steps.flatMap {
42+
case step if step.id.contains("release") =>
43+
List(
44+
WorkflowStep.Sbt(
45+
List("nativeImage"),
46+
cond = Some("startsWith(github.ref, 'refs/tags/')")
47+
),
48+
WorkflowStep.Use(
49+
UseRef.Public("softprops", "action-gh-release", "v1"),
50+
params = Map("files" -> "target/native-image/spotify-next-${{ matrix.os }}"),
51+
cond = Some("startsWith(github.ref, 'refs/tags/')")
52+
)
53+
)
54+
case step =>
55+
step :: Nil
56+
}
57+
) ::
58+
Nil
4559
case job =>
46-
job
60+
job :: Nil
4761
}
4862
}
4963

0 commit comments

Comments
 (0)