mirror of
https://github.com/actions/setup-java
synced 2024-11-09 23:22:40 +00:00
add support for dragonwell (#532)
* add support for dragonwell * fix: update logic of parsing json file, refactor code * build: rebuild action * chore: update error message * build: rebuild action * tests: fix unit tests, add e2e tests * chore: prettier, lint and rebuild solution * feat: add check for the package type, update unit tests * tests: update e2e tests * tests: remove excess entries from e2e tests * feat: update logic of getting json file * feat: add logic for backuping getting json * chore: update wordings * chore: fix typos, add additional logs * fix: fix review points * chore: rebuild solution * chore: update wordings * chore: refactor code --------- Co-authored-by: Ivan Zosimov <ivanzosimov@github.com> Co-authored-by: Ivan <98037481+IvanZosimov@users.noreply.github.com>
This commit is contained in:
parent
4075bfc1b5
commit
0ab4596768
12 changed files with 1918 additions and 20 deletions
22
.github/workflows/e2e-versions.yml
vendored
22
.github/workflows/e2e-versions.yml
vendored
|
@ -29,12 +29,15 @@ jobs:
|
||||||
'liberica',
|
'liberica',
|
||||||
'microsoft',
|
'microsoft',
|
||||||
'semeru',
|
'semeru',
|
||||||
'corretto'
|
'corretto',
|
||||||
|
'dragonwell'
|
||||||
] # internally 'adopt-hotspot' is the same as 'adopt'
|
] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||||
version: ['8', '11', '17']
|
version: ['8', '11', '17']
|
||||||
exclude:
|
exclude:
|
||||||
- distribution: microsoft
|
- distribution: microsoft
|
||||||
version: 8
|
version: 8
|
||||||
|
- distribution: dragonwell
|
||||||
|
os: macos-latest
|
||||||
include:
|
include:
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
|
@ -45,6 +48,7 @@ jobs:
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
version: 20
|
version: 20
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
@ -75,6 +79,12 @@ jobs:
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
version: '20.0.1'
|
version: '20.0.1'
|
||||||
|
- distribution: dragonwell
|
||||||
|
os: ubuntu-latest
|
||||||
|
version: '11.0'
|
||||||
|
- distribution: dragonwell
|
||||||
|
os: ubuntu-latest
|
||||||
|
version: '11.0.13+9'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
@ -96,7 +106,10 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution: ['temurin', 'zulu', 'liberica']
|
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||||
|
exclude:
|
||||||
|
- distribution: dragonwell
|
||||||
|
os: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
@ -119,7 +132,10 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution: ['temurin', 'zulu', 'liberica']
|
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||||
|
exclude:
|
||||||
|
- distribution: dragonwell
|
||||||
|
os: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
|
@ -105,6 +105,7 @@ Currently, the following distributions are supported:
|
||||||
| `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/)
|
| `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/)
|
||||||
| `semeru` | IBM Semeru Runtime Open Edition | [Link](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [Link](https://openjdk.java.net/legal/gplv2+ce.html) |
|
| `semeru` | IBM Semeru Runtime Open Edition | [Link](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [Link](https://openjdk.java.net/legal/gplv2+ce.html) |
|
||||||
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
|
| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense)
|
||||||
|
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
|
||||||
|
|
||||||
**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
|
**NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
|
||||||
|
|
||||||
|
@ -227,6 +228,7 @@ In the example above multiple JDKs are installed for the same job. The result af
|
||||||
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
||||||
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
||||||
- [Oracle](docs/advanced-usage.md#Oracle)
|
- [Oracle](docs/advanced-usage.md#Oracle)
|
||||||
|
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
|
||||||
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
|
- [Installing custom Java package type](docs/advanced-usage.md#Installing-custom-Java-package-type)
|
||||||
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
|
- [Installing custom Java architecture](docs/advanced-usage.md#Installing-custom-Java-architecture)
|
||||||
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
|
- [Installing custom Java distribution from local file](docs/advanced-usage.md#Installing-Java-from-local-file)
|
||||||
|
|
1138
__tests__/data/dragonwell.json
Normal file
1138
__tests__/data/dragonwell.json
Normal file
File diff suppressed because it is too large
Load diff
226
__tests__/distributors/dragonwell-installer.test.ts
Normal file
226
__tests__/distributors/dragonwell-installer.test.ts
Normal file
|
@ -0,0 +1,226 @@
|
||||||
|
import {HttpClient} from '@actions/http-client';
|
||||||
|
import {DragonwellDistribution} from '../../src/distributions/dragonwell/installer';
|
||||||
|
import * as utils from '../../src/util';
|
||||||
|
|
||||||
|
import manifestData from '../data/dragonwell.json';
|
||||||
|
|
||||||
|
describe('getAvailableVersions', () => {
|
||||||
|
let spyHttpClient: jest.SpyInstance;
|
||||||
|
let spyUtilGetDownloadArchiveExtension: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||||
|
spyHttpClient.mockReturnValue({
|
||||||
|
statusCode: 200,
|
||||||
|
headers: {},
|
||||||
|
result: manifestData
|
||||||
|
});
|
||||||
|
|
||||||
|
spyUtilGetDownloadArchiveExtension = jest.spyOn(
|
||||||
|
utils,
|
||||||
|
'getDownloadArchiveExtension'
|
||||||
|
);
|
||||||
|
spyUtilGetDownloadArchiveExtension.mockReturnValue('tar.gz');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
const mockPlatform = (
|
||||||
|
distribution: DragonwellDistribution,
|
||||||
|
platform: string
|
||||||
|
) => {
|
||||||
|
distribution['getPlatformOption'] = () => platform;
|
||||||
|
const mockedExtension = platform == 'windows' ? 'zip' : 'tar.gz';
|
||||||
|
spyUtilGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('getAvailableVersions', () => {
|
||||||
|
it.each([
|
||||||
|
['8', 'x86', 'linux', 0],
|
||||||
|
['8', 'aarch64', 'linux', 24],
|
||||||
|
['8.6.6', 'x64', 'linux', 27],
|
||||||
|
['8', 'x86', 'anolis', 0],
|
||||||
|
['8', 'x86', 'windows', 0],
|
||||||
|
['8', 'x86', 'mac', 0],
|
||||||
|
['11', 'x64', 'linux', 27],
|
||||||
|
['11', 'aarch64', 'linux', 24],
|
||||||
|
['17', 'riscv', 'linux', 0],
|
||||||
|
['16.0.1', 'x64', 'linux', 27]
|
||||||
|
])(
|
||||||
|
'should get right number of available versions from JSON',
|
||||||
|
async (
|
||||||
|
jdkVersion: string,
|
||||||
|
arch: string,
|
||||||
|
platform: string,
|
||||||
|
len: number
|
||||||
|
) => {
|
||||||
|
const distribution = new DragonwellDistribution({
|
||||||
|
version: jdkVersion,
|
||||||
|
architecture: arch,
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
mockPlatform(distribution, platform);
|
||||||
|
|
||||||
|
const availableVersions = await distribution['getAvailableVersions']();
|
||||||
|
expect(availableVersions).not.toBeNull();
|
||||||
|
expect(availableVersions.length).toBe(len);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('findPackageForDownload', () => {
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'8',
|
||||||
|
'linux',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'8',
|
||||||
|
'linux',
|
||||||
|
'aarch64',
|
||||||
|
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_aarch64_linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'8',
|
||||||
|
'windows',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_windows.zip'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'8.13.14',
|
||||||
|
'linux',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell8/releases/download/dragonwell-extended-8.13.14_jdk8u352-ga/Alibaba_Dragonwell_Extended_8.13.14_x64_linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'11',
|
||||||
|
'linux',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'11',
|
||||||
|
'linux',
|
||||||
|
'aarch64',
|
||||||
|
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_aarch64_linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'11',
|
||||||
|
'windows',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_windows.zip'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'11',
|
||||||
|
'alpine-linux',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_alpine-linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'11.0.17',
|
||||||
|
'linux',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell11/releases/download/dragonwell-extended-11.0.17.13_jdk-11.0.17-ga/Alibaba_Dragonwell_Extended_11.0.17.13.8_x64_linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17',
|
||||||
|
'linux',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17',
|
||||||
|
'linux',
|
||||||
|
'aarch64',
|
||||||
|
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_aarch64_linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17',
|
||||||
|
'windows',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_windows.zip'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17',
|
||||||
|
'alpine-linux',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.5.0.5%2B8_jdk-17.0.5-ga/Alibaba_Dragonwell_Standard_17.0.5.0.5.8_x64_alpine-linux.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17.0.4',
|
||||||
|
'linux',
|
||||||
|
'x64',
|
||||||
|
'https://github.com/alibaba/dragonwell17/releases/download/dragonwell-standard-17.0.4.0.4%2B8_jdk-17.0.4-ga/Alibaba_Dragonwell_Standard_17.0.4.0.4%2B8_x64_linux.tar.gz'
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'should return proper link according to the specified java-version, platform and arch',
|
||||||
|
async (
|
||||||
|
jdkVersion: string,
|
||||||
|
platform: string,
|
||||||
|
arch: string,
|
||||||
|
expectedLink: string
|
||||||
|
) => {
|
||||||
|
const distribution = new DragonwellDistribution({
|
||||||
|
version: jdkVersion,
|
||||||
|
architecture: arch,
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
mockPlatform(distribution, platform);
|
||||||
|
|
||||||
|
const availableVersion = await distribution['findPackageForDownload'](
|
||||||
|
jdkVersion
|
||||||
|
);
|
||||||
|
expect(availableVersion).not.toBeNull();
|
||||||
|
expect(availableVersion.url).toBe(expectedLink);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['8', 'alpine-linux', 'x64'],
|
||||||
|
['8', 'macos', 'aarch64'],
|
||||||
|
['11', 'macos', 'aarch64'],
|
||||||
|
['17', 'linux', 'riscv']
|
||||||
|
])(
|
||||||
|
'should throw when required version of JDK can not be found in the JSON',
|
||||||
|
async (jdkVersion: string, platform: string, arch: string) => {
|
||||||
|
const distribution = new DragonwellDistribution({
|
||||||
|
version: jdkVersion,
|
||||||
|
architecture: arch,
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
mockPlatform(distribution, platform);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
distribution['findPackageForDownload'](jdkVersion)
|
||||||
|
).rejects.toThrow(
|
||||||
|
`Couldn't find any satisfied version for the specified java-version: "${jdkVersion}" and architecture: "${arch}".`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('should throw when required package type is not jdk', async () => {
|
||||||
|
const jdkVersion = '17';
|
||||||
|
const arch = 'x64';
|
||||||
|
const platform = 'linux';
|
||||||
|
const distribution = new DragonwellDistribution({
|
||||||
|
version: jdkVersion,
|
||||||
|
architecture: arch,
|
||||||
|
packageType: 'jre',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
mockPlatform(distribution, platform);
|
||||||
|
await expect(
|
||||||
|
distribution['findPackageForDownload'](jdkVersion)
|
||||||
|
).rejects.toThrow('Dragonwell provides only the `jdk` package type');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
12
dist/cleanup/index.js
vendored
12
dist/cleanup/index.js
vendored
|
@ -67020,7 +67020,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
|
exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
|
||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
|
@ -67157,6 +67157,16 @@ function convertVersionToSemver(version) {
|
||||||
return mainVersion;
|
return mainVersion;
|
||||||
}
|
}
|
||||||
exports.convertVersionToSemver = convertVersionToSemver;
|
exports.convertVersionToSemver = convertVersionToSemver;
|
||||||
|
function getGitHubHttpHeaders() {
|
||||||
|
const token = core.getInput('token');
|
||||||
|
const auth = !token ? undefined : `token ${token}`;
|
||||||
|
const headers = {
|
||||||
|
authorization: auth,
|
||||||
|
accept: 'application/vnd.github.VERSION.raw'
|
||||||
|
};
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
228
dist/setup/index.js
vendored
228
dist/setup/index.js
vendored
|
@ -102554,6 +102554,7 @@ const installer_6 = __nccwpck_require__(3613);
|
||||||
const installer_7 = __nccwpck_require__(1121);
|
const installer_7 = __nccwpck_require__(1121);
|
||||||
const installer_8 = __nccwpck_require__(4750);
|
const installer_8 = __nccwpck_require__(4750);
|
||||||
const installer_9 = __nccwpck_require__(4298);
|
const installer_9 = __nccwpck_require__(4298);
|
||||||
|
const installer_10 = __nccwpck_require__(6132);
|
||||||
var JavaDistribution;
|
var JavaDistribution;
|
||||||
(function (JavaDistribution) {
|
(function (JavaDistribution) {
|
||||||
JavaDistribution["Adopt"] = "adopt";
|
JavaDistribution["Adopt"] = "adopt";
|
||||||
|
@ -102567,6 +102568,7 @@ var JavaDistribution;
|
||||||
JavaDistribution["Semeru"] = "semeru";
|
JavaDistribution["Semeru"] = "semeru";
|
||||||
JavaDistribution["Corretto"] = "corretto";
|
JavaDistribution["Corretto"] = "corretto";
|
||||||
JavaDistribution["Oracle"] = "oracle";
|
JavaDistribution["Oracle"] = "oracle";
|
||||||
|
JavaDistribution["Dragonwell"] = "dragonwell";
|
||||||
})(JavaDistribution || (JavaDistribution = {}));
|
})(JavaDistribution || (JavaDistribution = {}));
|
||||||
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||||
switch (distributionName) {
|
switch (distributionName) {
|
||||||
|
@ -102591,6 +102593,8 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||||
return new installer_8.CorrettoDistribution(installerOptions);
|
return new installer_8.CorrettoDistribution(installerOptions);
|
||||||
case JavaDistribution.Oracle:
|
case JavaDistribution.Oracle:
|
||||||
return new installer_9.OracleDistribution(installerOptions);
|
return new installer_9.OracleDistribution(installerOptions);
|
||||||
|
case JavaDistribution.Dragonwell:
|
||||||
|
return new installer_10.DragonwellDistribution(installerOptions);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -102598,6 +102602,211 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||||
exports.getJavaDistribution = getJavaDistribution;
|
exports.getJavaDistribution = getJavaDistribution;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6132:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.DragonwellDistribution = void 0;
|
||||||
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
|
const tc = __importStar(__nccwpck_require__(7784));
|
||||||
|
const semver_1 = __importDefault(__nccwpck_require__(1383));
|
||||||
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
|
const base_installer_1 = __nccwpck_require__(9741);
|
||||||
|
const util_1 = __nccwpck_require__(2629);
|
||||||
|
class DragonwellDistribution extends base_installer_1.JavaBase {
|
||||||
|
constructor(installerOptions) {
|
||||||
|
super('Dragonwell', installerOptions);
|
||||||
|
}
|
||||||
|
findPackageForDownload(version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (!this.stable) {
|
||||||
|
throw new Error('Early access versions are not supported by Dragonwell');
|
||||||
|
}
|
||||||
|
if (this.packageType !== 'jdk') {
|
||||||
|
throw new Error('Dragonwell provides only the `jdk` package type');
|
||||||
|
}
|
||||||
|
const availableVersions = yield this.getAvailableVersions();
|
||||||
|
const matchedVersions = availableVersions
|
||||||
|
.filter(item => {
|
||||||
|
return util_1.isVersionSatisfies(version, item.jdk_version);
|
||||||
|
})
|
||||||
|
.map(item => {
|
||||||
|
return {
|
||||||
|
version: item.jdk_version,
|
||||||
|
url: item.download_link
|
||||||
|
};
|
||||||
|
});
|
||||||
|
if (!matchedVersions.length) {
|
||||||
|
throw new Error(`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`);
|
||||||
|
}
|
||||||
|
const resolvedVersion = matchedVersions[0];
|
||||||
|
return resolvedVersion;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getAvailableVersions() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const platform = this.getPlatformOption();
|
||||||
|
const arch = this.distributionArchitecture();
|
||||||
|
let fetchedDragonwellJson = yield this.fetchJsonFromPrimaryUrl();
|
||||||
|
if (!fetchedDragonwellJson) {
|
||||||
|
fetchedDragonwellJson = yield this.fetchJsonFromBackupUrl();
|
||||||
|
}
|
||||||
|
if (!fetchedDragonwellJson) {
|
||||||
|
throw new Error(`Couldn't fetch Dragonwell versions information from both primary and backup urls`);
|
||||||
|
}
|
||||||
|
core.debug('Successfully fetched information about available Dragonwell versions');
|
||||||
|
const availableVersions = this.parseVersions(platform, arch, fetchedDragonwellJson);
|
||||||
|
if (core.isDebug()) {
|
||||||
|
core.startGroup('Print information about available versions');
|
||||||
|
core.debug(availableVersions.map(item => item.jdk_version).join(', '));
|
||||||
|
core.endGroup();
|
||||||
|
}
|
||||||
|
return availableVersions;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
downloadTool(javaRelease) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||||
|
const javaArchivePath = yield tc.downloadTool(javaRelease.url);
|
||||||
|
core.info(`Extracting Java archive...`);
|
||||||
|
const extractedJavaPath = yield util_1.extractJdkFile(javaArchivePath, util_1.getDownloadArchiveExtension());
|
||||||
|
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
|
||||||
|
const archivePath = path_1.default.join(extractedJavaPath, archiveName);
|
||||||
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
|
const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture);
|
||||||
|
return { version: javaRelease.version, path: javaPath };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
parseVersions(platform, arch, dragonwellVersions) {
|
||||||
|
var _a;
|
||||||
|
const eligibleVersions = [];
|
||||||
|
for (const majorVersion in dragonwellVersions) {
|
||||||
|
const majorVersionMap = dragonwellVersions[majorVersion];
|
||||||
|
for (let jdkVersion in majorVersionMap) {
|
||||||
|
const jdkVersionMap = majorVersionMap[jdkVersion];
|
||||||
|
if (!(platform in jdkVersionMap)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const platformMap = jdkVersionMap[platform];
|
||||||
|
if (!(arch in platformMap)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const archMap = platformMap[arch];
|
||||||
|
if (jdkVersion === 'latest') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
|
||||||
|
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
|
||||||
|
if (jdkVersion.split('.').length > 3) {
|
||||||
|
jdkVersion = util_1.convertVersionToSemver(jdkVersion);
|
||||||
|
}
|
||||||
|
for (const edition in archMap) {
|
||||||
|
eligibleVersions.push({
|
||||||
|
os: platform,
|
||||||
|
architecture: arch,
|
||||||
|
jdk_version: jdkVersion,
|
||||||
|
checksum: (_a = archMap[edition].sha256) !== null && _a !== void 0 ? _a : '',
|
||||||
|
download_link: archMap[edition].download_url,
|
||||||
|
edition: edition,
|
||||||
|
image_type: 'jdk'
|
||||||
|
});
|
||||||
|
break; // Get the first available link to the JDK. In most cases it should point to the Extended version of JDK, in rare cases like with v17 it points to the Standard version (the only available).
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const sortedVersions = this.sortParsedVersions(eligibleVersions);
|
||||||
|
return sortedVersions;
|
||||||
|
}
|
||||||
|
// Sorts versions in descending order as by default data in JSON isn't sorted
|
||||||
|
sortParsedVersions(eligibleVersions) {
|
||||||
|
const sortedVersions = eligibleVersions.sort((versionObj1, versionObj2) => {
|
||||||
|
const version1 = versionObj1.jdk_version;
|
||||||
|
const version2 = versionObj2.jdk_version;
|
||||||
|
return semver_1.default.compareBuild(version1, version2);
|
||||||
|
});
|
||||||
|
return sortedVersions.reverse();
|
||||||
|
}
|
||||||
|
getPlatformOption() {
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'win32':
|
||||||
|
return 'windows';
|
||||||
|
default:
|
||||||
|
return process.platform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fetchJsonFromPrimaryUrl() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json';
|
||||||
|
try {
|
||||||
|
core.debug(`Trying to fetch available Dragonwell versions info from the primary url: ${primaryUrl}`);
|
||||||
|
const fetchedDragonwellJson = (yield this.http.getJson(primaryUrl)).result;
|
||||||
|
return fetchedDragonwellJson;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
core.debug(`Fetching Dragonwell versions info from the primary link: ${primaryUrl} ended up with the error: ${err.message}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
fetchJsonFromBackupUrl() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const owner = 'dragonwell-releng';
|
||||||
|
const repository = 'dragonwell-setup-java';
|
||||||
|
const branch = 'main';
|
||||||
|
const filePath = 'releases.json';
|
||||||
|
const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||||
|
const headers = util_1.getGitHubHttpHeaders();
|
||||||
|
try {
|
||||||
|
core.debug(`Trying to fetch available Dragonwell versions info from the backup url: ${backupUrl}`);
|
||||||
|
const fetchedDragonwellJson = (yield this.http.getJson(backupUrl, headers)).result;
|
||||||
|
return fetchedDragonwellJson;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
core.debug(`Fetching Dragonwell versions info from the backup url: ${backupUrl} ended up with the error: ${err.message}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.DragonwellDistribution = DragonwellDistribution;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 883:
|
/***/ 883:
|
||||||
|
@ -102970,18 +103179,13 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// TODO get these dynamically!
|
// TODO get these dynamically!
|
||||||
// We will need Microsoft to add an endpoint where we can query for versions.
|
// We will need Microsoft to add an endpoint where we can query for versions.
|
||||||
const token = core.getInput('token');
|
|
||||||
const auth = !token ? undefined : `token ${token}`;
|
|
||||||
const owner = 'actions';
|
const owner = 'actions';
|
||||||
const repository = 'setup-java';
|
const repository = 'setup-java';
|
||||||
const branch = 'main';
|
const branch = 'main';
|
||||||
const filePath = 'src/distributions/microsoft/microsoft-openjdk-versions.json';
|
const filePath = 'src/distributions/microsoft/microsoft-openjdk-versions.json';
|
||||||
let releases = null;
|
let releases = null;
|
||||||
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||||
const headers = {
|
const headers = util_1.getGitHubHttpHeaders();
|
||||||
authorization: auth,
|
|
||||||
accept: 'application/vnd.github.VERSION.raw'
|
|
||||||
};
|
|
||||||
let response = null;
|
let response = null;
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
console.time('Retrieving available versions for Microsoft took'); // eslint-disable-line no-console
|
console.time('Retrieving available versions for Microsoft took'); // eslint-disable-line no-console
|
||||||
|
@ -104074,7 +104278,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
|
exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
|
||||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
|
@ -104211,6 +104415,16 @@ function convertVersionToSemver(version) {
|
||||||
return mainVersion;
|
return mainVersion;
|
||||||
}
|
}
|
||||||
exports.convertVersionToSemver = convertVersionToSemver;
|
exports.convertVersionToSemver = convertVersionToSemver;
|
||||||
|
function getGitHubHttpHeaders() {
|
||||||
|
const token = core.getInput('token');
|
||||||
|
const auth = !token ? undefined : `token ${token}`;
|
||||||
|
const headers = {
|
||||||
|
authorization: auth,
|
||||||
|
accept: 'application/vnd.github.VERSION.raw'
|
||||||
|
};
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
- [Microsoft](#Microsoft)
|
- [Microsoft](#Microsoft)
|
||||||
- [Amazon Corretto](#Amazon-Corretto)
|
- [Amazon Corretto](#Amazon-Corretto)
|
||||||
- [Oracle](#Oracle)
|
- [Oracle](#Oracle)
|
||||||
|
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
||||||
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
||||||
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
||||||
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
||||||
|
@ -124,6 +125,18 @@ steps:
|
||||||
- run: java -cp java HelloWorldApp
|
- run: java -cp java HelloWorldApp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Alibaba Dragonwell
|
||||||
|
**NOTE:** Alibaba Dragonwell only provides jdk.
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'dragonwell'
|
||||||
|
java-version: '8'
|
||||||
|
- run: java -cp java HelloWorldApp
|
||||||
|
```
|
||||||
|
|
||||||
## Installing custom Java package type
|
## Installing custom Java package type
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {MicrosoftDistributions} from './microsoft/installer';
|
||||||
import {SemeruDistribution} from './semeru/installer';
|
import {SemeruDistribution} from './semeru/installer';
|
||||||
import {CorrettoDistribution} from './corretto/installer';
|
import {CorrettoDistribution} from './corretto/installer';
|
||||||
import {OracleDistribution} from './oracle/installer';
|
import {OracleDistribution} from './oracle/installer';
|
||||||
|
import {DragonwellDistribution} from './dragonwell/installer';
|
||||||
|
|
||||||
enum JavaDistribution {
|
enum JavaDistribution {
|
||||||
Adopt = 'adopt',
|
Adopt = 'adopt',
|
||||||
|
@ -21,7 +22,8 @@ enum JavaDistribution {
|
||||||
Microsoft = 'microsoft',
|
Microsoft = 'microsoft',
|
||||||
Semeru = 'semeru',
|
Semeru = 'semeru',
|
||||||
Corretto = 'corretto',
|
Corretto = 'corretto',
|
||||||
Oracle = 'oracle'
|
Oracle = 'oracle',
|
||||||
|
Dragonwell = 'dragonwell'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getJavaDistribution(
|
export function getJavaDistribution(
|
||||||
|
@ -60,6 +62,8 @@ export function getJavaDistribution(
|
||||||
return new CorrettoDistribution(installerOptions);
|
return new CorrettoDistribution(installerOptions);
|
||||||
case JavaDistribution.Oracle:
|
case JavaDistribution.Oracle:
|
||||||
return new OracleDistribution(installerOptions);
|
return new OracleDistribution(installerOptions);
|
||||||
|
case JavaDistribution.Dragonwell:
|
||||||
|
return new DragonwellDistribution(installerOptions);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
240
src/distributions/dragonwell/installer.ts
Normal file
240
src/distributions/dragonwell/installer.ts
Normal file
|
@ -0,0 +1,240 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import semver from 'semver';
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
import {JavaBase} from '../base-installer';
|
||||||
|
import {
|
||||||
|
convertVersionToSemver,
|
||||||
|
extractJdkFile,
|
||||||
|
getDownloadArchiveExtension,
|
||||||
|
getGitHubHttpHeaders,
|
||||||
|
isVersionSatisfies
|
||||||
|
} from '../../util';
|
||||||
|
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
|
||||||
|
import {
|
||||||
|
JavaDownloadRelease,
|
||||||
|
JavaInstallerOptions,
|
||||||
|
JavaInstallerResults
|
||||||
|
} from '../base-models';
|
||||||
|
|
||||||
|
export class DragonwellDistribution extends JavaBase {
|
||||||
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
|
super('Dragonwell', installerOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async findPackageForDownload(
|
||||||
|
version: string
|
||||||
|
): Promise<JavaDownloadRelease> {
|
||||||
|
if (!this.stable) {
|
||||||
|
throw new Error('Early access versions are not supported by Dragonwell');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.packageType !== 'jdk') {
|
||||||
|
throw new Error('Dragonwell provides only the `jdk` package type');
|
||||||
|
}
|
||||||
|
|
||||||
|
const availableVersions = await this.getAvailableVersions();
|
||||||
|
|
||||||
|
const matchedVersions = availableVersions
|
||||||
|
.filter(item => {
|
||||||
|
return isVersionSatisfies(version, item.jdk_version);
|
||||||
|
})
|
||||||
|
.map(item => {
|
||||||
|
return {
|
||||||
|
version: item.jdk_version,
|
||||||
|
url: item.download_link
|
||||||
|
} as JavaDownloadRelease;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!matchedVersions.length) {
|
||||||
|
throw new Error(
|
||||||
|
`Couldn't find any satisfied version for the specified java-version: "${version}" and architecture: "${this.architecture}".`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolvedVersion = matchedVersions[0];
|
||||||
|
return resolvedVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getAvailableVersions(): Promise<IDragonwellVersions[]> {
|
||||||
|
const platform = this.getPlatformOption();
|
||||||
|
const arch = this.distributionArchitecture();
|
||||||
|
|
||||||
|
let fetchedDragonwellJson = await this.fetchJsonFromPrimaryUrl();
|
||||||
|
|
||||||
|
if (!fetchedDragonwellJson) {
|
||||||
|
fetchedDragonwellJson = await this.fetchJsonFromBackupUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fetchedDragonwellJson) {
|
||||||
|
throw new Error(
|
||||||
|
`Couldn't fetch Dragonwell versions information from both primary and backup urls`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
core.debug(
|
||||||
|
'Successfully fetched information about available Dragonwell versions'
|
||||||
|
);
|
||||||
|
|
||||||
|
const availableVersions = this.parseVersions(
|
||||||
|
platform,
|
||||||
|
arch,
|
||||||
|
fetchedDragonwellJson
|
||||||
|
);
|
||||||
|
|
||||||
|
if (core.isDebug()) {
|
||||||
|
core.startGroup('Print information about available versions');
|
||||||
|
core.debug(availableVersions.map(item => item.jdk_version).join(', '));
|
||||||
|
core.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
return availableVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async downloadTool(
|
||||||
|
javaRelease: JavaDownloadRelease
|
||||||
|
): Promise<JavaInstallerResults> {
|
||||||
|
core.info(
|
||||||
|
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||||
|
);
|
||||||
|
const javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||||
|
|
||||||
|
core.info(`Extracting Java archive...`);
|
||||||
|
|
||||||
|
const extractedJavaPath = await extractJdkFile(
|
||||||
|
javaArchivePath,
|
||||||
|
getDownloadArchiveExtension()
|
||||||
|
);
|
||||||
|
|
||||||
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
|
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||||
|
const version = this.getToolcacheVersionName(javaRelease.version);
|
||||||
|
|
||||||
|
const javaPath = await tc.cacheDir(
|
||||||
|
archivePath,
|
||||||
|
this.toolcacheFolderName,
|
||||||
|
version,
|
||||||
|
this.architecture
|
||||||
|
);
|
||||||
|
|
||||||
|
return {version: javaRelease.version, path: javaPath};
|
||||||
|
}
|
||||||
|
|
||||||
|
private parseVersions(
|
||||||
|
platform: string,
|
||||||
|
arch: string,
|
||||||
|
dragonwellVersions: IDragonwellAllVersions
|
||||||
|
): IDragonwellVersions[] {
|
||||||
|
const eligibleVersions: IDragonwellVersions[] = [];
|
||||||
|
|
||||||
|
for (const majorVersion in dragonwellVersions) {
|
||||||
|
const majorVersionMap = dragonwellVersions[majorVersion];
|
||||||
|
for (let jdkVersion in majorVersionMap) {
|
||||||
|
const jdkVersionMap = majorVersionMap[jdkVersion];
|
||||||
|
if (!(platform in jdkVersionMap)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const platformMap = jdkVersionMap[platform];
|
||||||
|
if (!(arch in platformMap)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const archMap = platformMap[arch];
|
||||||
|
|
||||||
|
if (jdkVersion === 'latest') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
|
||||||
|
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
|
||||||
|
if (jdkVersion.split('.').length > 3) {
|
||||||
|
jdkVersion = convertVersionToSemver(jdkVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const edition in archMap) {
|
||||||
|
eligibleVersions.push({
|
||||||
|
os: platform,
|
||||||
|
architecture: arch,
|
||||||
|
jdk_version: jdkVersion,
|
||||||
|
checksum: archMap[edition].sha256 ?? '',
|
||||||
|
download_link: archMap[edition].download_url,
|
||||||
|
edition: edition,
|
||||||
|
image_type: 'jdk'
|
||||||
|
});
|
||||||
|
break; // Get the first available link to the JDK. In most cases it should point to the Extended version of JDK, in rare cases like with v17 it points to the Standard version (the only available).
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const sortedVersions = this.sortParsedVersions(eligibleVersions);
|
||||||
|
|
||||||
|
return sortedVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sorts versions in descending order as by default data in JSON isn't sorted
|
||||||
|
private sortParsedVersions(
|
||||||
|
eligibleVersions: IDragonwellVersions[]
|
||||||
|
): IDragonwellVersions[] {
|
||||||
|
const sortedVersions = eligibleVersions.sort((versionObj1, versionObj2) => {
|
||||||
|
const version1 = versionObj1.jdk_version;
|
||||||
|
const version2 = versionObj2.jdk_version;
|
||||||
|
return semver.compareBuild(version1, version2);
|
||||||
|
});
|
||||||
|
return sortedVersions.reverse();
|
||||||
|
}
|
||||||
|
|
||||||
|
private getPlatformOption(): string {
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'win32':
|
||||||
|
return 'windows';
|
||||||
|
default:
|
||||||
|
return process.platform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async fetchJsonFromPrimaryUrl(): Promise<IDragonwellAllVersions | null> {
|
||||||
|
const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json';
|
||||||
|
try {
|
||||||
|
core.debug(
|
||||||
|
`Trying to fetch available Dragonwell versions info from the primary url: ${primaryUrl}`
|
||||||
|
);
|
||||||
|
const fetchedDragonwellJson = (
|
||||||
|
await this.http.getJson<IDragonwellAllVersions>(primaryUrl)
|
||||||
|
).result;
|
||||||
|
return fetchedDragonwellJson;
|
||||||
|
} catch (err) {
|
||||||
|
core.debug(
|
||||||
|
`Fetching Dragonwell versions info from the primary link: ${primaryUrl} ended up with the error: ${err.message}`
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async fetchJsonFromBackupUrl(): Promise<IDragonwellAllVersions | null> {
|
||||||
|
const owner = 'dragonwell-releng';
|
||||||
|
const repository = 'dragonwell-setup-java';
|
||||||
|
const branch = 'main';
|
||||||
|
const filePath = 'releases.json';
|
||||||
|
|
||||||
|
const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||||
|
|
||||||
|
const headers = getGitHubHttpHeaders();
|
||||||
|
|
||||||
|
try {
|
||||||
|
core.debug(
|
||||||
|
`Trying to fetch available Dragonwell versions info from the backup url: ${backupUrl}`
|
||||||
|
);
|
||||||
|
const fetchedDragonwellJson = (
|
||||||
|
await this.http.getJson<IDragonwellAllVersions>(backupUrl, headers)
|
||||||
|
).result;
|
||||||
|
return fetchedDragonwellJson;
|
||||||
|
} catch (err) {
|
||||||
|
core.debug(
|
||||||
|
`Fetching Dragonwell versions info from the backup url: ${backupUrl} ended up with the error: ${err.message}`
|
||||||
|
);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
src/distributions/dragonwell/models.ts
Normal file
26
src/distributions/dragonwell/models.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
export interface IDragonwellAllVersions {
|
||||||
|
[major: string]: {
|
||||||
|
[jdk_version: string]: {
|
||||||
|
[os: string]: {
|
||||||
|
[arch: string]: {
|
||||||
|
[edition: string]: {
|
||||||
|
content_type: string;
|
||||||
|
sha256: string;
|
||||||
|
name: string;
|
||||||
|
download_url: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IDragonwellVersions {
|
||||||
|
os: string;
|
||||||
|
architecture: string;
|
||||||
|
jdk_version: string;
|
||||||
|
checksum: string;
|
||||||
|
download_link: string;
|
||||||
|
edition: string;
|
||||||
|
image_type: string;
|
||||||
|
}
|
|
@ -4,10 +4,13 @@ import {
|
||||||
JavaInstallerOptions,
|
JavaInstallerOptions,
|
||||||
JavaInstallerResults
|
JavaInstallerResults
|
||||||
} from '../base-models';
|
} from '../base-models';
|
||||||
import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
|
import {
|
||||||
|
extractJdkFile,
|
||||||
|
getDownloadArchiveExtension,
|
||||||
|
getGitHubHttpHeaders
|
||||||
|
} from '../../util';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import {OutgoingHttpHeaders} from 'http';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {ITypedResponse} from '@actions/http-client/interfaces';
|
import {ITypedResponse} from '@actions/http-client/interfaces';
|
||||||
|
@ -85,8 +88,6 @@ export class MicrosoftDistributions extends JavaBase {
|
||||||
private async getAvailableVersions(): Promise<tc.IToolRelease[] | null> {
|
private async getAvailableVersions(): Promise<tc.IToolRelease[] | null> {
|
||||||
// TODO get these dynamically!
|
// TODO get these dynamically!
|
||||||
// We will need Microsoft to add an endpoint where we can query for versions.
|
// We will need Microsoft to add an endpoint where we can query for versions.
|
||||||
const token = core.getInput('token');
|
|
||||||
const auth = !token ? undefined : `token ${token}`;
|
|
||||||
const owner = 'actions';
|
const owner = 'actions';
|
||||||
const repository = 'setup-java';
|
const repository = 'setup-java';
|
||||||
const branch = 'main';
|
const branch = 'main';
|
||||||
|
@ -96,10 +97,7 @@ export class MicrosoftDistributions extends JavaBase {
|
||||||
let releases: tc.IToolRelease[] | null = null;
|
let releases: tc.IToolRelease[] | null = null;
|
||||||
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||||
|
|
||||||
const headers: OutgoingHttpHeaders = {
|
const headers = getGitHubHttpHeaders();
|
||||||
authorization: auth,
|
|
||||||
accept: 'application/vnd.github.VERSION.raw'
|
|
||||||
};
|
|
||||||
|
|
||||||
let response: ITypedResponse<tc.IToolRelease[]> | null = null;
|
let response: ITypedResponse<tc.IToolRelease[]> | null = null;
|
||||||
|
|
||||||
|
|
11
src/util.ts
11
src/util.ts
|
@ -7,6 +7,7 @@ import * as core from '@actions/core';
|
||||||
|
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import {INPUT_JOB_STATUS, DISTRIBUTIONS_ONLY_MAJOR_VERSION} from './constants';
|
import {INPUT_JOB_STATUS, DISTRIBUTIONS_ONLY_MAJOR_VERSION} from './constants';
|
||||||
|
import {OutgoingHttpHeaders} from 'http';
|
||||||
|
|
||||||
export function getTempDir() {
|
export function getTempDir() {
|
||||||
const tempDirectory = process.env['RUNNER_TEMP'] || os.tmpdir();
|
const tempDirectory = process.env['RUNNER_TEMP'] || os.tmpdir();
|
||||||
|
@ -161,3 +162,13 @@ export function convertVersionToSemver(version: number[] | string) {
|
||||||
}
|
}
|
||||||
return mainVersion;
|
return mainVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
|
||||||
|
const token = core.getInput('token');
|
||||||
|
const auth = !token ? undefined : `token ${token}`;
|
||||||
|
const headers: OutgoingHttpHeaders = {
|
||||||
|
authorization: auth,
|
||||||
|
accept: 'application/vnd.github.VERSION.raw'
|
||||||
|
};
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue