Skip to content

Commit f3f09a3

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

File tree

6 files changed

+268
-74
lines changed

6 files changed

+268
-74
lines changed

.github/workflows/build-test.yml

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

.github/workflows/ci.yml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
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, windows-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: Ignore line ending differences in git
31+
if: contains(runner.os, 'windows')
32+
shell: bash
33+
run: git config --global core.autocrlf false
34+
35+
- name: Configure pagefile for Windows
36+
if: contains(runner.os, 'windows')
37+
uses: al-cheb/configure-pagefile-action@v1.3
38+
with:
39+
minimum-size: 2GB
40+
maximum-size: 8GB
41+
disk-root: 'C:'
42+
43+
- name: Checkout current branch (full)
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Setup Java (temurin@8)
49+
if: matrix.java == 'temurin@8'
50+
uses: actions/setup-java@v4
51+
with:
52+
distribution: temurin
53+
java-version: 8
54+
cache: sbt
55+
56+
- name: Setup Java (temurin@11)
57+
if: matrix.java == 'temurin@11'
58+
uses: actions/setup-java@v4
59+
with:
60+
distribution: temurin
61+
java-version: 11
62+
cache: sbt
63+
64+
- name: Setup Java (temurin@17)
65+
if: matrix.java == 'temurin@17'
66+
uses: actions/setup-java@v4
67+
with:
68+
distribution: temurin
69+
java-version: 17
70+
cache: sbt
71+
72+
- name: Setup Java (temurin@21)
73+
if: matrix.java == 'temurin@21'
74+
uses: actions/setup-java@v4
75+
with:
76+
distribution: temurin
77+
java-version: 21
78+
cache: sbt
79+
80+
- name: Check that workflows are up to date
81+
shell: bash
82+
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
83+
84+
- shell: bash
85+
run: sbt '++ ${{ matrix.scala }}' test scripted
86+
87+
- name: Compress target directories
88+
shell: bash
89+
run: tar cf targets.tar target project/target
90+
91+
- name: Upload target directories
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
95+
path: targets.tar
96+
97+
publish:
98+
name: Publish Artifacts
99+
needs: [build]
100+
if: github.event_name != 'pull_request' && ((startsWith(github.ref, 'refs/tags/') && contains(github.ref, '*.*.*')) || github.ref == 'refs/heads/main')
101+
strategy:
102+
matrix:
103+
os: [ubuntu-latest]
104+
scala: [2.12.19]
105+
java: [temurin@8]
106+
runs-on: ${{ matrix.os }}
107+
steps:
108+
- name: Ignore line ending differences in git
109+
if: contains(runner.os, 'windows')
110+
run: git config --global core.autocrlf false
111+
112+
- name: Configure pagefile for Windows
113+
if: contains(runner.os, 'windows')
114+
uses: al-cheb/configure-pagefile-action@v1.3
115+
with:
116+
minimum-size: 2GB
117+
maximum-size: 8GB
118+
disk-root: 'C:'
119+
120+
- name: Checkout current branch (full)
121+
uses: actions/checkout@v4
122+
with:
123+
fetch-depth: 0
124+
125+
- name: Setup Java (temurin@8)
126+
if: matrix.java == 'temurin@8'
127+
uses: actions/setup-java@v4
128+
with:
129+
distribution: temurin
130+
java-version: 8
131+
cache: sbt
132+
133+
- name: Setup Java (temurin@11)
134+
if: matrix.java == 'temurin@11'
135+
uses: actions/setup-java@v4
136+
with:
137+
distribution: temurin
138+
java-version: 11
139+
cache: sbt
140+
141+
- name: Setup Java (temurin@17)
142+
if: matrix.java == 'temurin@17'
143+
uses: actions/setup-java@v4
144+
with:
145+
distribution: temurin
146+
java-version: 17
147+
cache: sbt
148+
149+
- name: Setup Java (temurin@21)
150+
if: matrix.java == 'temurin@21'
151+
uses: actions/setup-java@v4
152+
with:
153+
distribution: temurin
154+
java-version: 21
155+
cache: sbt
156+
157+
- name: Download target directories (2.12.19)
158+
uses: actions/download-artifact@v4
159+
with:
160+
name: target-${{ matrix.os }}-2.12.19-${{ matrix.java }}
161+
162+
- name: Inflate target directories (2.12.19)
163+
run: |
164+
tar xf targets.tar
165+
rm targets.tar
166+
167+
- name: Publish project
168+
env:
169+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
170+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
171+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
172+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
173+
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", "windows-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)