Skip to content

Commit aa37482

Browse files
committed
Use sbt-github-actions
1 parent d3e685c commit aa37482

File tree

6 files changed

+240
-74
lines changed

6 files changed

+240
-74
lines changed

.github/workflows/build-test.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Continuous Integration
9+
10+
on:
11+
pull_request:
12+
branches: ['**']
13+
push:
14+
branches: ['**']
15+
tags: ['*.*.*']
16+
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
jobs:
21+
build:
22+
name: Build and Test
23+
strategy:
24+
matrix:
25+
os: [ubuntu-latest, macos-latest]
26+
scala: [2.12.19]
27+
java: [temurin@8, temurin@11, temurin@17, temurin@21]
28+
runs-on: ${{ matrix.os }}
29+
steps:
30+
- name: Checkout current branch (full)
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Setup Java (temurin@8)
36+
if: matrix.java == 'temurin@8'
37+
uses: actions/setup-java@v4
38+
with:
39+
distribution: temurin
40+
java-version: 8
41+
cache: sbt
42+
43+
- name: Setup Java (temurin@11)
44+
if: matrix.java == 'temurin@11'
45+
uses: actions/setup-java@v4
46+
with:
47+
distribution: temurin
48+
java-version: 11
49+
cache: sbt
50+
51+
- name: Setup Java (temurin@17)
52+
if: matrix.java == 'temurin@17'
53+
uses: actions/setup-java@v4
54+
with:
55+
distribution: temurin
56+
java-version: 17
57+
cache: sbt
58+
59+
- name: Setup Java (temurin@21)
60+
if: matrix.java == 'temurin@21'
61+
uses: actions/setup-java@v4
62+
with:
63+
distribution: temurin
64+
java-version: 21
65+
cache: sbt
66+
67+
- name: Check that workflows are up to date
68+
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
69+
70+
- run: sbt '++ ${{ matrix.scala }}' test scripted
71+
72+
- name: Compress target directories
73+
run: tar cf targets.tar target project/target
74+
75+
- name: Upload target directories
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
79+
path: targets.tar
80+
81+
publish:
82+
name: Publish Artifacts
83+
needs: [build]
84+
if: github.event_name != 'pull_request' && ((startsWith(github.ref, 'refs/tags/') && contains(github.ref, '*.*.*')) || github.ref == 'refs/heads/main')
85+
strategy:
86+
matrix:
87+
os: [ubuntu-latest]
88+
scala: [2.12.19]
89+
java: [temurin@8]
90+
runs-on: ${{ matrix.os }}
91+
steps:
92+
- name: Checkout current branch (full)
93+
uses: actions/checkout@v4
94+
with:
95+
fetch-depth: 0
96+
97+
- name: Setup Java (temurin@8)
98+
if: matrix.java == 'temurin@8'
99+
uses: actions/setup-java@v4
100+
with:
101+
distribution: temurin
102+
java-version: 8
103+
cache: sbt
104+
105+
- name: Setup Java (temurin@11)
106+
if: matrix.java == 'temurin@11'
107+
uses: actions/setup-java@v4
108+
with:
109+
distribution: temurin
110+
java-version: 11
111+
cache: sbt
112+
113+
- name: Setup Java (temurin@17)
114+
if: matrix.java == 'temurin@17'
115+
uses: actions/setup-java@v4
116+
with:
117+
distribution: temurin
118+
java-version: 17
119+
cache: sbt
120+
121+
- name: Setup Java (temurin@21)
122+
if: matrix.java == 'temurin@21'
123+
uses: actions/setup-java@v4
124+
with:
125+
distribution: temurin
126+
java-version: 21
127+
cache: sbt
128+
129+
- name: Download target directories (2.12.19)
130+
uses: actions/download-artifact@v4
131+
with:
132+
name: target-${{ matrix.os }}-2.12.19-${{ matrix.java }}
133+
134+
- name: Inflate target directories (2.12.19)
135+
run: |
136+
tar xf targets.tar
137+
rm targets.tar
138+
139+
- name: Publish project
140+
env:
141+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
142+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
143+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
144+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
145+
run: sbt ci-release

.github/workflows/clean.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Clean
9+
10+
on: push
11+
12+
jobs:
13+
delete-artifacts:
14+
name: Delete Artifacts
15+
runs-on: ubuntu-latest
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- name: Delete artifacts
20+
shell: bash {0}
21+
run: |
22+
# Customize those three lines with your repository and credentials:
23+
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
24+
25+
# A shortcut to call GitHub API.
26+
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
27+
28+
# A temporary file which receives HTTP response headers.
29+
TMPFILE=$(mktemp)
30+
31+
# An associative array, key: artifact name, value: number of artifacts of that name.
32+
declare -A ARTCOUNT
33+
34+
# Process all artifacts on this repository, loop on returned "pages".
35+
URL=$REPO/actions/artifacts
36+
while [[ -n "$URL" ]]; do
37+
38+
# Get current page, get response headers in a temporary file.
39+
JSON=$(ghapi --dump-header $TMPFILE "$URL")
40+
41+
# Get URL of next page. Will be empty if we are at the last page.
42+
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
43+
rm -f $TMPFILE
44+
45+
# Number of artifacts on this page:
46+
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
47+
48+
# Loop on all artifacts on this page.
49+
for ((i=0; $i < $COUNT; i++)); do
50+
51+
# Get name of artifact and count instances of this name.
52+
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
53+
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
54+
55+
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
56+
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
57+
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
58+
ghapi -X DELETE $REPO/actions/artifacts/$id
59+
done
60+
done

.github/workflows/publish.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

build.sbt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,37 @@ Global / onLoad := (Global / onLoad).value.andThen { s =>
2626
dynverAssertTagVersion.value
2727
s
2828
}
29+
30+
lazy val scala212 = "2.12.19"
31+
ThisBuild / crossScalaVersions := Seq(scala212)
32+
ThisBuild / scalaVersion := scala212
33+
34+
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "scripted")))
35+
36+
ThisBuild / githubWorkflowTargetTags ++= Seq("*.*.*")
37+
ThisBuild / githubWorkflowPublishTargetBranches :=
38+
Seq(
39+
RefPredicate.Contains(Ref.Tag("*.*.*")),
40+
RefPredicate.Equals(Ref.Branch("main"))
41+
)
42+
ThisBuild / githubWorkflowPublish := Seq(
43+
WorkflowStep.Sbt(
44+
commands = List("ci-release"),
45+
name = Some("Publish project"),
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+
)
54+
55+
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest")
56+
57+
ThisBuild / githubWorkflowJavaVersions := Seq(
58+
JavaSpec.temurin("8"),
59+
JavaSpec.temurin("11"),
60+
JavaSpec.temurin("17"),
61+
JavaSpec.temurin("21")
62+
)

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
addSbtPlugin("com.github.sbt" % "sbt-web-build-base" % "2.0.2")
22
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
33
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
4+
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.22.0")

0 commit comments

Comments
 (0)