mirror of
https://github.com/actions/setup-java.git
synced 2024-11-13 21:48:05 +00:00
Compare commits
3 Commits
6b70e9d704
...
b6f9fd5f01
Author | SHA1 | Date | |
---|---|---|---|
|
b6f9fd5f01 | ||
|
0ab4596768 | ||
|
a8e0c559af |
22
.github/workflows/e2e-versions.yml
vendored
22
.github/workflows/e2e-versions.yml
vendored
@ -29,12 +29,15 @@ jobs:
|
||||
'liberica',
|
||||
'microsoft',
|
||||
'semeru',
|
||||
'corretto'
|
||||
'corretto',
|
||||
'dragonwell'
|
||||
] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||
version: ['8', '11', '17']
|
||||
exclude:
|
||||
- distribution: microsoft
|
||||
version: 8
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
include:
|
||||
- distribution: oracle
|
||||
os: macos-latest
|
||||
@ -45,6 +48,7 @@ jobs:
|
||||
- distribution: oracle
|
||||
os: ubuntu-latest
|
||||
version: 20
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -75,6 +79,12 @@ jobs:
|
||||
- distribution: oracle
|
||||
os: ubuntu-latest
|
||||
version: '20.0.1'
|
||||
- distribution: dragonwell
|
||||
os: ubuntu-latest
|
||||
version: '11.0'
|
||||
- distribution: dragonwell
|
||||
os: ubuntu-latest
|
||||
version: '11.0.13+9'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -96,7 +106,10 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['temurin', 'zulu', 'liberica']
|
||||
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||
exclude:
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@ -119,7 +132,10 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||
distribution: ['temurin', 'zulu', 'liberica']
|
||||
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||
exclude:
|
||||
- distribution: dragonwell
|
||||
os: macos-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
14
README.md
14
README.md
@ -41,6 +41,8 @@ This action allows you to work with Java and Scala projects.
|
||||
|
||||
- `cache`: Quick [setup caching](#caching-packages-dependencies) for the dependencies managed through one of the predefined package managers. It can be one of "maven", "gradle" or "sbt".
|
||||
|
||||
- `cache-dependency-path`: The path to a dependency file: pom.xml, build.gradle, build.sbt, etc. This option can be used with the `cache` option. If this option is omitted, the action searches for the dependency file in the entire repository. This option supports wildcards and a list of file names for caching multiple dependencies.
|
||||
|
||||
#### Maven options
|
||||
The action has a bunch of inputs to generate maven's [settings.xml](https://maven.apache.org/settings.html) on the fly and pass the values to Apache Maven GPG Plugin as well as Apache Maven Toolchains. See [advanced usage](docs/advanced-usage.md) for more.
|
||||
|
||||
@ -105,6 +107,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/)
|
||||
| `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)
|
||||
| `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.
|
||||
|
||||
@ -114,10 +117,13 @@ Currently, the following distributions are supported:
|
||||
|
||||
### Caching packages dependencies
|
||||
The action has a built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
|
||||
|
||||
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, `gradle/*.versions.toml`, and `**/versions.properties`
|
||||
- maven: `**/pom.xml`
|
||||
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.scala`, `**/project/**.sbt`
|
||||
|
||||
When the option `cache-dependency-path` is specified, the hash is based on the matching file. This option supports wildcards and a list of file names, and is especially useful for monorepos.
|
||||
|
||||
The workflow output `cache-hit` is set to indicate if an exact match was found for the key [as actions/cache does](https://github.com/actions/cache/tree/main#outputs).
|
||||
|
||||
The cache input is optional, and caching is turned off by default.
|
||||
@ -131,6 +137,9 @@ steps:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: 'gradle'
|
||||
cache-dependency-path: | # optional
|
||||
sub-project/*.gradle*
|
||||
sub-project/**/gradle-wrapper.properties
|
||||
- run: ./gradlew build --no-daemon
|
||||
```
|
||||
|
||||
@ -143,6 +152,7 @@ steps:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: 'maven'
|
||||
cache-dependency-path: 'sub-project/pom.xml' # optional
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
```
|
||||
@ -156,6 +166,9 @@ steps:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: 'sbt'
|
||||
cache-dependency-path: | # optional
|
||||
sub-project/build.sbt
|
||||
sub-project/project/build.properties
|
||||
- name: Build with SBT
|
||||
run: sbt package
|
||||
```
|
||||
@ -227,6 +240,7 @@ In the example above multiple JDKs are installed for the same job. The result af
|
||||
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
||||
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
||||
- [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 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)
|
||||
|
@ -6,6 +6,7 @@ import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as core from '@actions/core';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as glob from '@actions/glob';
|
||||
|
||||
describe('dependency cache', () => {
|
||||
const ORIGINAL_RUNNER_OS = process.env['RUNNER_OS'];
|
||||
@ -64,6 +65,10 @@ describe('dependency cache', () => {
|
||||
ReturnType<typeof cache.restoreCache>,
|
||||
Parameters<typeof cache.restoreCache>
|
||||
>;
|
||||
let spyGlobHashFiles: jest.SpyInstance<
|
||||
ReturnType<typeof glob.hashFiles>,
|
||||
Parameters<typeof glob.hashFiles>
|
||||
>;
|
||||
|
||||
beforeEach(() => {
|
||||
spyCacheRestore = jest
|
||||
@ -71,6 +76,7 @@ describe('dependency cache', () => {
|
||||
.mockImplementation((paths: string[], primaryKey: string) =>
|
||||
Promise.resolve(undefined)
|
||||
);
|
||||
spyGlobHashFiles = jest.spyOn(glob, 'hashFiles');
|
||||
spyWarning.mockImplementation(() => null);
|
||||
});
|
||||
|
||||
@ -93,6 +99,7 @@ describe('dependency cache', () => {
|
||||
|
||||
await restore('maven');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith('**/pom.xml');
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
|
||||
});
|
||||
@ -110,6 +117,9 @@ describe('dependency cache', () => {
|
||||
|
||||
await restore('gradle');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||
});
|
||||
@ -118,6 +128,9 @@ describe('dependency cache', () => {
|
||||
|
||||
await restore('gradle');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||
});
|
||||
@ -127,18 +140,24 @@ describe('dependency cache', () => {
|
||||
|
||||
await restore('gradle');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||
});
|
||||
});
|
||||
it('downloads cache based on buildSrc/Versions.kt', async () => {
|
||||
createDirectory(join(workspace, 'buildSrc'));
|
||||
createFile(join(workspace, 'buildSrc', 'Versions.kt'));
|
||||
it('downloads cache based on buildSrc/Versions.kt', async () => {
|
||||
createDirectory(join(workspace, 'buildSrc'));
|
||||
createFile(join(workspace, 'buildSrc', 'Versions.kt'));
|
||||
|
||||
await restore('gradle');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||
await restore('gradle');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||
});
|
||||
});
|
||||
describe('for sbt', () => {
|
||||
it('throws error if no build.sbt found', async () => {
|
||||
@ -153,6 +172,9 @@ describe('dependency cache', () => {
|
||||
|
||||
await restore('sbt');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/*.sbt\n**/project/build.properties\n**/project/**.scala\n**/project/**.sbt'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('sbt cache is not found');
|
||||
});
|
||||
@ -184,9 +206,53 @@ describe('dependency cache', () => {
|
||||
|
||||
await restore('gradle');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'**/*.gradle*\n**/gradle-wrapper.properties\nbuildSrc/**/Versions.kt\nbuildSrc/**/Dependencies.kt\ngradle/*.versions.toml\n**/versions.properties'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||
});
|
||||
describe('cache-dependency-path', () => {
|
||||
it('throws error if no matching dependency file found', async () => {
|
||||
createFile(join(workspace, 'build.gradle.kts'));
|
||||
await expect(
|
||||
restore('gradle', 'sub-project/**/build.gradle.kts')
|
||||
).rejects.toThrow(
|
||||
`No file in ${projectRoot(
|
||||
workspace
|
||||
)} matched to [sub-project/**/build.gradle.kts], make sure you have checked out the target repository`
|
||||
);
|
||||
});
|
||||
it('downloads cache based on the specified pattern', async () => {
|
||||
createFile(join(workspace, 'build.gradle.kts'));
|
||||
createDirectory(join(workspace, 'sub-project1'));
|
||||
createFile(join(workspace, 'sub-project1', 'build.gradle.kts'));
|
||||
createDirectory(join(workspace, 'sub-project2'));
|
||||
createFile(join(workspace, 'sub-project2', 'build.gradle.kts'));
|
||||
|
||||
await restore('gradle', 'build.gradle.kts');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith('build.gradle.kts');
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||
|
||||
await restore('gradle', 'sub-project1/**/*.gradle*\n');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'sub-project1/**/*.gradle*'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||
|
||||
await restore('gradle', '*.gradle*\nsub-project2/**/*.gradle*\n');
|
||||
expect(spyCacheRestore).toHaveBeenCalled();
|
||||
expect(spyGlobHashFiles).toHaveBeenCalledWith(
|
||||
'*.gradle*\nsub-project2/**/*.gradle*'
|
||||
);
|
||||
expect(spyWarning).not.toHaveBeenCalled();
|
||||
expect(spyInfo).toHaveBeenCalledWith('gradle cache is not found');
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('save', () => {
|
||||
let spyCacheSave: jest.SpyInstance<
|
||||
|
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');
|
||||
});
|
||||
});
|
||||
});
|
36
dist/cleanup/index.js
vendored
36
dist/cleanup/index.js
vendored
@ -66672,28 +66672,31 @@ function findPackageManager(id) {
|
||||
/**
|
||||
* A function that generates a cache key to use.
|
||||
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
||||
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
|
||||
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
|
||||
*/
|
||||
function computeCacheKey(packageManager) {
|
||||
function computeCacheKey(packageManager, cacheDependencyPath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const hash = yield glob.hashFiles(packageManager.pattern.join('\n'));
|
||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`;
|
||||
const pattern = cacheDependencyPath
|
||||
? cacheDependencyPath.trim().split('\n')
|
||||
: packageManager.pattern;
|
||||
const fileHash = yield glob.hashFiles(pattern.join('\n'));
|
||||
if (!fileHash) {
|
||||
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
||||
}
|
||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${fileHash}`;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Restore the dependency cache
|
||||
* @param id ID of the package manager, should be "maven" or "gradle"
|
||||
* @param cacheDependencyPath The path to a dependency file
|
||||
*/
|
||||
function restore(id) {
|
||||
function restore(id, cacheDependencyPath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const packageManager = findPackageManager(id);
|
||||
const primaryKey = yield computeCacheKey(packageManager);
|
||||
const primaryKey = yield computeCacheKey(packageManager, cacheDependencyPath);
|
||||
core.debug(`primary key is ${primaryKey}`);
|
||||
core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||
if (primaryKey.endsWith('-')) {
|
||||
throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`);
|
||||
}
|
||||
// No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269)
|
||||
const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey);
|
||||
if (matchedKey) {
|
||||
@ -66870,7 +66873,7 @@ else {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
||||
@ -66889,6 +66892,7 @@ exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
|
||||
exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined;
|
||||
exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
||||
exports.INPUT_CACHE = 'cache';
|
||||
exports.INPUT_CACHE_DEPENDENCY_PATH = 'cache-dependency-path';
|
||||
exports.INPUT_JOB_STATUS = 'job-status';
|
||||
exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';
|
||||
exports.M2_DIR = '.m2';
|
||||
@ -67020,7 +67024,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
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 path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
@ -67157,6 +67161,16 @@ function convertVersionToSemver(version) {
|
||||
return mainVersion;
|
||||
}
|
||||
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;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
255
dist/setup/index.js
vendored
255
dist/setup/index.js
vendored
@ -101877,28 +101877,31 @@ function findPackageManager(id) {
|
||||
/**
|
||||
* A function that generates a cache key to use.
|
||||
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
||||
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
|
||||
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
|
||||
*/
|
||||
function computeCacheKey(packageManager) {
|
||||
function computeCacheKey(packageManager, cacheDependencyPath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const hash = yield glob.hashFiles(packageManager.pattern.join('\n'));
|
||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`;
|
||||
const pattern = cacheDependencyPath
|
||||
? cacheDependencyPath.trim().split('\n')
|
||||
: packageManager.pattern;
|
||||
const fileHash = yield glob.hashFiles(pattern.join('\n'));
|
||||
if (!fileHash) {
|
||||
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
|
||||
}
|
||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${fileHash}`;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Restore the dependency cache
|
||||
* @param id ID of the package manager, should be "maven" or "gradle"
|
||||
* @param cacheDependencyPath The path to a dependency file
|
||||
*/
|
||||
function restore(id) {
|
||||
function restore(id, cacheDependencyPath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const packageManager = findPackageManager(id);
|
||||
const primaryKey = yield computeCacheKey(packageManager);
|
||||
const primaryKey = yield computeCacheKey(packageManager, cacheDependencyPath);
|
||||
core.debug(`primary key is ${primaryKey}`);
|
||||
core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||
if (primaryKey.endsWith('-')) {
|
||||
throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`);
|
||||
}
|
||||
// No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269)
|
||||
const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey);
|
||||
if (matchedKey) {
|
||||
@ -101974,7 +101977,7 @@ function isProbablyGradleDaemonProblem(packageManager, error) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||
exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE_DEPENDENCY_PATH = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||
exports.INPUT_JAVA_VERSION_FILE = 'java-version-file';
|
||||
@ -101993,6 +101996,7 @@ exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
|
||||
exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined;
|
||||
exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
||||
exports.INPUT_CACHE = 'cache';
|
||||
exports.INPUT_CACHE_DEPENDENCY_PATH = 'cache-dependency-path';
|
||||
exports.INPUT_JOB_STATUS = 'job-status';
|
||||
exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';
|
||||
exports.M2_DIR = '.m2';
|
||||
@ -102554,6 +102558,7 @@ const installer_6 = __nccwpck_require__(3613);
|
||||
const installer_7 = __nccwpck_require__(1121);
|
||||
const installer_8 = __nccwpck_require__(4750);
|
||||
const installer_9 = __nccwpck_require__(4298);
|
||||
const installer_10 = __nccwpck_require__(6132);
|
||||
var JavaDistribution;
|
||||
(function (JavaDistribution) {
|
||||
JavaDistribution["Adopt"] = "adopt";
|
||||
@ -102567,6 +102572,7 @@ var JavaDistribution;
|
||||
JavaDistribution["Semeru"] = "semeru";
|
||||
JavaDistribution["Corretto"] = "corretto";
|
||||
JavaDistribution["Oracle"] = "oracle";
|
||||
JavaDistribution["Dragonwell"] = "dragonwell";
|
||||
})(JavaDistribution || (JavaDistribution = {}));
|
||||
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
switch (distributionName) {
|
||||
@ -102591,6 +102597,8 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
return new installer_8.CorrettoDistribution(installerOptions);
|
||||
case JavaDistribution.Oracle:
|
||||
return new installer_9.OracleDistribution(installerOptions);
|
||||
case JavaDistribution.Dragonwell:
|
||||
return new installer_10.DragonwellDistribution(installerOptions);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -102598,6 +102606,211 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
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:
|
||||
@ -102970,18 +103183,13 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// TODO get these dynamically!
|
||||
// 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 repository = 'setup-java';
|
||||
const branch = 'main';
|
||||
const filePath = 'src/distributions/microsoft/microsoft-openjdk-versions.json';
|
||||
let releases = null;
|
||||
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
const headers = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
const headers = util_1.getGitHubHttpHeaders();
|
||||
let response = null;
|
||||
if (core.isDebug()) {
|
||||
console.time('Retrieving available versions for Microsoft took'); // eslint-disable-line no-console
|
||||
@ -103805,6 +104013,7 @@ function run() {
|
||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
||||
const cache = core.getInput(constants.INPUT_CACHE);
|
||||
const cacheDependencyPath = core.getInput(constants.INPUT_CACHE_DEPENDENCY_PATH);
|
||||
const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
||||
core.startGroup('Installed distributions');
|
||||
@ -103840,7 +104049,7 @@ function run() {
|
||||
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
||||
yield auth.configureAuthentication();
|
||||
if (cache && util_1.isCacheFeatureAvailable()) {
|
||||
yield cache_1.restore(cache);
|
||||
yield cache_1.restore(cache, cacheDependencyPath);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
@ -104074,7 +104283,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
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 path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
@ -104211,6 +104420,16 @@ function convertVersionToSemver(version) {
|
||||
return mainVersion;
|
||||
}
|
||||
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)
|
||||
- [Amazon Corretto](#Amazon-Corretto)
|
||||
- [Oracle](#Oracle)
|
||||
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
||||
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
||||
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
||||
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
||||
@ -124,6 +125,18 @@ steps:
|
||||
- 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
|
||||
```yaml
|
||||
steps:
|
||||
|
31
src/cache.ts
31
src/cache.ts
@ -83,31 +83,34 @@ function findPackageManager(id: string): PackageManager {
|
||||
/**
|
||||
* A function that generates a cache key to use.
|
||||
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
|
||||
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
|
||||
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
|
||||
*/
|
||||
async function computeCacheKey(packageManager: PackageManager) {
|
||||
const hash = await glob.hashFiles(packageManager.pattern.join('\n'));
|
||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`;
|
||||
async function computeCacheKey(
|
||||
packageManager: PackageManager,
|
||||
cacheDependencyPath?: string
|
||||
) {
|
||||
const pattern = cacheDependencyPath
|
||||
? cacheDependencyPath.trim().split('\n')
|
||||
: packageManager.pattern;
|
||||
const fileHash = await glob.hashFiles(pattern.join('\n'));
|
||||
if (!fileHash) {
|
||||
throw new Error(
|
||||
`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`
|
||||
);
|
||||
}
|
||||
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${fileHash}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the dependency cache
|
||||
* @param id ID of the package manager, should be "maven" or "gradle"
|
||||
* @param cacheDependencyPath The path to a dependency file
|
||||
*/
|
||||
export async function restore(id: string) {
|
||||
export async function restore(id: string, cacheDependencyPath?: string) {
|
||||
const packageManager = findPackageManager(id);
|
||||
const primaryKey = await computeCacheKey(packageManager);
|
||||
|
||||
const primaryKey = await computeCacheKey(packageManager, cacheDependencyPath);
|
||||
core.debug(`primary key is ${primaryKey}`);
|
||||
core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||
if (primaryKey.endsWith('-')) {
|
||||
throw new Error(
|
||||
`No file in ${process.cwd()} matched to [${
|
||||
packageManager.pattern
|
||||
}], make sure you have checked out the target repository`
|
||||
);
|
||||
}
|
||||
|
||||
// No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269)
|
||||
const matchedKey = await cache.restoreCache(packageManager.path, primaryKey);
|
||||
|
@ -18,6 +18,7 @@ export const INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined;
|
||||
export const INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
||||
|
||||
export const INPUT_CACHE = 'cache';
|
||||
export const INPUT_CACHE_DEPENDENCY_PATH = 'cache-dependency-path';
|
||||
export const INPUT_JOB_STATUS = 'job-status';
|
||||
|
||||
export const STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';
|
||||
|
@ -9,6 +9,7 @@ import {MicrosoftDistributions} from './microsoft/installer';
|
||||
import {SemeruDistribution} from './semeru/installer';
|
||||
import {CorrettoDistribution} from './corretto/installer';
|
||||
import {OracleDistribution} from './oracle/installer';
|
||||
import {DragonwellDistribution} from './dragonwell/installer';
|
||||
|
||||
enum JavaDistribution {
|
||||
Adopt = 'adopt',
|
||||
@ -21,7 +22,8 @@ enum JavaDistribution {
|
||||
Microsoft = 'microsoft',
|
||||
Semeru = 'semeru',
|
||||
Corretto = 'corretto',
|
||||
Oracle = 'oracle'
|
||||
Oracle = 'oracle',
|
||||
Dragonwell = 'dragonwell'
|
||||
}
|
||||
|
||||
export function getJavaDistribution(
|
||||
@ -60,6 +62,8 @@ export function getJavaDistribution(
|
||||
return new CorrettoDistribution(installerOptions);
|
||||
case JavaDistribution.Oracle:
|
||||
return new OracleDistribution(installerOptions);
|
||||
case JavaDistribution.Dragonwell:
|
||||
return new DragonwellDistribution(installerOptions);
|
||||
default:
|
||||
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,
|
||||
JavaInstallerResults
|
||||
} from '../base-models';
|
||||
import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
getGitHubHttpHeaders
|
||||
} from '../../util';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {ITypedResponse} from '@actions/http-client/interfaces';
|
||||
@ -85,8 +88,6 @@ export class MicrosoftDistributions extends JavaBase {
|
||||
private async getAvailableVersions(): Promise<tc.IToolRelease[] | null> {
|
||||
// TODO get these dynamically!
|
||||
// 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 repository = 'setup-java';
|
||||
const branch = 'main';
|
||||
@ -96,10 +97,7 @@ export class MicrosoftDistributions extends JavaBase {
|
||||
let releases: tc.IToolRelease[] | null = null;
|
||||
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
|
||||
const headers: OutgoingHttpHeaders = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
const headers = getGitHubHttpHeaders();
|
||||
|
||||
let response: ITypedResponse<tc.IToolRelease[]> | null = null;
|
||||
|
||||
|
@ -24,6 +24,9 @@ async function run() {
|
||||
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
||||
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
||||
const cache = core.getInput(constants.INPUT_CACHE);
|
||||
const cacheDependencyPath = core.getInput(
|
||||
constants.INPUT_CACHE_DEPENDENCY_PATH
|
||||
);
|
||||
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
||||
let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID);
|
||||
|
||||
@ -73,7 +76,7 @@ async function run() {
|
||||
|
||||
await auth.configureAuthentication();
|
||||
if (cache && isCacheFeatureAvailable()) {
|
||||
await restore(cache);
|
||||
await restore(cache, cacheDependencyPath);
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
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 {INPUT_JOB_STATUS, DISTRIBUTIONS_ONLY_MAJOR_VERSION} from './constants';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
|
||||
export function getTempDir() {
|
||||
const tempDirectory = process.env['RUNNER_TEMP'] || os.tmpdir();
|
||||
@ -161,3 +162,13 @@ export function convertVersionToSemver(version: number[] | string) {
|
||||
}
|
||||
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 New Issue
Block a user