mirror of
https://github.com/actions/setup-java.git
synced 2026-08-06 14:09:29 +08:00
f4bfb3ddea
* Fix floating Oracle JDK version resolution Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Update generated distribution bundles Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Harden floating artifact cache identity Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Regenerate setup bundle after cache hardening Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Temporarily enable hosted full validation Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Export hosted formatting results Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Apply repository formatting Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Run hosted validation after formatting Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Correct floating version regression tests Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Remove temporary validation wiring Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Cache checksum-less floating artifacts by their response fingerprint Oracle and Oracle GraalVM do not always publish a `.sha256` sibling next to a `/latest/` artifact. Those floating releases were excluded from both the resolution cache and the JDK cache, so `cache-jdk` users lost caching entirely for them. A floating URL is a constant string, so it cannot serve as a cache identity on its own — a stale entry would be reused forever. Instead, derive a validator from the headers of the HEAD request that already resolves the artifact: the ETag when present, otherwise `Last-Modified` combined with `Content-Length`. Republishing changes the validator, which changes the cache key, so a new build is downloaded rather than masked. `getJdkReleaseIdentity` now falls back to that fingerprint before the URL, and the floating cache gates ask whether the release has a stable identity (checksum or fingerprint) rather than a checksum specifically. A floating release with neither is still left uncached. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Bruno Borges <brborges@microsoft.com>
57 lines
1.7 KiB
Bash
Executable File
57 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "::error::Must supply java version argument"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "$2" ]; then
|
|
echo "::error::Must supply java path argument"
|
|
exit 1
|
|
fi
|
|
|
|
EXPECTED_JAVA_VERSION=$1
|
|
EXPECTED_PATH=$2
|
|
SETUP_JAVA_VERSION=$3
|
|
REQUIRE_CONCRETE_VERSION=$4
|
|
|
|
EXPECTED_JAVA_VERSION=$(echo $EXPECTED_JAVA_VERSION | cut -d'+' -f1)
|
|
if [[ $EXPECTED_JAVA_VERSION == 8 ]] || [[ $EXPECTED_JAVA_VERSION == 8.* ]]; then
|
|
EXPECTED_JAVA_VERSION="1.${EXPECTED_JAVA_VERSION}"
|
|
fi
|
|
if [[ $EXPECTED_JAVA_VERSION == *-ea* ]]; then
|
|
EXPECTED_JAVA_VERSION=$(echo $EXPECTED_JAVA_VERSION | cut -d'-' -f1 | cut -d'.' -f1)
|
|
fi
|
|
|
|
ACTUAL_JAVA_VERSION="$(java -version 2>&1)"
|
|
echo "Found java version: $ACTUAL_JAVA_VERSION"
|
|
|
|
GREP_RESULT=$(echo $ACTUAL_JAVA_VERSION | grep -E "^(openjdk|java) version \"$EXPECTED_JAVA_VERSION")
|
|
if [ -z "$GREP_RESULT" ]; then
|
|
echo "::error::Unexpected version"
|
|
echo "Expected version: $EXPECTED_JAVA_VERSION"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "$SETUP_JAVA_VERSION" ]; then
|
|
OUTPUT_JAVA_VERSION=$(echo "$SETUP_JAVA_VERSION" | cut -d'+' -f1)
|
|
OUTPUT_GREP_RESULT=$(echo "$ACTUAL_JAVA_VERSION" | grep -E "^(openjdk|java) version \"$OUTPUT_JAVA_VERSION")
|
|
if [ -z "$OUTPUT_GREP_RESULT" ]; then
|
|
echo "::error::The version output does not match the installed Java version"
|
|
echo "Version output: $SETUP_JAVA_VERSION"
|
|
exit 1
|
|
fi
|
|
if [ "$REQUIRE_CONCRETE_VERSION" = "true" ] && [ "$OUTPUT_JAVA_VERSION" = "$EXPECTED_JAVA_VERSION" ]; then
|
|
echo "::error::Expected a concrete version output for a floating JDK"
|
|
echo "Version output: $SETUP_JAVA_VERSION"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "$EXPECTED_PATH" != "$JAVA_HOME" ]; then
|
|
echo "::error::Unexpected path"
|
|
echo "Actual path: $JAVA_HOME"
|
|
echo "Expected path: $EXPECTED_PATH"
|
|
exit 1
|
|
fi
|