mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
61 lines
2.3 KiB
YAML
61 lines
2.3 KiB
YAML
name: Local Java
|
|
description: Configure the JDK already installed on the GitHub Actions runner
|
|
inputs:
|
|
java-version:
|
|
description: JDK major version
|
|
required: false
|
|
default: "25"
|
|
architecture:
|
|
description: Compatibility input for existing workflow call sites
|
|
required: false
|
|
default: ""
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Configure preinstalled JDK
|
|
shell: bash
|
|
env:
|
|
JAVA_VERSION: ${{ inputs.java-version }}
|
|
JAVA_ARCHITECTURE: ${{ inputs.architecture }}
|
|
RUNNER_ARCHITECTURE: ${{ runner.arch }}
|
|
RUNNER_OS_NAME: ${{ runner.os }}
|
|
run: |
|
|
set -euo pipefail
|
|
if [ "${JAVA_VERSION}" != "25" ]; then
|
|
echo "This repository requires JDK 25; received ${JAVA_VERSION}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
architecture="${JAVA_ARCHITECTURE}"
|
|
if [ -z "${architecture}" ]; then
|
|
architecture="${RUNNER_ARCHITECTURE}"
|
|
fi
|
|
normalized_architecture="$(printf '%s' "${architecture}" | tr '[:lower:]' '[:upper:]')"
|
|
case "${normalized_architecture}" in
|
|
X64|AMD64|X86_64) architecture=X64 ;;
|
|
ARM64|AARCH64) architecture=ARM64 ;;
|
|
*) echo "Unsupported runner architecture: ${architecture}" >&2; exit 1 ;;
|
|
esac
|
|
|
|
java_home_variable="JAVA_HOME_${JAVA_VERSION}_${architecture}"
|
|
java_home="${!java_home_variable:-}"
|
|
if [ -z "${java_home}" ] && [ "${RUNNER_OS_NAME}" = "macOS" ] && [ "${architecture}" = "X64" ]; then
|
|
java_home="$(arch -x86_64 /usr/libexec/java_home -v "${JAVA_VERSION}" 2>/dev/null || true)"
|
|
fi
|
|
if [ -z "${java_home}" ]; then
|
|
echo "JDK 25 is not installed on this runner (${java_home_variable} is missing)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
shell_java_home="${java_home}"
|
|
if command -v cygpath >/dev/null 2>&1; then
|
|
shell_java_home="$(cygpath --unix "${java_home}")"
|
|
fi
|
|
|
|
export JAVA_HOME="${shell_java_home}"
|
|
export PATH="${shell_java_home}/bin:${PATH}"
|
|
echo "JAVA_HOME=${java_home}" >> "${GITHUB_ENV}"
|
|
echo "${java_home}/bin" >> "${GITHUB_PATH}"
|
|
java -version 2>&1 | tee "${RUNNER_TEMP}/java-version.txt"
|
|
grep -Eq "version \"${JAVA_VERSION}(\.|\")" "${RUNNER_TEMP}/java-version.txt"
|