diff --git a/__tests__/distributors/corretto-installer.test.ts b/__tests__/distributors/corretto-installer.test.ts
index bc24a532b..416c21607 100644
--- a/__tests__/distributors/corretto-installer.test.ts
+++ b/__tests__/distributors/corretto-installer.test.ts
@@ -244,19 +244,282 @@ describe('getAvailableVersions', () => {
).rejects.toThrow('Early access versions are not supported');
});
- it('with non major version expect to throw not supported error', async () => {
- const version = '18.0.1';
+ it.each(['18.0.1', '17.0.13.11', '17.0.13.11.1.1'])(
+ 'rejects partial or malformed release %s',
+ async version => {
+ const distribution = new CorrettoDistribution({
+ version,
+ architecture: 'x64',
+ packageType: 'jdk',
+ checkLatest: false
+ });
+ mockPlatform(distribution, 'linux');
+
+ await expect(
+ distribution['findPackageForDownload'](version)
+ ).rejects.toThrow(
+ 'Specify a major version or a full Corretto release, such as 25.0.5.0.10'
+ );
+ }
+ );
+
+ it.each([
+ [
+ '25.0.5.0.10',
+ 'linux',
+ 'x64',
+ 'jdk',
+ '25.0.5+0.10',
+ 'https://corretto.aws/downloads/resources/25.0.5.0.10/amazon-corretto-25.0.5.0.10-linux-x64.tar.gz'
+ ],
+ [
+ '25.0.5+0.10',
+ 'macos',
+ 'arm64',
+ 'jdk',
+ '25.0.5+0.10',
+ 'https://corretto.aws/downloads/resources/25.0.5.0.10/amazon-corretto-25.0.5.0.10-macosx-aarch64.tar.gz'
+ ],
+ [
+ '17.0.2.8.1',
+ 'windows',
+ 'x64',
+ 'jdk',
+ '17.0.2+8.1',
+ 'https://corretto.aws/downloads/resources/17.0.2.8.1/amazon-corretto-17.0.2.8.1-windows-x64-jdk.zip'
+ ],
+ [
+ '25.0.5.0.10',
+ 'alpine',
+ 'aarch64',
+ 'jdk',
+ '25.0.5+0.10',
+ 'https://corretto.aws/downloads/resources/25.0.5.0.10/amazon-corretto-25.0.5.0.10-alpine-linux-aarch64.tar.gz'
+ ],
+ [
+ '11.0.14.10.1',
+ 'linux',
+ 'armv7',
+ 'jdk',
+ '11.0.14+10.1',
+ 'https://corretto.aws/downloads/resources/11.0.14.10.1/amazon-corretto-11.0.14.10.1-linux-armv7.tar.gz'
+ ],
+ [
+ '8.472.8+1',
+ 'linux',
+ 'x64',
+ 'jdk',
+ '8.472.8+1',
+ 'https://corretto.aws/downloads/resources/8.472.08.1/amazon-corretto-8.472.08.1-linux-x64.tar.gz'
+ ],
+ [
+ '8.472.08.1',
+ 'linux',
+ 'x64',
+ 'jdk',
+ '8.472.8+1',
+ 'https://corretto.aws/downloads/resources/8.472.08.1/amazon-corretto-8.472.08.1-linux-x64.tar.gz'
+ ],
+ [
+ '8.472.08.1',
+ 'windows',
+ 'x86',
+ 'jre',
+ '8.472.8+1',
+ 'https://corretto.aws/downloads/resources/8.472.08.1/amazon-corretto-8.472.08.1-windows-x86-jre.zip'
+ ]
+ ])(
+ 'resolves exact release %s on %s/%s (%s)',
+ async (
+ requestedVersion,
+ platform,
+ architecture,
+ packageType,
+ expectedVersion,
+ url
+ ) => {
+ const checksum = 'a'.repeat(64);
+ spyHttpClient.mockResolvedValue({
+ statusCode: 200,
+ headers: {},
+ result: {
+ body: `|JDK|[archive](${url})|\`md5\` /
\`${checksum}\`|`
+ }
+ });
+ const distribution = new CorrettoDistribution({
+ version: requestedVersion,
+ architecture,
+ packageType,
+ checkLatest: false
+ });
+ mockPlatform(distribution, platform);
+
+ const release = await distribution['findPackageForDownload'](
+ distribution['version']
+ );
+ const rawVersion = new URL(url).pathname.split('/')[3];
+ const source = `https://api.github.com/repos/corretto/corretto-${rawVersion.split('.')[0]}/releases/tags/${rawVersion}`;
+ expect(release).toEqual({
+ version: expectedVersion,
+ url,
+ checksum: {algorithm: 'sha256', value: checksum, source}
+ });
+ expect(spyHttpClient).toHaveBeenCalledTimes(1);
+ expect(spyHttpClient).toHaveBeenCalledWith(
+ source,
+ expect.objectContaining({accept: 'application/vnd.github+json'})
+ );
+ }
+ );
+
+ it('rejects exact releases without an archive for the requested platform', async () => {
+ spyHttpClient.mockResolvedValueOnce({
+ statusCode: 200,
+ headers: {},
+ result: {
+ body:
+ '|[other archive](https://example.com/archive)|`' +
+ 'a'.repeat(64) +
+ '`|'
+ }
+ });
const distribution = new CorrettoDistribution({
- version,
+ version: '25.0.5.0.10',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
mockPlatform(distribution, 'linux');
+ await expect(
+ distribution['findPackageForDownload'](distribution['version'])
+ ).rejects.toThrow(
+ 'No linux/x64 jdk archive is listed for Corretto 25.0.5.0.10'
+ );
+ });
+ it('rejects historical archives with only an MD5 checksum', async () => {
+ spyHttpClient.mockResolvedValueOnce({
+ statusCode: 200,
+ headers: {},
+ result: {
+ body:
+ '|[archive](https://corretto.aws/downloads/resources/17.0.1.12.1/amazon-corretto-17.0.1.12.1-linux-x64.tar.gz)|`' +
+ 'a'.repeat(32) +
+ '`|'
+ }
+ });
+ const distribution = new CorrettoDistribution({
+ version: '17.0.1.12.1',
+ architecture: 'x64',
+ packageType: 'jdk',
+ checkLatest: false
+ });
+ mockPlatform(distribution, 'linux');
await expect(
- distribution['findPackageForDownload'](version)
- ).rejects.toThrow('Only major versions are supported');
+ distribution['findPackageForDownload'](distribution['version'])
+ ).rejects.toThrow(
+ 'No SHA-256 checksum is published for Corretto 17.0.1.12.1 (linux, x64, jdk)'
+ );
+ });
+
+ it('does not substitute a JDK for an exact Linux JRE request', async () => {
+ const distribution = new CorrettoDistribution({
+ version: '25.0.5.0.10',
+ architecture: 'x64',
+ packageType: 'jre',
+ checkLatest: false
+ });
+ mockPlatform(distribution, 'linux');
+ await expect(
+ distribution['findPackageForDownload'](distribution['version'])
+ ).rejects.toThrow('Corretto JRE archives are only available for Windows');
+ expect(spyHttpClient).not.toHaveBeenCalled();
+ });
+
+ it('resolves catalog-only releases without a GitHub release', async () => {
+ spyHttpClient.mockResolvedValueOnce({
+ statusCode: 404,
+ headers: {},
+ result: null
+ });
+ const distribution = new CorrettoDistribution({
+ version: '15.0.2.7.1',
+ architecture: 'x64',
+ packageType: 'jdk',
+ checkLatest: false
+ });
+ mockPlatform(distribution, 'linux');
+ expect(
+ await distribution['findPackageForDownload'](distribution['version'])
+ ).toEqual({
+ version: '15.0.2+7.1',
+ url: 'https://corretto.aws/downloads/resources/15.0.2.7.1/amazon-corretto-15.0.2.7.1-linux-x64.tar.gz',
+ checksum: {
+ algorithm: 'sha256',
+ value: manifestData.linux.x64.jdk['15']['tar.gz'].checksum_sha256,
+ source:
+ 'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json'
+ }
+ });
+ });
+
+ it('falls back to the catalog when the GitHub lookup fails', async () => {
+ spyHttpClient.mockRejectedValueOnce(new Error('GitHub rate limit'));
+ const distribution = new CorrettoDistribution({
+ version: '15.0.2.7.1',
+ architecture: 'x64',
+ packageType: 'jdk',
+ checkLatest: false
+ });
+ mockPlatform(distribution, 'linux');
+
+ expect(
+ await distribution['findPackageForDownload'](distribution['version'])
+ ).toEqual({
+ version: '15.0.2+7.1',
+ url: 'https://corretto.aws/downloads/resources/15.0.2.7.1/amazon-corretto-15.0.2.7.1-linux-x64.tar.gz',
+ checksum: {
+ algorithm: 'sha256',
+ value: manifestData.linux.x64.jdk['15']['tar.gz'].checksum_sha256,
+ source:
+ 'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json'
+ }
+ });
+ expect(spyHttpClient).toHaveBeenCalledTimes(2);
+ });
+
+ it('reports missing release metadata without substituting the latest release', async () => {
+ spyHttpClient.mockResolvedValueOnce({
+ statusCode: 404,
+ headers: {},
+ result: null
+ });
+ const distribution = new CorrettoDistribution({
+ version: '17.0.0.0.999',
+ architecture: 'x64',
+ packageType: 'jdk',
+ checkLatest: false
+ });
+ mockPlatform(distribution, 'linux');
+ await expect(
+ distribution['findPackageForDownload'](distribution['version'])
+ ).rejects.toThrow(
+ "Corretto release 17.0.0.0.999 was not found in Amazon's GitHub releases or current download catalog"
+ );
+ });
+
+ it('does not normalize zero-padded major-only inputs', () => {
+ expect(
+ () =>
+ new CorrettoDistribution({
+ version: '08',
+ architecture: 'x64',
+ packageType: 'jdk',
+ checkLatest: false
+ })
+ ).toThrow(
+ "The string '08' is not valid SemVer notation for a Java version"
+ );
});
it('with unfound version throw could not find error', async () => {
diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts
index 87b10b74f..be3f10bc1 100644
--- a/__tests__/util.test.ts
+++ b/__tests__/util.test.ts
@@ -278,6 +278,28 @@ describe('validatePaginationUrl', () => {
});
describe('getVersionFromFileContent', () => {
+ it.each(['25.0.5.0.10', '8.472.08.1', '25.0.5+0.10'])(
+ 'preserves full Corretto release %s in .java-version',
+ version => {
+ expect(
+ getVersionFromFileContent(version, 'corretto', '.java-version')
+ ).toEqual({version, distribution: undefined});
+ }
+ );
+
+ it.each([
+ ['17.0.3.1', '.java-version', '17'],
+ ['1.8.0.472.1', '.java-version', '8'],
+ ['8.0.472.08.1', '.java-version', '8'],
+ ['8.0.282+8', '.java-version', '8'],
+ ['java corretto-17.0.13.11.1-jre', '.tool-versions', '17'],
+ ['java corretto-17.0.13.11.1+1', '.tool-versions', '17']
+ ])('keeps the existing major selection for %s', (content, file, version) => {
+ expect(getVersionFromFileContent(content, 'corretto', file)?.version).toBe(
+ version
+ );
+ });
+
describe('.sdkmanrc', () => {
it.each([
['java=26-tem', '26', 'temurin'],
@@ -290,6 +312,8 @@ describe('getVersionFromFileContent', () => {
['java=21.0.5-zulu', '21.0.5', 'zulu'],
['java=17.0.13-albba', '17.0.13', 'dragonwell'],
['java=17.0.13-amzn', '17', 'corretto'],
+ ['java=25.0.5.0.10-amzn', '25.0.5.0.10', 'corretto'],
+ ['java=8.472.08.1-amzn', '8.472.08.1', 'corretto'],
['java=21.0.5-graal', '21.0.5', 'graalvm'],
['java=17.0.9-graalce', '17.0.9', 'graalvm'],
['java=11.0.25-librca', '11.0.25', 'liberica'],
@@ -368,7 +392,8 @@ describe('getVersionFromFileContent', () => {
['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 corretto-17.0.13.11.1', '17.0.13.11.1', 'corretto'],
+ ['java corretto-8.472.08.1', '8.472.08.1', 'corretto'],
['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'],
diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js
index d03227ad0..06a775f5a 100644
--- a/dist/cleanup/index.js
+++ b/dist/cleanup/index.js
@@ -31220,7 +31220,7 @@ const DISTRIBUTIONS_ONLY_MAJOR_VERSION = (/* unused pure expression or super */
/* harmony export */ Vt: () => (/* binding */ getBooleanInput),
/* harmony export */ lN: () => (/* binding */ isJdkCacheEnabled)
/* harmony export */ });
-/* unused harmony exports getVersionFromToolcachePath, extractJdkFile, cacheJdkDir, getJavaVersionFromReleaseFile, getDownloadArchiveExtension, isVersionSatisfies, getToolcachePath, isGhes, getVersionFromFileContent, convertVersionToSemver, normalizeJavaVersionToSemver, getArtifactFingerprint, getGitHubToken, getGitHubHttpHeaders, MAX_PAGINATION_PAGES, getNextPageUrlFromLinkHeader, validatePaginationUrl, renameWinArchive, getLatestMajorVersion */
+/* unused harmony exports getVersionFromToolcachePath, extractJdkFile, cacheJdkDir, getJavaVersionFromReleaseFile, getDownloadArchiveExtension, isVersionSatisfies, getToolcachePath, isGhes, getVersionFromFileContent, isExactCorrettoVersion, convertVersionToSemver, normalizeJavaVersionToSemver, getArtifactFingerprint, getGitHubToken, getGitHubHttpHeaders, MAX_PAGINATION_PAGES, getNextPageUrlFromLinkHeader, validatePaginationUrl, renameWinArchive, getLatestMajorVersion */
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(857);
/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(os__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(6928);
@@ -31527,6 +31527,15 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
}
const tentativeVersion = avoidOldNotation(capturedVersion);
const rawVersion = tentativeVersion.split('-')[0];
+ // Preserve Corretto's full vendor release before generic coercion drops its extra numeric fields.
+ if ((extractedDistribution || distributionName) === 'corretto' &&
+ capturedVersion === tentativeVersion &&
+ isExactCorrettoVersion(tentativeVersion)) {
+ return {
+ version: tentativeVersion,
+ distribution: extractedDistribution
+ };
+ }
let version = semver.validRange(rawVersion)
? tentativeVersion
: semver.coerce(tentativeVersion);
@@ -31610,6 +31619,10 @@ function mapAsdfDistribution(asdfDist) {
function avoidOldNotation(content) {
return content.startsWith('1.') ? content.substring(2) : content;
}
+function isExactCorrettoVersion(version) {
+ // Java 8 releases have a nonzero update field; later releases use five numeric fields.
+ return /^(?:8\.(?!0+(?:\.|$))\d+(?:\.\d+){2}|(?!8\.)\d+(?:\.\d+){4})$/.test(version.replace('+', '.'));
+}
function convertVersionToSemver(version) {
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
const versionArray = Array.isArray(version) ? version : version.split('.');
diff --git a/dist/setup/126.index.js b/dist/setup/126.index.js
index 410f70ed8..cfbf14c76 100644
--- a/dist/setup/126.index.js
+++ b/dist/setup/126.index.js
@@ -13,9 +13,11 @@ export const modules = {
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6928);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
-/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4527);
-/* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6242);
-/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7444);
+/* harmony import */ var _actions_http_client__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4942);
+/* harmony import */ var _util_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4527);
+/* harmony import */ var _base_installer_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6242);
+/* harmony import */ var _platform_types_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7444);
+
@@ -23,29 +25,42 @@ export const modules = {
const CORRETTO_VERSIONS_URL = 'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json';
-class CorrettoDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4__/* .JavaBase */ .O {
+class CorrettoDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_5__/* .JavaBase */ .O {
+ requestedVersion;
constructor(installerOptions) {
- super('Corretto', installerOptions);
+ super('Corretto', {
+ ...installerOptions,
+ // Java 8 releases use zero-padded fields, e.g. 8.472.08.1.
+ version: (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .isExactCorrettoVersion */ .kI)(installerOptions.version)
+ ? installerOptions.version.replace(/(^|\.)0+(?=\d)/g, '$1')
+ : installerOptions.version
+ });
+ this.requestedVersion = installerOptions.version
+ .replace('+', '.')
+ .replace(/^8\.(\d+)\.(\d)\./, '8.$1.0$2.');
}
async downloadTool(javaRelease) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
let javaArchivePath = await this.downloadAndVerify(javaRelease);
_actions_core__WEBPACK_IMPORTED_MODULE_0__/* .info */ .pq(`Extracting Java archive...`);
- const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_3__/* .getDownloadArchiveExtension */ .ag)();
+ const extension = (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .getDownloadArchiveExtension */ .ag)();
if (process.platform === 'win32') {
- javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_3__/* .renameWinArchive */ .n2)(javaArchivePath);
+ javaArchivePath = (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .renameWinArchive */ .n2)(javaArchivePath);
}
- const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_3__/* .extractJdkFile */ .PE)(javaArchivePath, extension);
+ const extractedJavaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .extractJdkFile */ .PE)(javaArchivePath, extension);
const archiveName = fs__WEBPACK_IMPORTED_MODULE_1___default().readdirSync(extractedJavaPath)[0];
const archivePath = path__WEBPACK_IMPORTED_MODULE_2___default().join(extractedJavaPath, archiveName);
const version = this.getToolcacheVersionName(javaRelease.version);
- const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_3__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, version, this.architecture);
+ const javaPath = await (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .cacheJdkDir */ .Vj)(archivePath, this.toolcacheFolderName, version, this.architecture);
return { version: javaRelease.version, path: javaPath };
}
async findPackageForDownload(version) {
if (!this.stable) {
throw new Error('Early access versions are not supported');
}
+ if ((0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .isExactCorrettoVersion */ .kI)(this.requestedVersion)) {
+ return this.findExactRelease();
+ }
const availableVersions = await this.getAvailableVersions();
// The `latest` alias is normalized to the SemVer wildcard, but Corretto
// matches on an exact major version, so resolve it to the newest available
@@ -60,13 +75,13 @@ class CorrettoDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4
version = Math.max(...majors).toString();
}
if (version.includes('.')) {
- throw new Error('Only major versions are supported');
+ throw new Error('Specify a major version or a full Corretto release, such as 25.0.5.0.10');
}
const matchingVersions = availableVersions
.filter(item => item.version == version)
.map(item => {
return {
- version: (0,_util_js__WEBPACK_IMPORTED_MODULE_3__/* .convertVersionToSemver */ .ZY)(item.correttoVersion),
+ version: (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .convertVersionToSemver */ .ZY)(item.correttoVersion),
url: item.downloadLink,
checksum: {
algorithm: 'sha256',
@@ -82,6 +97,76 @@ class CorrettoDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4
}
return resolvedVersion;
}
+ async findExactRelease() {
+ const version = this.requestedVersion;
+ const major = version.split('.')[0];
+ const platform = this.getPlatformOption();
+ const arch = this.architecture;
+ if (platform !== 'windows' && this.packageType !== 'jdk') {
+ throw new Error('Corretto JRE archives are only available for Windows');
+ }
+ const os = platform === 'macos'
+ ? 'macosx'
+ : platform === 'alpine'
+ ? 'alpine-linux'
+ : platform;
+ const suffix = platform === 'windows' ? `-${this.packageType}.zip` : '.tar.gz';
+ const url = `https://corretto.aws/downloads/resources/${version}/amazon-corretto-${version}-${os}-${arch}${suffix}`;
+ // Versioned archives have no checksum sidecar; Amazon publishes their SHA-256s in the release notes.
+ const source = `https://api.github.com/repos/corretto/corretto-${major}/releases/tags/${version}`;
+ const findCatalogRelease = async () => {
+ const archive = (await this.getAvailableVersions()).find(item => item.downloadLink === url);
+ if (!archive) {
+ return undefined;
+ }
+ return {
+ version: this.version,
+ url,
+ checksum: {
+ algorithm: 'sha256',
+ value: archive.checksum_sha256,
+ source: CORRETTO_VERSIONS_URL
+ }
+ };
+ };
+ let response;
+ try {
+ response = await this.http.getJson(source, {
+ ...(0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .getGitHubHttpHeaders */ .U_)(),
+ accept: 'application/vnd.github+json'
+ });
+ }
+ catch (error) {
+ const catalogRelease = await findCatalogRelease();
+ if (catalogRelease) {
+ return catalogRelease;
+ }
+ throw error;
+ }
+ const row = response.result?.body
+ ?.split(/\r?\n/)
+ .find(line => line.includes(`](${url})`));
+ const checksum = row?.match(/`([a-fA-F0-9]{64})`/)?.[1];
+ if (checksum) {
+ return {
+ version: this.version,
+ url,
+ checksum: { algorithm: 'sha256', value: checksum, source }
+ };
+ }
+ // The current catalog also covers releases missing from GitHub, such as Corretto 15 and 16.
+ const catalogRelease = await findCatalogRelease();
+ if (catalogRelease) {
+ return catalogRelease;
+ }
+ if (response.statusCode === _actions_http_client__WEBPACK_IMPORTED_MODULE_3__/* .HttpCodes */ .Hv.NotFound) {
+ throw new Error(`Corretto release ${version} was not found in Amazon's GitHub releases or current download catalog`);
+ }
+ if (!row) {
+ throw new Error(`No ${platform}/${arch} ${this.packageType} archive is listed for Corretto ${version}`);
+ }
+ throw new Error(`No SHA-256 checksum is published for Corretto ${version} (${platform}, ${arch}, ${this.packageType})`);
+ }
async getAvailableVersions() {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
@@ -112,7 +197,7 @@ class CorrettoDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4
for (const version in eligibleVersions) {
const availableVersion = eligibleVersions[version];
for (const fileType in availableVersion) {
- const skipNonExtractableBinaries = fileType != (0,_util_js__WEBPACK_IMPORTED_MODULE_3__/* .getDownloadArchiveExtension */ .ag)();
+ const skipNonExtractableBinaries = fileType != (0,_util_js__WEBPACK_IMPORTED_MODULE_4__/* .getDownloadArchiveExtension */ .ag)();
if (skipNonExtractableBinaries) {
continue;
}
@@ -139,7 +224,7 @@ class CorrettoDistribution extends _base_installer_js__WEBPACK_IMPORTED_MODULE_4
case 'win32':
return 'windows';
case 'linux':
- return (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_5__/* .isAlpineLinux */ .G6)() ? 'alpine' : 'linux';
+ return (0,_platform_types_js__WEBPACK_IMPORTED_MODULE_6__/* .isAlpineLinux */ .G6)() ? 'alpine' : 'linux';
default:
return process.platform;
}
diff --git a/dist/setup/index.js b/dist/setup/index.js
index 37ccb2993..301bfe39c 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -31674,6 +31674,7 @@ function validateToolchainIds(versions, versionFile, toolchainIds) {
/* harmony export */ ZY: () => (/* binding */ convertVersionToSemver),
/* harmony export */ aT: () => (/* binding */ isGhes),
/* harmony export */ ag: () => (/* binding */ getDownloadArchiveExtension),
+/* harmony export */ kI: () => (/* binding */ isExactCorrettoVersion),
/* harmony export */ lK: () => (/* binding */ getGitHubToken),
/* harmony export */ lN: () => (/* binding */ isJdkCacheEnabled),
/* harmony export */ n2: () => (/* binding */ renameWinArchive),
@@ -31990,6 +31991,15 @@ function getVersionFromFileContent(content, distributionName, versionFile) {
}
const tentativeVersion = avoidOldNotation(capturedVersion);
const rawVersion = tentativeVersion.split('-')[0];
+ // Preserve Corretto's full vendor release before generic coercion drops its extra numeric fields.
+ if ((extractedDistribution || distributionName) === 'corretto' &&
+ capturedVersion === tentativeVersion &&
+ isExactCorrettoVersion(tentativeVersion)) {
+ return {
+ version: tentativeVersion,
+ distribution: extractedDistribution
+ };
+ }
let version = semver__WEBPACK_IMPORTED_MODULE_3__.validRange(rawVersion)
? tentativeVersion
: semver__WEBPACK_IMPORTED_MODULE_3__.coerce(tentativeVersion);
@@ -32073,6 +32083,10 @@ function mapAsdfDistribution(asdfDist) {
function avoidOldNotation(content) {
return content.startsWith('1.') ? content.substring(2) : content;
}
+function isExactCorrettoVersion(version) {
+ // Java 8 releases have a nonzero update field; later releases use five numeric fields.
+ return /^(?:8\.(?!0+(?:\.|$))\d+(?:\.\d+){2}|(?!8\.)\d+(?:\.\d+){4})$/.test(version.replace('+', '.'));
+}
function convertVersionToSemver(version) {
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
const versionArray = Array.isArray(version) ? version : version.split('.');
diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md
index 8e1a61507..cdc528d16 100644
--- a/docs/advanced-usage.md
+++ b/docs/advanced-usage.md
@@ -157,7 +157,16 @@ steps:
```
### Amazon Corretto
-**NOTE:** Amazon Corretto only supports the major version specification.
+Amazon Corretto supports major versions (for example, `25`) and full release numbers
+(for example, `25.0.5.0.10`). Full release numbers select the versioned archive directly,
+including older releases no longer listed in the latest-version feed. SHA-256 checksums
+for exact releases come from Amazon's current download catalog or GitHub release notes.
+Historical releases without a published SHA-256 cannot be downloaded.
+
+Full Corretto release numbers supplied through `java-version-file` now select that exact
+release; previously they selected the latest matching major. Update MD5-only file pins
+to a release with a published SHA-256. Partial version-file values keep their existing
+major-version behavior.
```yaml
steps:
@@ -165,7 +174,7 @@ steps:
- uses: actions/setup-java@v6
with:
distribution: 'corretto'
- java-version: '25'
+ java-version: '25.0.5.0.10'
- run: java --version
```
@@ -336,7 +345,7 @@ The package types have these meanings:
| `liberica-nik` | `jdk`, `jdk+fx` | `java-version` selects the embedded JDK version, not the NIK/GraalVM release number. BellSoft currently publishes matching standard and JavaFX "full" bundles for JDK 11 and later, with gaps between feature releases. Any other `java-package` value is rejected. |
| `microsoft` | `jdk` | Stable builds only. The bundled manifest contains Java 11, 16, 17, 21, and 25 releases; platform availability varies by release. |
| `semeru` | `jdk`, `jre` | Stable OpenJ9 builds only. IBM publishes both image types for the supported release lines (currently 8, 11, 17, 21, and 25), subject to platform availability. |
-| `corretto` | `jdk`, `jre` | Accepts major versions only. JDK availability follows Amazon's platform catalog. For the operating systems directly selected by `setup-java`, JRE downloads are limited to Java 8 on Windows; Linux and macOS use `jdk`. |
+| `corretto` | `jdk`, `jre` | Accepts major versions and full Corretto release numbers. JDK availability follows Amazon's platform catalog. For the operating systems directly selected by `setup-java`, JRE downloads are limited to Java 8 on Windows; Linux and macOS use `jdk`. |
| `oracle` | `jdk` | Stable Oracle JDK 17 and later only. |
| `oracle-openjdk` | `jdk` | Installs the GA or early-access JDK builds currently listed or archived on `jdk.java.net`; use a `-ea` version such as `27-ea` for early access. |
| `redhat` | `jdk`, `jre` | Stable builds only. Version availability follows the Foojay Disco catalog for Red Hat Build of OpenJDK and can lag Red Hat's downloads page. |
diff --git a/src/distributions/corretto/installer.ts b/src/distributions/corretto/installer.ts
index 787286f2b..ebb6b9e6c 100644
--- a/src/distributions/corretto/installer.ts
+++ b/src/distributions/corretto/installer.ts
@@ -1,10 +1,13 @@
import * as core from '@actions/core';
import fs from 'fs';
import path from 'path';
+import {HttpCodes} from '@actions/http-client';
import {
cacheJdkDir,
extractJdkFile,
getDownloadArchiveExtension,
+ getGitHubHttpHeaders,
+ isExactCorrettoVersion,
convertVersionToSemver,
renameWinArchive
} from '../../util.js';
@@ -24,8 +27,19 @@ const CORRETTO_VERSIONS_URL =
'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json';
export class CorrettoDistribution extends JavaBase {
+ private readonly requestedVersion: string;
+
constructor(installerOptions: JavaInstallerOptions) {
- super('Corretto', installerOptions);
+ super('Corretto', {
+ ...installerOptions,
+ // Java 8 releases use zero-padded fields, e.g. 8.472.08.1.
+ version: isExactCorrettoVersion(installerOptions.version)
+ ? installerOptions.version.replace(/(^|\.)0+(?=\d)/g, '$1')
+ : installerOptions.version
+ });
+ this.requestedVersion = installerOptions.version
+ .replace('+', '.')
+ .replace(/^8\.(\d+)\.(\d)\./, '8.$1.0$2.');
}
protected async downloadTool(
@@ -63,6 +77,9 @@ export class CorrettoDistribution extends JavaBase {
if (!this.stable) {
throw new Error('Early access versions are not supported');
}
+ if (isExactCorrettoVersion(this.requestedVersion)) {
+ return this.findExactRelease();
+ }
const availableVersions = await this.getAvailableVersions();
// The `latest` alias is normalized to the SemVer wildcard, but Corretto
@@ -83,7 +100,9 @@ export class CorrettoDistribution extends JavaBase {
}
if (version.includes('.')) {
- throw new Error('Only major versions are supported');
+ throw new Error(
+ 'Specify a major version or a full Corretto release, such as 25.0.5.0.10'
+ );
}
const matchingVersions = availableVersions
.filter(item => item.version == version)
@@ -110,6 +129,91 @@ export class CorrettoDistribution extends JavaBase {
return resolvedVersion;
}
+ private async findExactRelease(): Promise {
+ const version = this.requestedVersion;
+ const major = version.split('.')[0];
+ const platform = this.getPlatformOption();
+ const arch = this.architecture;
+ if (platform !== 'windows' && this.packageType !== 'jdk') {
+ throw new Error('Corretto JRE archives are only available for Windows');
+ }
+ const os =
+ platform === 'macos'
+ ? 'macosx'
+ : platform === 'alpine'
+ ? 'alpine-linux'
+ : platform;
+ const suffix =
+ platform === 'windows' ? `-${this.packageType}.zip` : '.tar.gz';
+ const url = `https://corretto.aws/downloads/resources/${version}/amazon-corretto-${version}-${os}-${arch}${suffix}`;
+
+ // Versioned archives have no checksum sidecar; Amazon publishes their SHA-256s in the release notes.
+ const source = `https://api.github.com/repos/corretto/corretto-${major}/releases/tags/${version}`;
+ const findCatalogRelease = async (): Promise<
+ JavaDownloadRelease | undefined
+ > => {
+ const archive = (await this.getAvailableVersions()).find(
+ item => item.downloadLink === url
+ );
+ if (!archive) {
+ return undefined;
+ }
+ return {
+ version: this.version,
+ url,
+ checksum: {
+ algorithm: 'sha256',
+ value: archive.checksum_sha256,
+ source: CORRETTO_VERSIONS_URL
+ }
+ };
+ };
+
+ let response;
+ try {
+ response = await this.http.getJson<{body: string | null}>(source, {
+ ...getGitHubHttpHeaders(),
+ accept: 'application/vnd.github+json'
+ });
+ } catch (error) {
+ const catalogRelease = await findCatalogRelease();
+ if (catalogRelease) {
+ return catalogRelease;
+ }
+ throw error;
+ }
+ const row = response.result?.body
+ ?.split(/\r?\n/)
+ .find(line => line.includes(`](${url})`));
+ const checksum = row?.match(/`([a-fA-F0-9]{64})`/)?.[1];
+ if (checksum) {
+ return {
+ version: this.version,
+ url,
+ checksum: {algorithm: 'sha256', value: checksum, source}
+ };
+ }
+
+ // The current catalog also covers releases missing from GitHub, such as Corretto 15 and 16.
+ const catalogRelease = await findCatalogRelease();
+ if (catalogRelease) {
+ return catalogRelease;
+ }
+ if (response.statusCode === HttpCodes.NotFound) {
+ throw new Error(
+ `Corretto release ${version} was not found in Amazon's GitHub releases or current download catalog`
+ );
+ }
+ if (!row) {
+ throw new Error(
+ `No ${platform}/${arch} ${this.packageType} archive is listed for Corretto ${version}`
+ );
+ }
+ throw new Error(
+ `No SHA-256 checksum is published for Corretto ${version} (${platform}, ${arch}, ${this.packageType})`
+ );
+ }
+
private async getAvailableVersions(): Promise {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
diff --git a/src/util.ts b/src/util.ts
index b71a73629..e745b36b6 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -397,6 +397,18 @@ export function getVersionFromFileContent(
const tentativeVersion = avoidOldNotation(capturedVersion);
const rawVersion = tentativeVersion.split('-')[0];
+ // Preserve Corretto's full vendor release before generic coercion drops its extra numeric fields.
+ if (
+ (extractedDistribution || distributionName) === 'corretto' &&
+ capturedVersion === tentativeVersion &&
+ isExactCorrettoVersion(tentativeVersion)
+ ) {
+ return {
+ version: tentativeVersion,
+ distribution: extractedDistribution
+ };
+ }
+
let version = semver.validRange(rawVersion)
? tentativeVersion
: semver.coerce(tentativeVersion);
@@ -500,6 +512,13 @@ function avoidOldNotation(content: string): string {
return content.startsWith('1.') ? content.substring(2) : content;
}
+export function isExactCorrettoVersion(version: string): boolean {
+ // Java 8 releases have a nonzero update field; later releases use five numeric fields.
+ return /^(?:8\.(?!0+(?:\.|$))\d+(?:\.\d+){2}|(?!8\.)\d+(?:\.\d+){4})$/.test(
+ version.replace('+', '.')
+ );
+}
+
export function convertVersionToSemver(version: number[] | string) {
// Some distributions may use semver-like notation (12.10.2.1, 12.10.2.1.1)
const versionArray = Array.isArray(version) ? version : version.split('.');