-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
47 lines (41 loc) · 1.82 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: "Setup Scala with both Java and sbt"
description: "Much longer description"
inputs:
major-java-version:
description: 'Specify a major Java version (21, 11, etc) as an alternative to reading one from .tool-versions'
required: false
default: ''
runs:
using: "composite"
steps:
- name: Determine major Java version
id: determine-java-version
shell: bash
env:
MAJOR_JAVA_VERSION: ${{ inputs.major-java-version }}
run: |
if [ ${MAJOR_JAVA_VERSION} ]; then
echo "Reading Java version from the 'major-java-version' input property, rather than .tool-versions"
else
if [ ! -f .tool-versions ]; then
echo "::error title=Missing .tool-versions file::setup-scala prefers an asdf-format .tool-versions file to establish the Java version for the build - a standard file that is understood by many different tools. Failing this, specify the 'major-java-version' parameter."
exit 1
fi
MAJOR_JAVA_VERSION=$( grep -Eo 'java [[:alnum:]-]+-[[:digit:]]+' .tool-versions | rev | cut -d'-' -f1 | rev )
if [ -z "${MAJOR_JAVA_VERSION}" ]; then
echo "::error title=Missing Java version in .tool-versions file::Could not establish the project's required Java version - the '.tool-versions' file should have a line like 'java corretto-21.0.3.9.1'."
exit 1
fi
fi
echo "Using Java $MAJOR_JAVA_VERSION"
cat << EndOfFile >> $GITHUB_OUTPUT
major_java_version=$MAJOR_JAVA_VERSION
EndOfFile
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: ${{ steps.determine-java-version.outputs.major_java_version }}
distribution: "corretto"
cache: sbt
- name: Setup sbt
uses: sbt/[email protected]