Skip to content

Commit 159bc2b

Browse files
committed
Initial commit
0 parents  commit 159bc2b

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 eugene yokota
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Setup sbt
2+
=========
3+
4+
This action enables `sbt` runner from GitHub Actions.
5+
6+
Usage
7+
-----
8+
9+
Here's an example usage of setup-sbt action.
10+
11+
```yaml
12+
env:
13+
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Setup JDK
17+
uses: actions/setup-java@v4
18+
with:
19+
distribution: temurin
20+
java-version: 17
21+
cache: sbt
22+
- uses: sbt/setup-sbt@v1
23+
- name: Build and test
24+
shell: bash
25+
run: sbt -v +test
26+
```
27+
28+
`uses: sbt/setup-sbt@v1` makes `sbt` available on Linux, macOS, and Windows.
29+
30+
### Setting the runner version
31+
32+
The `sbt` runner (Bash script that launches sbt) is typically compatible with all modern sbt releases,
33+
you might want to pin the runner to a specific version.
34+
35+
```yaml
36+
env:
37+
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Setup JDK
41+
uses: actions/setup-java@v4
42+
with:
43+
distribution: temurin
44+
java-version: 17
45+
cache: sbt
46+
- uses: sbt/setup-sbt@v1
47+
with:
48+
sbt-runner-version: 1.9.9
49+
- name: Build and test
50+
shell: bash
51+
run: sbt -v +test
52+
```
53+
54+
Why is this GitHub Action needed?
55+
---------------------------------
56+
57+
The runner images on GitHub Action has long included `sbt` runner script. The [initial commit on actions/runner-images](https://github.com/actions/runner-images/pull/96) contains `images/linux/scripts/installers/sbt.sh`. However, the situation has changed in May 2024 when GitHub released the runner image for `macos-13` and `macos-14`, users noticed that they were missing the `sbt` runner script.
58+
59+
[actions/runner-images#9369](https://github.com/actions/runner-images/issues/9369) and [actions/runner-images#9837](https://github.com/actions/runner-images/issues/9837) confirmed that this was intentional:
60+
61+
> Thank you for such detail request. But currently we have no plans to add `sbt` on `macOS-13`/`macOS-14`.
62+
63+
Since GitHub Actions are extensible, we thought this providing a setup action would be convenient way to enable `sbt` again on all runner images.
64+
65+
License
66+
-------
67+
68+
The scripts and documentation in this project are released under the [MIT License](LICENSE).

action.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Setup sbt"
2+
description: "Sets up sbt runner script"
3+
inputs:
4+
sbt-runner-version:
5+
description: "The runner version (The actual version is controlled via project/build.properties)"
6+
required: true
7+
default: 1.10.0
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Cache sbt distribution
12+
id: cache-dir
13+
uses: actions/cache@v4
14+
with:
15+
path: setupsbt
16+
key: ${{ runner.os }}-sbt-${{ inputs.sbt-runner-version }}
17+
18+
- name: "Install sbt"
19+
shell: bash
20+
if: steps.cache-dir.outputs.cache-hit != 'true'
21+
run: |
22+
mkdir -p setupsbt
23+
curl -sL https://github.com/sbt/sbt/releases/download/v$SBT_RUNNER_VERSION/sbt-$SBT_RUNNER_VERSION.zip > setupsbt/sbt-$SBT_RUNNER_VERSION.zip
24+
pushd setupsbt
25+
unzip -o "sbt-$SBT_RUNNER_VERSION.zip"
26+
popd
27+
env:
28+
SBT_RUNNER_VERSION: ${{ inputs.sbt-runner-version }}
29+
30+
- name: "Setup PATH"
31+
shell: bash
32+
run: |
33+
pushd setupsbt
34+
ls sbt/bin/sbt
35+
echo "$PWD/sbt/bin" >> "$GITHUB_PATH"
36+
popd

0 commit comments

Comments
 (0)