diff --git a/.github/workflows/reusable-release.yml b/.github/workflows/reusable-release.yml index f3a7386..4f01a4a 100644 --- a/.github/workflows/reusable-release.yml +++ b/.github/workflows/reusable-release.yml @@ -110,12 +110,27 @@ jobs: name: 🎊 Test & Version needs: init runs-on: ubuntu-latest + outputs: + library_build_java_version: ${{ steps.establish_library_build_java_version.outputs.library_build_java_version }} steps: - uses: actions/checkout@v4 + - id: establish_library_build_java_version + name: Establish library build Java version + run: | + if [ ! -f .tool-versions ]; then + echo "::error title=Missing .tool-versions file::gha-scala-library-release-workflow requires an asdf-format .tool-versions file to establish the Java version for the build." + exit 1 + fi + LIBRARY_BUILD_JAVA_VERSION=$( grep -Eo 'java [[:alpha:]-]+-[[:digit:]]+' .tool-versions | rev | cut -d'-' -f1 | rev ) + echo "LIBRARY_BUILD_JAVA_VERSION=$LIBRARY_BUILD_JAVA_VERSION" + + cat << EndOfFile >> $GITHUB_OUTPUT + library_build_java_version=$LIBRARY_BUILD_JAVA_VERSION + EndOfFile - uses: actions/setup-java@v4 # don't 'cache: sbt', at least until https://github.com/actions/setup-java/pull/564 is merged with: distribution: corretto - java-version: 17 + java-version: ${{ steps.establish_library_build_java_version.outputs.library_build_java_version }} # - name: Debug MIMA assessment # run: | # sbt "show versionPolicyFindIssues" @@ -239,7 +254,7 @@ jobs: create-artifacts: name: 🎊 Create artifacts - needs: [init, push-release-commit] + needs: [init, generate-version-update-commits, push-release-commit] runs-on: ubuntu-latest outputs: ARTIFACT_SHA256SUMS: ${{ steps.record-hashes.outputs.ARTIFACT_SHA256SUMS }} @@ -250,7 +265,7 @@ jobs: - uses: actions/setup-java@v4 # don't 'cache: sbt', at least until https://github.com/actions/setup-java/pull/564 is resolved with: distribution: corretto - java-version: 17 + java-version: ${{ needs.generate-version-update-commits.outputs.library_build_java_version }} - name: Generate artifacts run: | cat << EndOfFile > sbt-commands.txt diff --git a/docs/configuration.md b/docs/configuration.md index b4b76a9..a17b147 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -37,6 +37,19 @@ Your repo will require access to [release credentials](credentials/supplying-cre [pass on those secrets](https://github.com/guardian/etag-caching/blob/9935da29e76b8b89759bcfe967cc7c1c02aa1814/.github/workflows/release.yml#L11-L13) to the workflow. +## Java version + +[Example `.tool-versions`]() + +Your repository *must* contain an asdf-formatted `.tool-versions` file in the root of the repository, +specifying the Java version to be used by the workflow, eg: + +``` +java corretto-21.0.3.9.1 +``` + + + ## `sbt` ### Recommended `sbt` plugins