Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/e2e-local-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
id: setup-java
with:
distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
jdk-file: ${{ runner.temp }}/${{ env.LocalFilename }}
java-version: '11.0.0-ea'
architecture: x64
- name: Verify Java version
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
id: setup-java
with:
distribution: 'jdkfile'
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
jdk-file: ${{ runner.temp }}/${{ env.LocalFilename }}
java-version: '11.0.0-ea'
architecture: x64
- name: Verify Java version
Expand Down Expand Up @@ -129,6 +129,7 @@ jobs:
id: setup-java
with:
distribution: 'jdkfile'
# Intentionally uses the deprecated `jdkFile` alias to keep it covered.
jdkFile: ${{ runner.temp }}/${{ env.LocalFilename }}
java-version: '11.0.0-ea'
architecture: x64
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ For more details, see the full release notes on the [releases page](https://git

- `architecture`: The target architecture of the package. Possible values: `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`. Default value: Derived from the runner machine.

- `jdkFile`: If a use-case requires a custom distribution setup-java uses the compressed JDK from the location pointed by this input and will take care of the installation and caching on the VM. Note: `distribution` must be set to 'jdkfile' (case-sensitive; all lowercase) when using this option.
- `jdk-file`: If a use-case requires a custom distribution setup-java uses the compressed JDK from the location pointed by this input and will take care of the installation and caching on the VM. Note: `distribution` must be set to 'jdkfile' (case-sensitive; all lowercase) when using this option. (The camelCase `jdkFile` input is still accepted as a deprecated alias and may be removed in a future release.)

- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.

Expand Down
6 changes: 3 additions & 3 deletions __tests__/distributors/zulu-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('getAvailableVersions', () => {
packageType: 'jdk',
checkLatest: false
},
'?os=macos&archive_type=tar.gz&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=x86&release_status=ga&availability_types=ca&page=1&page_size=100'
'?os=macos&archive_type=tar.gz&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=i686&release_status=ga&availability_types=ca&page=1&page_size=100'
],
[
{
Expand All @@ -96,7 +96,7 @@ describe('getAvailableVersions', () => {
packageType: 'jdk',
checkLatest: false
},
'?os=macos&archive_type=tar.gz&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=x86&release_status=ea&availability_types=ca&page=1&page_size=100'
'?os=macos&archive_type=tar.gz&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=i686&release_status=ea&availability_types=ca&page=1&page_size=100'
],
[
{
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('getAvailableVersions', () => {
describe('getArchitectureOptions', () => {
it.each([
[{architecture: 'x64'}, 'x64'],
[{architecture: 'x86'}, 'x86'],
[{architecture: 'x86'}, 'i686'],
[{architecture: 'aarch64'}, 'aarch64'],
[{architecture: 'arm64'}, 'aarch64'],
[{architecture: 'arm'}, 'arm']
Expand Down
6 changes: 3 additions & 3 deletions __tests__/distributors/zulu-linux-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('getAvailableVersions', () => {
packageType: 'jdk',
checkLatest: false
},
'?os=linux_glibc&archive_type=zip&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=x86&release_status=ga&availability_types=ca&page=1&page_size=100'
'?os=linux_glibc&archive_type=zip&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=i686&release_status=ga&availability_types=ca&page=1&page_size=100'
],
[
{
Expand All @@ -98,7 +98,7 @@ describe('getAvailableVersions', () => {
packageType: 'jdk',
checkLatest: false
},
'?os=linux_glibc&archive_type=zip&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=x86&release_status=ea&availability_types=ca&page=1&page_size=100'
'?os=linux_glibc&archive_type=zip&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=i686&release_status=ea&availability_types=ca&page=1&page_size=100'
],
[
{
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('getAvailableVersions', () => {
describe('getArchitectureOptions', () => {
it.each([
[{architecture: 'x64'}, 'x64'],
[{architecture: 'x86'}, 'x86'],
[{architecture: 'x86'}, 'i686'],
[{architecture: 'aarch64'}, 'aarch64'],
[{architecture: 'arm64'}, 'aarch64'],
[{architecture: 'arm'}, 'arm']
Expand Down
6 changes: 3 additions & 3 deletions __tests__/distributors/zulu-windows-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('getAvailableVersions', () => {
packageType: 'jdk',
checkLatest: false
},
'?os=windows&archive_type=zip&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=x86&release_status=ga&availability_types=ca&page=1&page_size=100'
'?os=windows&archive_type=zip&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=i686&release_status=ga&availability_types=ca&page=1&page_size=100'
],
[
{
Expand All @@ -97,7 +97,7 @@ describe('getAvailableVersions', () => {
packageType: 'jdk',
checkLatest: false
},
'?os=windows&archive_type=zip&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=x86&release_status=ea&availability_types=ca&page=1&page_size=100'
'?os=windows&archive_type=zip&java_package_type=jdk&javafx_bundled=false&crac_supported=false&arch=i686&release_status=ea&availability_types=ca&page=1&page_size=100'
],
[
{
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('getAvailableVersions', () => {
describe('getArchitectureOptions', () => {
it.each([
[{architecture: 'x64'}, 'x64'],
[{architecture: 'x86'}, 'x86'],
[{architecture: 'x86'}, 'i686'],
[{architecture: 'aarch64'}, 'aarch64'],
[{architecture: 'arm64'}, 'aarch64'],
[{architecture: 'arm'}, 'arm']
Expand Down
66 changes: 66 additions & 0 deletions __tests__/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,72 @@ describe('getVersionFromFileContent', () => {
);
});
});

describe('.tool-versions', () => {
it.each([
['java temurin-17.0.3+7', '17.0.3+7', 'temurin'],
['java temurin-jre-17.0.3+7', '17.0.3+7', 'temurin'],
['java adoptopenjdk-11.0.16+8', '11.0.16+8', 'temurin'],
['java adoptopenjdk-openj9-11.0.16+8', '11.0.16+8', 'temurin'],
['java zulu-11.56.19', '11.56.19', 'zulu'],
['java corretto-17.0.13.11.1', '17', 'corretto'], // corretto -> major only
['java liberica-11.0.15+10', '11.0.15+10', 'liberica'],
['java microsoft-11.0.13.8.1', '11.0.13', 'microsoft'],
['java semeru-openj9-11.0.25+9', '11.0.25+9', 'semeru'],
['java ibm-openj9-11.0.25+9', '11.0.25+9', 'semeru'],
['java dragonwell-17.0.13.0.13+11', '17.0.13', 'dragonwell'],
['java graalvm-22.3.0+java17', '22.3.0+java17', 'graalvm'],
['java graalvm-community-22.3.0', '22.3.0', 'graalvm-community'],
['java oracle-graalvm-21.0.5', '21.0.5', 'graalvm'],
['java oracle-21.0.5', '21.0.5', 'oracle'],
['java sapmachine-21.0.5', '21.0.5', 'sapmachine'],
['java kona-17.0.13', '17.0.13', 'kona'],
['java jetbrains-21.0.5', '21.0.5', 'jetbrains']
])(
'parsing %s should return version %s and distribution %s',
(content: string, expectedVersion: string, expectedDist: string) => {
const actual = getVersionFromFileContent(
content,
'openjdk',
'.tool-versions'
);
expect(actual?.version).toBe(expectedVersion);
expect(actual?.distribution).toBe(expectedDist);
}
);

it.each([
['java 17.0.7', '17.0.7'],
['java 17', '17'],
['java 1.8', '8'],
['java 21-ea', '21-ea']
])(
'parsing prefix-less %s should return version %s and no distribution',
(content: string, expectedVersion: string) => {
const actual = getVersionFromFileContent(
content,
'temurin',
'.tool-versions'
);
expect(actual?.version).toBe(expectedVersion);
expect(actual?.distribution).toBeUndefined();
}
);

it('should warn and return undefined distribution for unsupported vendor', () => {
const warnSpy = jest.spyOn(core, 'warning');
const actual = getVersionFromFileContent(
'java openjdk-17.0.7',
'temurin',
'.tool-versions'
);
expect(actual?.version).toBe('17.0.7');
expect(actual?.distribution).toBeUndefined();
expect(warnSpy).toHaveBeenCalledWith(
expect.stringContaining('Unknown asdf distribution identifier')
);
});
});
});

describe('isGhes', () => {
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ inputs:
architecture:
description: "The architecture of the package (defaults to the action runner's architecture)"
required: false
jdkFile:
jdk-file:
description: 'Path to where the compressed JDK is located'
required: false
jdkFile:
description: 'Deprecated alias for `jdk-file`. Path to where the compressed JDK is located. Use `jdk-file` instead; this alias may be removed in a future release.'
required: false
deprecationMessage: 'The `jdkFile` input is deprecated. Use `jdk-file` instead.'
check-latest:
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec'
required: false
Expand Down
52 changes: 50 additions & 2 deletions dist/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95834,7 +95834,8 @@ const INPUT_JAVA_VERSION_FILE = 'java-version-file';
const INPUT_ARCHITECTURE = 'architecture';
const INPUT_JAVA_PACKAGE = 'java-package';
const INPUT_DISTRIBUTION = 'distribution';
const INPUT_JDK_FILE = 'jdkFile';
const INPUT_JDK_FILE = 'jdk-file';
const INPUT_JDK_FILE_DEPRECATED = 'jdkFile';
const INPUT_CHECK_LATEST = 'check-latest';
const INPUT_SET_DEFAULT = 'set-default';
const INPUT_VERIFY_SIGNATURE = 'verify-signature';
Expand Down Expand Up @@ -95965,8 +95966,10 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
}
const versionFileName = getFileName(versionFile);
if (versionFileName == '.tool-versions') {
// Capture an optional asdf-java vendor prefix (e.g. `temurin-`, `corretto-`)
// in the `distribution` group so it can be mapped to a setup-java distribution.
javaVersionRegExp =
/^java\s+(?:\S*-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
/^java\s+(?:(?<distribution>\S*)-)?(?<version>\d+(?:\.\d+)*([+_.-](?:openj9[-._]?\d[\w.-]*|java\d+|jre[-_\w]*|OpenJDK\d+[\w_.-]*|[a-z0-9]+))*)/im;
}
else if (versionFileName == '.sdkmanrc') {
// Match both version and optional distribution identifier
Expand All @@ -95986,6 +95989,14 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
extractedDistribution = mapSdkmanDistribution(sdkmanDist);
core.debug(`Parsed distribution '${extractedDistribution}' from SDKMAN identifier '${sdkmanDist}'`);
}
// Extract distribution from asdf .tool-versions file
if (versionFileName == '.tool-versions' && match?.groups?.distribution) {
const asdfDist = match.groups.distribution;
extractedDistribution = mapAsdfDistribution(asdfDist);
if (extractedDistribution) {
core.debug(`Parsed distribution '${extractedDistribution}' from asdf identifier '${asdfDist}'`);
}
}
core.debug(`Parsed version '${capturedVersion}' from file '${versionFileName}'`);
if (!capturedVersion) {
return null;
Expand Down Expand Up @@ -96034,6 +96045,43 @@ function mapSdkmanDistribution(sdkmanDist) {
}
return mapped;
}
// Map asdf-java (.tool-versions) vendor identifiers to setup-java distribution names.
// asdf-java encodes the vendor as a prefix on the version string, e.g.
// `java temurin-17.0.3+7` or `java semeru-openj9-11.0.25+9`. Packaging variants
// (`-jre`, `-musl`, `-openj9`, `-crac`, `-javafx`, ...) are collapsed onto the
// base vendor since setup-java does not distinguish them here.
function mapAsdfDistribution(asdfDist) {
const normalized = asdfDist.toLowerCase();
// Multi-segment vendors that map to a distinct setup-java distribution.
if (normalized.startsWith('graalvm-community')) {
return 'graalvm-community';
}
if (normalized.startsWith('oracle-graalvm')) {
return 'graalvm';
}
const baseVendor = normalized.split('-')[0];
const distributionMap = {
temurin: 'temurin',
adoptopenjdk: 'temurin',
zulu: 'zulu',
corretto: 'corretto',
liberica: 'liberica',
microsoft: 'microsoft',
semeru: 'semeru',
ibm: 'semeru',
dragonwell: 'dragonwell',
graalvm: 'graalvm',
oracle: 'oracle',
sapmachine: 'sapmachine',
kona: 'kona',
jetbrains: 'jetbrains'
};
const mapped = distributionMap[baseVendor];
if (!mapped) {
core.warning(`Unknown asdf distribution identifier '${asdfDist}'. Please specify the distribution explicitly.`);
}
return mapped;
}
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
function avoidOldNotation(content) {
return content.startsWith('1.') ? content.substring(2) : content;
Expand Down
Loading
Loading