Combining setup-java & setup-sbt with good defaults for the Guardian
Get rid of this:
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 21
cache: sbtand replace it with this:
- uses: guardian/setup-scala@v1Specifically:
- In your GitHub Action workflow definition (eg
ci.yml), understeps::- Remove the
setup-javastep and its config (andsetup-sbtif you have it) - Add
- uses: guardian/setup-scala@v1where theactions/setup-javaconfig was (example)
- Remove the
- Add a
.tool-versionsfile if you don't already have one, specifying the version of Java you want to use (example)
Example PR removing setup-java and installing setup-scala.
- Java distribution used: always the AWS Corretto distribution of Java, the standard Java distro used at the Guardian.
Note that (like gha-scala-library-release-workflow) guardian/setup-scala
requires that projects specify their Java version with an asdf-formatted .tool-versions file.
Although asdf requires a fully-specified Java version (eg 21.0.3.9.1) in the .tool-versions file,
currently the workflow will only match the major version of Java specified in the file (eg 21).
This is due to limitations in actions/setup-java.