mirror of
https://github.com/actions/setup-java.git
synced 2026-07-05 12:00:58 +00:00
Compare commits
2 Commits
a43c374bbb
...
aa23dade20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa23dade20 | ||
|
|
9871695637 |
36
.github/workflows/e2e-versions.yml
vendored
36
.github/workflows/e2e-versions.yml
vendored
@ -31,7 +31,6 @@ jobs:
|
|||||||
'semeru',
|
'semeru',
|
||||||
'corretto',
|
'corretto',
|
||||||
'dragonwell',
|
'dragonwell',
|
||||||
'sapmachine',
|
|
||||||
'kona'
|
'kona'
|
||||||
] # internally 'adopt-hotspot' is the same as 'adopt'
|
] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||||
version: ['21', '11', '17']
|
version: ['21', '11', '17']
|
||||||
@ -40,6 +39,8 @@ jobs:
|
|||||||
version: 8
|
version: 8
|
||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: macos-13
|
os: macos-13
|
||||||
|
- distribution: kona
|
||||||
|
version: 21
|
||||||
include:
|
include:
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: macos-13
|
os: macos-13
|
||||||
@ -87,9 +88,6 @@ jobs:
|
|||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
version: '11.0.13+9'
|
version: '11.0.13+9'
|
||||||
- distribution: sapmachine
|
|
||||||
os: ubuntu-latest
|
|
||||||
version: '17.0.7'
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -111,8 +109,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution:
|
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||||
['temurin', 'zulu', 'liberica', 'dragonwell', 'sapmachine']
|
|
||||||
exclude:
|
exclude:
|
||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
@ -138,8 +135,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution:
|
distribution: ['temurin', 'zulu', 'liberica', 'dragonwell']
|
||||||
['temurin', 'zulu', 'liberica', 'dragonwell', 'sapmachine']
|
|
||||||
exclude:
|
exclude:
|
||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
@ -215,28 +211,6 @@ jobs:
|
|||||||
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
|
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-java-ea-versions-sapmachine:
|
|
||||||
name: sapmachine ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }}
|
|
||||||
needs: setup-java-major-minor-versions
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
version: ['17-ea', '21-ea']
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: setup-java
|
|
||||||
uses: ./
|
|
||||||
id: setup-java
|
|
||||||
with:
|
|
||||||
java-version: ${{ matrix.version }}
|
|
||||||
distribution: sapmachine
|
|
||||||
- name: Verify Java
|
|
||||||
run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}"
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
setup-java-custom-package-type:
|
setup-java-custom-package-type:
|
||||||
name: ${{ matrix.distribution }} ${{ matrix.version }} (${{ matrix.java-package }}-x64) - ${{ matrix.os }}
|
name: ${{ matrix.distribution }} ${{ matrix.version }} (${{ matrix.java-package }}-x64) - ${{ matrix.os }}
|
||||||
needs: setup-java-major-minor-versions
|
needs: setup-java-major-minor-versions
|
||||||
@ -245,7 +219,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
distribution: ['temurin', 'zulu', 'liberica', 'semeru', 'sapmachine']
|
distribution: ['temurin', 'zulu', 'liberica', 'semeru']
|
||||||
java-package: ['jre']
|
java-package: ['jre']
|
||||||
version: ['17.0']
|
version: ['17.0']
|
||||||
include:
|
include:
|
||||||
|
|||||||
22
.github/workflows/publish-immutable-actions.yml
vendored
22
.github/workflows/publish-immutable-actions.yml
vendored
@ -1,22 +0,0 @@
|
|||||||
name: 'Publish Immutable Action Version'
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [created]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
id-token: write
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checking out
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Publish
|
|
||||||
id: publish
|
|
||||||
uses: actions/publish-immutable-action@0.0.1
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
@ -108,7 +108,6 @@ Currently, the following distributions are supported:
|
|||||||
| `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/)
|
| `dragonwell` | Alibaba Dragonwell JDK | [Link](https://dragonwell-jdk.io/) | [Link](https://www.aliyun.com/product/dragonwell/)
|
||||||
| `sapmachine` | SAP SapMachine JDK/JRE | [Link](https://sapmachine.io/) | [Link](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
|
|
||||||
| `kona` | Tencent Kona JDK | [Link](https://tencent.github.io/konajdk/) | [Link](https://tencent.github.io/konajdk/LICENSE.txt)
|
| `kona` | Tencent Kona JDK | [Link](https://tencent.github.io/konajdk/) | [Link](https://tencent.github.io/konajdk/LICENSE.txt)
|
||||||
|
|
||||||
**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.
|
||||||
@ -259,7 +258,6 @@ In the example above multiple JDKs are installed for the same job. The result af
|
|||||||
- [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)
|
- [Alibaba Dragonwell](docs/advanced-usage.md#Alibaba-Dragonwell)
|
||||||
- [SapMachine](docs/advanced-usage.md#SapMachine)
|
|
||||||
- [Tencent Kona](docs/advanced-usage.md#Tencent-Kona)
|
- [Tencent Kona](docs/advanced-usage.md#Tencent-Kona)
|
||||||
- [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)
|
||||||
|
|||||||
@ -118,45 +118,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
|
||||||
"21": [
|
|
||||||
{
|
|
||||||
"version": "21.0.4",
|
|
||||||
"jdkVersion": "21.0.4",
|
|
||||||
"latest": true,
|
|
||||||
"baseUrl": "https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.4/",
|
|
||||||
"files": [
|
|
||||||
{
|
|
||||||
"os": "linux",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"filename": "TencentKona-21.0.4.b1-jdk_linux-aarch64.tar.gz",
|
|
||||||
"checksum": "47b81d125b2bbd7a77f9220aac38f5b1dcc990995b8888e0ecbd3e40418381d9"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"os": "linux",
|
|
||||||
"arch": "x86_64",
|
|
||||||
"filename": "TencentKona-21.0.4.b1-jdk_linux-x86_64.tar.gz",
|
|
||||||
"checksum": "f506d86c5a9321d37cd7aaa783529653f2b15d5817f2cd9eda3e2131029dd7a4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"os": "macos",
|
|
||||||
"arch": "aarch64",
|
|
||||||
"filename": "TencentKona-21.0.4.b1_jdk_macosx-aarch64_notarized.tar.gz",
|
|
||||||
"checksum": "71041e40bacacb99376e09229263cf3254d5c723074b248f4a590d324a06c188"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"os": "macos",
|
|
||||||
"arch": "x86_64",
|
|
||||||
"filename": "TencentKona-21.0.4.b1_jdk_macosx-x86_64_notarized.tar.gz",
|
|
||||||
"checksum": "445703ac1cae143090362da36ca08c3975190f37d149913ab2495bc26c3d41f7"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"os": "windows",
|
|
||||||
"arch": "x86_64",
|
|
||||||
"filename": "TencentKona-21.0.4.b1_jdk_windows-x86_64_signed.zip",
|
|
||||||
"checksum": "0e10f33df898567dd33c2cdd8e5352dee86b699e810c16b3a4e5e38715d26447"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -27,8 +27,7 @@ describe('Check getAvailableReleases', () => {
|
|||||||
['8.0.19', 'macos', 'x86_64', 'macosx-x86_64'],
|
['8.0.19', 'macos', 'x86_64', 'macosx-x86_64'],
|
||||||
['11', 'linux', 'x86_64', 'linux-x86_64'],
|
['11', 'linux', 'x86_64', 'linux-x86_64'],
|
||||||
['11.0.24', 'macos', 'aarch64', 'macosx-aarch64'],
|
['11.0.24', 'macos', 'aarch64', 'macosx-aarch64'],
|
||||||
['17.0.12', 'windows', 'x86_64', 'windows-x86_64'],
|
['17.0.12', 'windows', 'x86_64', 'windows-x86_64']
|
||||||
['21.0.4', 'linux', 'x86_64', 'linux-x86_64']
|
|
||||||
])(
|
])(
|
||||||
'should get releases with the specified version "%s", OS "%s" and arch "%s"',
|
'should get releases with the specified version "%s", OS "%s" and arch "%s"',
|
||||||
async (
|
async (
|
||||||
@ -41,7 +40,7 @@ describe('Check getAvailableReleases', () => {
|
|||||||
|
|
||||||
const releases = await distribution['getAvailableReleases']();
|
const releases = await distribution['getAvailableReleases']();
|
||||||
expect(releases).not.toBeNull();
|
expect(releases).not.toBeNull();
|
||||||
expect(releases.length).toBe(4);
|
expect(releases.length).toBe(3);
|
||||||
releases.forEach((release, index) =>
|
releases.forEach((release, index) =>
|
||||||
expect(releases[index].downloadUrl).toContain(expectedPattern)
|
expect(releases[index].downloadUrl).toContain(expectedPattern)
|
||||||
);
|
);
|
||||||
@ -142,37 +141,6 @@ describe('Check findPackageForDownload', () => {
|
|||||||
'windows',
|
'windows',
|
||||||
'x86_64',
|
'x86_64',
|
||||||
'https://github.com/Tencent/TencentKona-17/releases/download/TencentKona-17.0.12/TencentKona-17.0.12.b1_jdk_windows-x86_64_signed.zip'
|
'https://github.com/Tencent/TencentKona-17/releases/download/TencentKona-17.0.12/TencentKona-17.0.12.b1_jdk_windows-x86_64_signed.zip'
|
||||||
],
|
|
||||||
|
|
||||||
[
|
|
||||||
'21',
|
|
||||||
'linux',
|
|
||||||
'aarch64',
|
|
||||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.4/TencentKona-21.0.4.b1-jdk_linux-aarch64.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'21.0.4',
|
|
||||||
'linux',
|
|
||||||
'x86_64',
|
|
||||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.4/TencentKona-21.0.4.b1-jdk_linux-x86_64.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'21.0.4',
|
|
||||||
'macos',
|
|
||||||
'aarch64',
|
|
||||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.4/TencentKona-21.0.4.b1_jdk_macosx-aarch64_notarized.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'21.0.4',
|
|
||||||
'macos',
|
|
||||||
'x86_64',
|
|
||||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.4/TencentKona-21.0.4.b1_jdk_macosx-x86_64_notarized.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'21.0.4',
|
|
||||||
'windows',
|
|
||||||
'x86_64',
|
|
||||||
'https://github.com/Tencent/TencentKona-21/releases/download/TencentKona-21.0.4/TencentKona-21.0.4.b1_jdk_windows-x86_64_signed.zip'
|
|
||||||
]
|
]
|
||||||
])(
|
])(
|
||||||
'should return the download URL with the specified version "%s", OS "%s" and arch "%s"',
|
'should return the download URL with the specified version "%s", OS "%s" and arch "%s"',
|
||||||
@ -192,7 +160,7 @@ describe('No release is found', () => {
|
|||||||
it.each([
|
it.each([
|
||||||
['8', 'linux', 'x86'],
|
['8', 'linux', 'x86'],
|
||||||
['17', 'solaris', 'x86_64'],
|
['17', 'solaris', 'x86_64'],
|
||||||
['22', 'linux', 'x86_64']
|
['21', 'linux', 'x86_64']
|
||||||
])(
|
])(
|
||||||
`should throw an error due to no release with the specified version "%s", os "%s" and arch "%s"`,
|
`should throw an error due to no release with the specified version "%s", os "%s" and arch "%s"`,
|
||||||
async (version: string, os: string, arch: string) => {
|
async (version: string, os: string, arch: string) => {
|
||||||
|
|||||||
@ -1,294 +0,0 @@
|
|||||||
import {HttpClient} from '@actions/http-client';
|
|
||||||
import {SapMachineDistribution} from '../../src/distributions/sapmachine/installer';
|
|
||||||
import * as utils from '../../src/util';
|
|
||||||
|
|
||||||
import manifestData from '../data/sapmachine.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: SapMachineDistribution,
|
|
||||||
platform: string
|
|
||||||
) => {
|
|
||||||
distribution['getPlatformOption'] = () => platform;
|
|
||||||
const mockedExtension = platform == 'windows' ? 'zip' : 'tar.gz';
|
|
||||||
spyUtilGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('shouldFallbackToBackupUrl', () => {
|
|
||||||
it('should return correct release when the primary URL is not available', async () => {
|
|
||||||
spyHttpClient.mockReturnValueOnce({
|
|
||||||
statusCode: 404,
|
|
||||||
headers: {},
|
|
||||||
result: ''
|
|
||||||
});
|
|
||||||
spyHttpClient.mockReturnValueOnce({
|
|
||||||
statusCode: 200,
|
|
||||||
headers: {},
|
|
||||||
result: manifestData
|
|
||||||
});
|
|
||||||
|
|
||||||
const version = '17';
|
|
||||||
const distribution = new SapMachineDistribution({
|
|
||||||
version: version,
|
|
||||||
architecture: 'x64',
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
|
|
||||||
mockPlatform(distribution, 'linux');
|
|
||||||
|
|
||||||
const availableVersion = await distribution['findPackageForDownload'](
|
|
||||||
version
|
|
||||||
);
|
|
||||||
expect(availableVersion).not.toBeNull();
|
|
||||||
expect(availableVersion.url).toBe(
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_linux-x64_bin.tar.gz'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('getAvailableVersions', () => {
|
|
||||||
it.each([
|
|
||||||
['11', 'x64', 'linux', 71],
|
|
||||||
['11', 'aarch64', 'linux', 54],
|
|
||||||
['17', 'riscv', 'linux', 0],
|
|
||||||
['16.0.1', 'x64', 'linux', 71],
|
|
||||||
['23-ea', 'x64', 'linux', 798],
|
|
||||||
['23-ea', 'aarch64', 'windows', 0],
|
|
||||||
['23-ea', 'x64', 'windows', 750]
|
|
||||||
])(
|
|
||||||
'should get right number of available versions from JSON',
|
|
||||||
async (
|
|
||||||
jdkVersion: string,
|
|
||||||
arch: string,
|
|
||||||
platform: string,
|
|
||||||
len: number
|
|
||||||
) => {
|
|
||||||
const distribution = new SapMachineDistribution({
|
|
||||||
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([
|
|
||||||
[
|
|
||||||
'11',
|
|
||||||
'linux',
|
|
||||||
'x64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.22/sapmachine-jdk-11.0.22_linux-x64_bin.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'11',
|
|
||||||
'linux',
|
|
||||||
'aarch64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.22/sapmachine-jdk-11.0.22_linux-aarch64_bin.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'11',
|
|
||||||
'windows',
|
|
||||||
'x64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.22/sapmachine-jdk-11.0.22_windows-x64_bin.zip'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'11.0.17',
|
|
||||||
'linux',
|
|
||||||
'x64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.17/sapmachine-jdk-11.0.17_linux-x64_bin.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'17',
|
|
||||||
'linux',
|
|
||||||
'x64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_linux-x64_bin.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'17',
|
|
||||||
'linux',
|
|
||||||
'aarch64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_linux-aarch64_bin.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'17',
|
|
||||||
'windows',
|
|
||||||
'x64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_windows-x64_bin.zip'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'17.0.4',
|
|
||||||
'linux',
|
|
||||||
'x64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.4.1/sapmachine-jdk-17.0.4.1_linux-x64_bin.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'17',
|
|
||||||
'linux',
|
|
||||||
'x64',
|
|
||||||
'jre',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jre-17.0.10_linux-x64_bin.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'17',
|
|
||||||
'linux',
|
|
||||||
'aarch64',
|
|
||||||
'jre',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jre-17.0.10_linux-aarch64_bin.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'17',
|
|
||||||
'windows',
|
|
||||||
'x64',
|
|
||||||
'jre',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jre-17.0.10_windows-x64_bin.zip'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'17.0.4',
|
|
||||||
'linux',
|
|
||||||
'x64',
|
|
||||||
'jre',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.4.1/sapmachine-jre-17.0.4.1_linux-x64_bin.tar.gz'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'23-ea',
|
|
||||||
'linux',
|
|
||||||
'x64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-23%2B15/sapmachine-jdk-23-ea.15_linux-x64_bin.tar.gz',
|
|
||||||
'23'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'21.0.2+2-ea',
|
|
||||||
'linux',
|
|
||||||
'x64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-21.0.2%2B2/sapmachine-jdk-21.0.2-ea.2_linux-x64_bin.tar.gz',
|
|
||||||
'21.0.2+2'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'17',
|
|
||||||
'linux-musl',
|
|
||||||
'x64',
|
|
||||||
'jdk',
|
|
||||||
'https://github.com/SAP/SapMachine/releases/download/sapmachine-17.0.10/sapmachine-jdk-17.0.10_linux-x64-musl_bin.tar.gz'
|
|
||||||
]
|
|
||||||
])(
|
|
||||||
'should return proper link according to the specified java-version, platform and arch',
|
|
||||||
async (
|
|
||||||
version: string,
|
|
||||||
platform: string,
|
|
||||||
arch: string,
|
|
||||||
packageType: string,
|
|
||||||
expectedLink: string,
|
|
||||||
normalizedVersion: string = version
|
|
||||||
) => {
|
|
||||||
const distribution = new SapMachineDistribution({
|
|
||||||
version: version,
|
|
||||||
architecture: arch,
|
|
||||||
packageType: packageType,
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
mockPlatform(distribution, platform);
|
|
||||||
|
|
||||||
const availableVersion = await distribution['findPackageForDownload'](
|
|
||||||
normalizedVersion
|
|
||||||
);
|
|
||||||
expect(availableVersion).not.toBeNull();
|
|
||||||
expect(availableVersion.url).toBe(expectedLink);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each([
|
|
||||||
['8', 'linux', 'x64'],
|
|
||||||
['8', 'macos', 'aarch64'],
|
|
||||||
['23', 'macos', 'aarch64'],
|
|
||||||
['17', 'linux', 'riscv'],
|
|
||||||
['23', 'linux', 'x64'],
|
|
||||||
['25-ea', 'linux', 'x64', '25'],
|
|
||||||
['8-ea', 'linux', 'x64', '8'],
|
|
||||||
['21.0.3+7', 'linux', 'x64', '21.0.3+7'],
|
|
||||||
['21.0.3+8-ea', 'linux', 'x64', '21.0.3+8'],
|
|
||||||
['17', 'linux-muse', 'aarch64']
|
|
||||||
])(
|
|
||||||
'should throw when required version of JDK can not be found in the JSON',
|
|
||||||
async (
|
|
||||||
version: string,
|
|
||||||
platform: string,
|
|
||||||
arch: string,
|
|
||||||
normalizedVersion: string = version
|
|
||||||
) => {
|
|
||||||
const distribution = new SapMachineDistribution({
|
|
||||||
version: version,
|
|
||||||
architecture: arch,
|
|
||||||
packageType: 'jdk',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
mockPlatform(distribution, platform);
|
|
||||||
|
|
||||||
await expect(
|
|
||||||
distribution['findPackageForDownload'](normalizedVersion)
|
|
||||||
).rejects.toThrow(
|
|
||||||
`Couldn't find any satisfied version for the specified java-version: "${normalizedVersion}" and architecture: "${arch}".`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it('should throw when required package type is not supported', async () => {
|
|
||||||
const jdkVersion = '17';
|
|
||||||
const arch = 'x64';
|
|
||||||
const platform = 'linux';
|
|
||||||
const distribution = new SapMachineDistribution({
|
|
||||||
version: jdkVersion,
|
|
||||||
architecture: arch,
|
|
||||||
packageType: 'jdk+fx',
|
|
||||||
checkLatest: false
|
|
||||||
});
|
|
||||||
mockPlatform(distribution, platform);
|
|
||||||
await expect(
|
|
||||||
distribution['findPackageForDownload'](jdkVersion)
|
|
||||||
).rejects.toThrow(
|
|
||||||
'SapMachine provides only the `jdk` and `jre` package type'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
221
dist/setup/index.js
vendored
221
dist/setup/index.js
vendored
@ -124049,8 +124049,7 @@ const installer_7 = __nccwpck_require__(41121);
|
|||||||
const installer_8 = __nccwpck_require__(34750);
|
const installer_8 = __nccwpck_require__(34750);
|
||||||
const installer_9 = __nccwpck_require__(64298);
|
const installer_9 = __nccwpck_require__(64298);
|
||||||
const installer_10 = __nccwpck_require__(16132);
|
const installer_10 = __nccwpck_require__(16132);
|
||||||
const installer_11 = __nccwpck_require__(52869);
|
const installer_11 = __nccwpck_require__(45696);
|
||||||
const installer_12 = __nccwpck_require__(45696);
|
|
||||||
var JavaDistribution;
|
var JavaDistribution;
|
||||||
(function (JavaDistribution) {
|
(function (JavaDistribution) {
|
||||||
JavaDistribution["Adopt"] = "adopt";
|
JavaDistribution["Adopt"] = "adopt";
|
||||||
@ -124065,7 +124064,6 @@ var JavaDistribution;
|
|||||||
JavaDistribution["Corretto"] = "corretto";
|
JavaDistribution["Corretto"] = "corretto";
|
||||||
JavaDistribution["Oracle"] = "oracle";
|
JavaDistribution["Oracle"] = "oracle";
|
||||||
JavaDistribution["Dragonwell"] = "dragonwell";
|
JavaDistribution["Dragonwell"] = "dragonwell";
|
||||||
JavaDistribution["SapMachine"] = "sapmachine";
|
|
||||||
JavaDistribution["Kona"] = "kona";
|
JavaDistribution["Kona"] = "kona";
|
||||||
})(JavaDistribution || (JavaDistribution = {}));
|
})(JavaDistribution || (JavaDistribution = {}));
|
||||||
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||||
@ -124093,10 +124091,8 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
|||||||
return new installer_9.OracleDistribution(installerOptions);
|
return new installer_9.OracleDistribution(installerOptions);
|
||||||
case JavaDistribution.Dragonwell:
|
case JavaDistribution.Dragonwell:
|
||||||
return new installer_10.DragonwellDistribution(installerOptions);
|
return new installer_10.DragonwellDistribution(installerOptions);
|
||||||
case JavaDistribution.SapMachine:
|
|
||||||
return new installer_11.SapMachineDistribution(installerOptions);
|
|
||||||
case JavaDistribution.Kona:
|
case JavaDistribution.Kona:
|
||||||
return new installer_12.KonaDistribution(installerOptions);
|
return new installer_11.KonaDistribution(installerOptions);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -125056,219 +125052,6 @@ class OracleDistribution extends base_installer_1.JavaBase {
|
|||||||
exports.OracleDistribution = OracleDistribution;
|
exports.OracleDistribution = OracleDistribution;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 52869:
|
|
||||||
/***/ (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;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
||||||
}
|
|
||||||
Object.defineProperty(o, k2, desc);
|
|
||||||
}) : (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.SapMachineDistribution = void 0;
|
|
||||||
const core = __importStar(__nccwpck_require__(42186));
|
|
||||||
const tc = __importStar(__nccwpck_require__(27784));
|
|
||||||
const semver_1 = __importDefault(__nccwpck_require__(11383));
|
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
|
||||||
const path_1 = __importDefault(__nccwpck_require__(71017));
|
|
||||||
const util_1 = __nccwpck_require__(92629);
|
|
||||||
const base_installer_1 = __nccwpck_require__(59741);
|
|
||||||
class SapMachineDistribution extends base_installer_1.JavaBase {
|
|
||||||
constructor(installerOptions) {
|
|
||||||
super('SapMachine', installerOptions);
|
|
||||||
}
|
|
||||||
findPackageForDownload(version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
core.debug(`Only stable versions: ${this.stable}`);
|
|
||||||
if (!['jdk', 'jre'].includes(this.packageType)) {
|
|
||||||
throw new Error('SapMachine provides only the `jdk` and `jre` package type');
|
|
||||||
}
|
|
||||||
const availableVersions = yield this.getAvailableVersions();
|
|
||||||
const matchedVersions = availableVersions
|
|
||||||
.filter(item => {
|
|
||||||
return (0, util_1.isVersionSatisfies)(version, item.version);
|
|
||||||
})
|
|
||||||
.map(item => {
|
|
||||||
return {
|
|
||||||
version: item.version,
|
|
||||||
url: item.downloadLink
|
|
||||||
};
|
|
||||||
});
|
|
||||||
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 fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json');
|
|
||||||
if (!fetchedReleasesJson) {
|
|
||||||
fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages', (0, util_1.getGitHubHttpHeaders)());
|
|
||||||
}
|
|
||||||
if (!fetchedReleasesJson) {
|
|
||||||
throw new Error(`Couldn't fetch SapMachine versions information from both primary and backup urls`);
|
|
||||||
}
|
|
||||||
core.debug('Successfully fetched information about available SapMachine versions');
|
|
||||||
const availableVersions = this.parseVersions(platform, arch, fetchedReleasesJson);
|
|
||||||
if (core.isDebug()) {
|
|
||||||
core.startGroup('Print information about available versions');
|
|
||||||
core.debug(availableVersions.map(item => item.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 (0, util_1.extractJdkFile)(javaArchivePath, (0, 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, versions) {
|
|
||||||
const eligibleVersions = [];
|
|
||||||
for (const [, majorVersionMap] of Object.entries(versions)) {
|
|
||||||
for (const [, jdkVersionMap] of Object.entries(majorVersionMap.updates)) {
|
|
||||||
for (const [buildVersion, buildVersionMap] of Object.entries(jdkVersionMap)) {
|
|
||||||
let buildVersionWithoutPrefix = buildVersion.replace('sapmachine-', '');
|
|
||||||
if (!buildVersionWithoutPrefix.includes('.')) {
|
|
||||||
// replace major version with major.minor.patch and keep the remaining build identifier after the + as is with regex
|
|
||||||
buildVersionWithoutPrefix = buildVersionWithoutPrefix.replace(/(\d+)(\+.*)?/, '$1.0.0$2');
|
|
||||||
}
|
|
||||||
// replace + with . to convert to semver format if we have more than 3 version digits
|
|
||||||
if (buildVersionWithoutPrefix.split('.').length > 3) {
|
|
||||||
buildVersionWithoutPrefix = buildVersionWithoutPrefix.replace('+', '.');
|
|
||||||
}
|
|
||||||
buildVersionWithoutPrefix = (0, util_1.convertVersionToSemver)(buildVersionWithoutPrefix);
|
|
||||||
// ignore invalid version
|
|
||||||
if (!semver_1.default.valid(buildVersionWithoutPrefix)) {
|
|
||||||
core.debug(`Invalid version: ${buildVersionWithoutPrefix}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// skip earlyAccessVersions if stable version requested
|
|
||||||
if (this.stable && buildVersionMap.ea === 'true') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const [edition, editionAssets] of Object.entries(buildVersionMap.assets)) {
|
|
||||||
if (this.packageType !== edition) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const [archAndPlatForm, archAssets] of Object.entries(editionAssets)) {
|
|
||||||
let expectedArchAndPlatform = `${platform}-${arch}`;
|
|
||||||
if (platform === 'linux-musl') {
|
|
||||||
expectedArchAndPlatform = `linux-${arch}-musl`;
|
|
||||||
}
|
|
||||||
if (archAndPlatForm !== expectedArchAndPlatform) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const [contentType, contentTypeAssets] of Object.entries(archAssets)) {
|
|
||||||
// skip if not tar.gz and zip files
|
|
||||||
if (contentType !== 'tar.gz' && contentType !== 'zip') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
eligibleVersions.push({
|
|
||||||
os: platform,
|
|
||||||
architecture: arch,
|
|
||||||
version: buildVersionWithoutPrefix,
|
|
||||||
checksum: contentTypeAssets.checksum,
|
|
||||||
downloadLink: contentTypeAssets.url,
|
|
||||||
packageType: edition
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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.version;
|
|
||||||
const version2 = versionObj2.version;
|
|
||||||
return semver_1.default.compareBuild(version1, version2);
|
|
||||||
});
|
|
||||||
return sortedVersions.reverse();
|
|
||||||
}
|
|
||||||
getPlatformOption() {
|
|
||||||
switch (process.platform) {
|
|
||||||
case 'win32':
|
|
||||||
return 'windows';
|
|
||||||
case 'darwin':
|
|
||||||
return 'macos';
|
|
||||||
case 'linux':
|
|
||||||
// figure out if alpine/musl
|
|
||||||
if (fs_1.default.existsSync('/etc/alpine-release')) {
|
|
||||||
return 'linux-musl';
|
|
||||||
}
|
|
||||||
return 'linux';
|
|
||||||
default:
|
|
||||||
return process.platform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fetchReleasesFromUrl(url, headers = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
core.debug(`Trying to fetch available SapMachine versions info from the primary url: ${url}`);
|
|
||||||
const releases = (yield this.http.getJson(url, headers)).result;
|
|
||||||
return releases;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
core.debug(`Fetching SapMachine versions info from the link: ${url} ended up with the error: ${err.message}`);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.SapMachineDistribution = SapMachineDistribution;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 41121:
|
/***/ 41121:
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
- [Amazon Corretto](#Amazon-Corretto)
|
- [Amazon Corretto](#Amazon-Corretto)
|
||||||
- [Oracle](#Oracle)
|
- [Oracle](#Oracle)
|
||||||
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
- [Alibaba Dragonwell](#Alibaba-Dragonwell)
|
||||||
- [SapMachine](#SapMachine)
|
|
||||||
- [Tencent Kona](#Tencent-Kona)
|
- [Tencent Kona](#Tencent-Kona)
|
||||||
- [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)
|
||||||
@ -144,20 +143,8 @@ steps:
|
|||||||
- run: java -cp java HelloWorldApp
|
- run: java -cp java HelloWorldApp
|
||||||
```
|
```
|
||||||
|
|
||||||
### SapMachine
|
|
||||||
**NOTE:** An OpenJDK release maintained and supported by SAP
|
|
||||||
```yaml
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: 'sapmachine'
|
|
||||||
java-version: '21'
|
|
||||||
- run: java -cp java HelloWorldApp
|
|
||||||
```
|
|
||||||
|
|
||||||
### Tencent Kona
|
### Tencent Kona
|
||||||
**NOTE:** Tencent Kona supports major versions 8, 11, 17 and 21, and provides jdk only.
|
**NOTE:** Tencent Kona supports major versions 8, 11 and 17, and provides jdk only.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@ -10,7 +10,6 @@ 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';
|
import {DragonwellDistribution} from './dragonwell/installer';
|
||||||
import {SapMachineDistribution} from './sapmachine/installer';
|
|
||||||
import {KonaDistribution} from './kona/installer';
|
import {KonaDistribution} from './kona/installer';
|
||||||
|
|
||||||
enum JavaDistribution {
|
enum JavaDistribution {
|
||||||
@ -26,7 +25,6 @@ enum JavaDistribution {
|
|||||||
Corretto = 'corretto',
|
Corretto = 'corretto',
|
||||||
Oracle = 'oracle',
|
Oracle = 'oracle',
|
||||||
Dragonwell = 'dragonwell',
|
Dragonwell = 'dragonwell',
|
||||||
SapMachine = 'sapmachine',
|
|
||||||
Kona = 'kona'
|
Kona = 'kona'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +66,6 @@ export function getJavaDistribution(
|
|||||||
return new OracleDistribution(installerOptions);
|
return new OracleDistribution(installerOptions);
|
||||||
case JavaDistribution.Dragonwell:
|
case JavaDistribution.Dragonwell:
|
||||||
return new DragonwellDistribution(installerOptions);
|
return new DragonwellDistribution(installerOptions);
|
||||||
case JavaDistribution.SapMachine:
|
|
||||||
return new SapMachineDistribution(installerOptions);
|
|
||||||
case JavaDistribution.Kona:
|
case JavaDistribution.Kona:
|
||||||
return new KonaDistribution(installerOptions);
|
return new KonaDistribution(installerOptions);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -1,268 +0,0 @@
|
|||||||
import * as core from '@actions/core';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
|
||||||
import semver from 'semver';
|
|
||||||
import fs from 'fs';
|
|
||||||
import {OutgoingHttpHeaders} from 'http';
|
|
||||||
import path from 'path';
|
|
||||||
import {
|
|
||||||
convertVersionToSemver,
|
|
||||||
extractJdkFile,
|
|
||||||
getDownloadArchiveExtension,
|
|
||||||
getGitHubHttpHeaders,
|
|
||||||
isVersionSatisfies
|
|
||||||
} from '../../util';
|
|
||||||
import {JavaBase} from '../base-installer';
|
|
||||||
import {
|
|
||||||
JavaDownloadRelease,
|
|
||||||
JavaInstallerOptions,
|
|
||||||
JavaInstallerResults
|
|
||||||
} from '../base-models';
|
|
||||||
import {ISapMachineAllVersions, ISapMachineVersions} from './models';
|
|
||||||
|
|
||||||
export class SapMachineDistribution extends JavaBase {
|
|
||||||
constructor(installerOptions: JavaInstallerOptions) {
|
|
||||||
super('SapMachine', installerOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async findPackageForDownload(
|
|
||||||
version: string
|
|
||||||
): Promise<JavaDownloadRelease> {
|
|
||||||
core.debug(`Only stable versions: ${this.stable}`);
|
|
||||||
|
|
||||||
if (!['jdk', 'jre'].includes(this.packageType)) {
|
|
||||||
throw new Error(
|
|
||||||
'SapMachine provides only the `jdk` and `jre` package type'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const availableVersions = await this.getAvailableVersions();
|
|
||||||
|
|
||||||
const matchedVersions = availableVersions
|
|
||||||
.filter(item => {
|
|
||||||
return isVersionSatisfies(version, item.version);
|
|
||||||
})
|
|
||||||
.map(item => {
|
|
||||||
return {
|
|
||||||
version: item.version,
|
|
||||||
url: item.downloadLink
|
|
||||||
} 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<ISapMachineVersions[]> {
|
|
||||||
const platform = this.getPlatformOption();
|
|
||||||
const arch = this.distributionArchitecture();
|
|
||||||
|
|
||||||
let fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
|
||||||
'https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!fetchedReleasesJson) {
|
|
||||||
fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
|
||||||
'https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages',
|
|
||||||
getGitHubHttpHeaders()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fetchedReleasesJson) {
|
|
||||||
throw new Error(
|
|
||||||
`Couldn't fetch SapMachine versions information from both primary and backup urls`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
core.debug(
|
|
||||||
'Successfully fetched information about available SapMachine versions'
|
|
||||||
);
|
|
||||||
|
|
||||||
const availableVersions = this.parseVersions(
|
|
||||||
platform,
|
|
||||||
arch,
|
|
||||||
fetchedReleasesJson
|
|
||||||
);
|
|
||||||
|
|
||||||
if (core.isDebug()) {
|
|
||||||
core.startGroup('Print information about available versions');
|
|
||||||
core.debug(availableVersions.map(item => item.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,
|
|
||||||
versions: ISapMachineAllVersions
|
|
||||||
): ISapMachineVersions[] {
|
|
||||||
const eligibleVersions: ISapMachineVersions[] = [];
|
|
||||||
|
|
||||||
for (const [, majorVersionMap] of Object.entries(versions)) {
|
|
||||||
for (const [, jdkVersionMap] of Object.entries(majorVersionMap.updates)) {
|
|
||||||
for (const [buildVersion, buildVersionMap] of Object.entries(
|
|
||||||
jdkVersionMap
|
|
||||||
)) {
|
|
||||||
let buildVersionWithoutPrefix = buildVersion.replace(
|
|
||||||
'sapmachine-',
|
|
||||||
''
|
|
||||||
);
|
|
||||||
if (!buildVersionWithoutPrefix.includes('.')) {
|
|
||||||
// replace major version with major.minor.patch and keep the remaining build identifier after the + as is with regex
|
|
||||||
buildVersionWithoutPrefix = buildVersionWithoutPrefix.replace(
|
|
||||||
/(\d+)(\+.*)?/,
|
|
||||||
'$1.0.0$2'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// replace + with . to convert to semver format if we have more than 3 version digits
|
|
||||||
if (buildVersionWithoutPrefix.split('.').length > 3) {
|
|
||||||
buildVersionWithoutPrefix = buildVersionWithoutPrefix.replace(
|
|
||||||
'+',
|
|
||||||
'.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
buildVersionWithoutPrefix = convertVersionToSemver(
|
|
||||||
buildVersionWithoutPrefix
|
|
||||||
);
|
|
||||||
|
|
||||||
// ignore invalid version
|
|
||||||
if (!semver.valid(buildVersionWithoutPrefix)) {
|
|
||||||
core.debug(`Invalid version: ${buildVersionWithoutPrefix}`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// skip earlyAccessVersions if stable version requested
|
|
||||||
if (this.stable && buildVersionMap.ea === 'true') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const [edition, editionAssets] of Object.entries(
|
|
||||||
buildVersionMap.assets
|
|
||||||
)) {
|
|
||||||
if (this.packageType !== edition) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const [archAndPlatForm, archAssets] of Object.entries(
|
|
||||||
editionAssets
|
|
||||||
)) {
|
|
||||||
let expectedArchAndPlatform = `${platform}-${arch}`;
|
|
||||||
if (platform === 'linux-musl') {
|
|
||||||
expectedArchAndPlatform = `linux-${arch}-musl`;
|
|
||||||
}
|
|
||||||
if (archAndPlatForm !== expectedArchAndPlatform) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const [contentType, contentTypeAssets] of Object.entries(
|
|
||||||
archAssets
|
|
||||||
)) {
|
|
||||||
// skip if not tar.gz and zip files
|
|
||||||
if (contentType !== 'tar.gz' && contentType !== 'zip') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
eligibleVersions.push({
|
|
||||||
os: platform,
|
|
||||||
architecture: arch,
|
|
||||||
version: buildVersionWithoutPrefix,
|
|
||||||
checksum: contentTypeAssets.checksum,
|
|
||||||
downloadLink: contentTypeAssets.url,
|
|
||||||
packageType: edition
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const sortedVersions = this.sortParsedVersions(eligibleVersions);
|
|
||||||
|
|
||||||
return sortedVersions;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sorts versions in descending order as by default data in JSON isn't sorted
|
|
||||||
private sortParsedVersions(
|
|
||||||
eligibleVersions: ISapMachineVersions[]
|
|
||||||
): ISapMachineVersions[] {
|
|
||||||
const sortedVersions = eligibleVersions.sort((versionObj1, versionObj2) => {
|
|
||||||
const version1 = versionObj1.version;
|
|
||||||
const version2 = versionObj2.version;
|
|
||||||
return semver.compareBuild(version1, version2);
|
|
||||||
});
|
|
||||||
return sortedVersions.reverse();
|
|
||||||
}
|
|
||||||
|
|
||||||
private getPlatformOption(): string {
|
|
||||||
switch (process.platform) {
|
|
||||||
case 'win32':
|
|
||||||
return 'windows';
|
|
||||||
case 'darwin':
|
|
||||||
return 'macos';
|
|
||||||
case 'linux':
|
|
||||||
// figure out if alpine/musl
|
|
||||||
if (fs.existsSync('/etc/alpine-release')) {
|
|
||||||
return 'linux-musl';
|
|
||||||
}
|
|
||||||
return 'linux';
|
|
||||||
default:
|
|
||||||
return process.platform;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async fetchReleasesFromUrl(
|
|
||||||
url: string,
|
|
||||||
headers: OutgoingHttpHeaders = {}
|
|
||||||
): Promise<ISapMachineAllVersions | null> {
|
|
||||||
try {
|
|
||||||
core.debug(
|
|
||||||
`Trying to fetch available SapMachine versions info from the primary url: ${url}`
|
|
||||||
);
|
|
||||||
const releases = (
|
|
||||||
await this.http.getJson<ISapMachineAllVersions>(url, headers)
|
|
||||||
).result;
|
|
||||||
return releases;
|
|
||||||
} catch (err) {
|
|
||||||
core.debug(
|
|
||||||
`Fetching SapMachine versions info from the link: ${url} ended up with the error: ${
|
|
||||||
(err as Error).message
|
|
||||||
}`
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
export interface ISapMachineAllVersions {
|
|
||||||
[major: string]: {
|
|
||||||
lts: string;
|
|
||||||
updates: {
|
|
||||||
[full_version: string]: {
|
|
||||||
[sapmachineBuild: string]: {
|
|
||||||
release_url: string;
|
|
||||||
ea: string;
|
|
||||||
assets: {
|
|
||||||
[packageType: string]: {
|
|
||||||
[arch: string]: {
|
|
||||||
[content_type: string]: {
|
|
||||||
name: string;
|
|
||||||
checksum: string;
|
|
||||||
url: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ISapMachineVersions {
|
|
||||||
os: string;
|
|
||||||
architecture: string;
|
|
||||||
version: string;
|
|
||||||
checksum: string;
|
|
||||||
downloadLink: string;
|
|
||||||
packageType: string;
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user