Compare commits

..

7 Commits

Author SHA1 Message Date
Gregory Mitchell
7a6d8a8234 Add Support for JetBrains Runtime (#637)
* Add Support for JetBrains Runtime

- Add Installer, Models
- Includes Tests & Test Manifest Data
- Add to `e2e-versions.yml`
- Run `npm run build`
- Update README.md

* Add Docs + Distro Factory

* Fix Runtime Unrecognizable

* `npm run build` (JBR)

* Fix Incorrect JBR Distribution

* Switch to `jbrsdk_jcef`

* Fix Incorrect File Extension

* `npm run build` (JBR)

* Fix Windows Support

* Add `GITHUB_TOKEN` Authentication

* Update Authorization, Add Documentation

* Fix PR Issues

- Fix JDK 11 URL Bug
- Add JDK URL Testing to ensure versions can be downloaded
- Run Prettier

* Change Distribution to \`jbrsdk\`

* Don't Replace Underscores

* Fix `semver` not resolving correctly

* Update e2e-versions.yml

- Add `GITHUB_TOKEN` environment variable for JetBrains requests
- Add `jetbrains` to other E2E tests

* `npm run format`

* Fix Format, Inaccessible URLs

* Update Tests

* Fix Broken URLs, Add Additional Package Types

* `npm run build`

* Fix JetBrains Tests, Issues in `e2e-versions.yml`

* Add Hidden JDK 11 Versions

* Update `jetbrains-installer` Tests

* Add Notices in Documentation

* Fix Documentation

* Run `npm audit fix`

* Fix Tests on Windows
2024-12-12 16:21:52 -06:00
mahabaleshwars
7136edc5e8 Fix sbt and x86 CI failures on Ubuntu-24 (#693)
* updated workflows with ubuntu 24.04 runner

* added workflow_dispatch to test workflows

* updated workflow to ubnutu 22.04

* Updated workflows for PR

* workflows updated to ubuntu-latest

* Audit fixes
2024-12-10 22:04:58 -06:00
John Wesley Walker III
8df1039502 Refine isGhes logic (#697) 2024-10-21 19:57:52 +02:00
mahabaleshwars
870c199c48 Update workflows for GraalVM and Version Enhancements (#699)
* workflow update graalvm version

* updated workflow for publish action version update
2024-10-21 11:43:20 -05:00
Priya Gupta
83a06ff9d9 Fix Windows archives extraction issue (#689) 2024-10-10 16:32:25 -05:00
Joel Ambass
292cc14be8 Merge pull request #686 from actions/Jcambass-patch-1
Upgrade IA Publish
2024-09-26 08:24:15 +02:00
Joel Ambass
68b1d5a3da Upgrade IA Publish 2024-09-16 17:19:52 +02:00
27 changed files with 2414 additions and 126 deletions

View File

@@ -121,7 +121,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [macos-13, windows-latest, ubuntu-latest] os: [macos-13, windows-latest, ubuntu-22.04]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -170,7 +170,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [macos-13, windows-latest, ubuntu-latest] os: [macos-13, windows-latest, ubuntu-22.04]
needs: sbt-save needs: sbt-save
steps: steps:
- name: Checkout - name: Checkout

View File

@@ -31,7 +31,8 @@ jobs:
'semeru', 'semeru',
'corretto', 'corretto',
'dragonwell', 'dragonwell',
'sapmachine' 'sapmachine',
'jetbrains'
] # internally 'adopt-hotspot' is the same as 'adopt' ] # internally 'adopt-hotspot' is the same as 'adopt'
version: ['21', '11', '17'] version: ['21', '11', '17']
exclude: exclude:
@@ -51,7 +52,7 @@ jobs:
version: 21 version: 21
- distribution: graalvm - distribution: graalvm
os: macos-latest os: macos-latest
version: 17 version: 17.0.12
- distribution: graalvm - distribution: graalvm
os: windows-latest os: windows-latest
version: 21 version: 21
@@ -70,6 +71,8 @@ jobs:
with: with:
java-version: ${{ matrix.version }} java-version: ${{ matrix.version }}
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify Java - name: Verify Java
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
@@ -103,6 +106,12 @@ jobs:
- distribution: sapmachine - distribution: sapmachine
os: ubuntu-latest os: ubuntu-latest
version: '17.0.7' version: '17.0.7'
- distribution: jetbrains
os: ubuntu-latest
version: '11.0.11'
- distribution: jetbrains
os: ubuntu-latest
version: '17.0.7'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -115,6 +124,8 @@ jobs:
- name: Verify Java - name: Verify Java
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
setup-java-check-latest: setup-java-check-latest:
name: ${{ matrix.distribution }} ${{ matrix.version }} - check-latest flag - ${{ matrix.os }} name: ${{ matrix.distribution }} ${{ matrix.version }} - check-latest flag - ${{ matrix.os }}
@@ -125,7 +136,14 @@ jobs:
matrix: matrix:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
distribution: distribution:
['temurin', 'zulu', 'liberica', 'dragonwell', 'sapmachine'] [
'temurin',
'zulu',
'liberica',
'dragonwell',
'sapmachine',
'jetbrains'
]
exclude: exclude:
- distribution: dragonwell - distribution: dragonwell
os: macos-latest os: macos-latest
@@ -139,6 +157,8 @@ jobs:
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
java-version: 11 java-version: 11
check-latest: true check-latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify Java - name: Verify Java
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
shell: bash shell: bash
@@ -152,7 +172,14 @@ jobs:
matrix: matrix:
os: [macos-latest, windows-latest, ubuntu-latest] os: [macos-latest, windows-latest, ubuntu-latest]
distribution: distribution:
['temurin', 'zulu', 'liberica', 'dragonwell', 'sapmachine'] [
'temurin',
'zulu',
'liberica',
'dragonwell',
'sapmachine',
'jetbrains'
]
exclude: exclude:
- distribution: dragonwell - distribution: dragonwell
os: macos-latest os: macos-latest
@@ -167,6 +194,8 @@ jobs:
java-version: | java-version: |
11 11
17 17
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify Java env variables - name: Verify Java env variables
run: | run: |
$versionsArr = "11","17" $versionsArr = "11","17"
@@ -258,7 +287,8 @@ 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', 'sapmachine', 'jetbrains']
java-package: ['jre'] java-package: ['jre']
version: ['17.0'] version: ['17.0']
include: include:
@@ -282,6 +312,47 @@ jobs:
java-package: jre java-package: jre
version: '8' version: '8'
os: windows-latest os: windows-latest
- distribution: 'jetbrains'
java-package: jdk+jcef
version: '11'
os: ubuntu-latest
- distribution: 'jetbrains'
java-package: jdk+jcef
version: '17'
os: ubuntu-latest
- distribution: 'jetbrains'
java-package: jdk+jcef
version: '21'
os: ubuntu-latest
- distribution: 'jetbrains'
java-package: jre+jcef
version: '11'
os: ubuntu-latest
- distribution: 'jetbrains'
java-package: jre+jcef
version: '17'
os: ubuntu-latest
- distribution: 'jetbrains'
java-package: jre+jcef
version: '21'
os: ubuntu-latest
- distribution: 'jetbrains'
java-package: jdk+ft
version: '17'
os: ubuntu-latest
- distribution: 'jetbrains'
java-package: jdk+ft
version: '21'
os: ubuntu-latest
- distribution: 'jetbrains'
java-package: jre+ft
version: '17'
os: ubuntu-latest
- distribution: 'jetbrains'
java-package: jre+ft
version: '21'
os: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -292,6 +363,8 @@ jobs:
java-version: ${{ matrix.version }} java-version: ${{ matrix.version }}
java-package: ${{ matrix.java-package }} java-package: ${{ matrix.java-package }}
distribution: ${{ matrix.distribution }} distribution: ${{ matrix.distribution }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify Java - name: Verify Java
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
@@ -305,7 +378,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
# x86 is not supported on macOS # x86 is not supported on macOS
os: [windows-latest, ubuntu-latest] os: [windows-latest, ubuntu-22.04]
distribution: ['liberica', 'zulu', 'corretto'] distribution: ['liberica', 'zulu', 'corretto']
version: ['11'] version: ['11']
steps: steps:

View File

@@ -2,7 +2,7 @@ name: 'Publish Immutable Action Version'
on: on:
release: release:
types: [created] types: [published]
jobs: jobs:
publish: publish:
@@ -17,6 +17,4 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Publish - name: Publish
id: publish id: publish
uses: actions/publish-immutable-action@0.0.1 uses: actions/publish-immutable-action@0.0.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -23,7 +23,7 @@ jobs:
steps: steps:
- name: Update the ${{ env.TAG_NAME }} tag - name: Update the ${{ env.TAG_NAME }} tag
id: update-major-tag id: update-major-tag
uses: actions/publish-action@v0.2.2 uses: actions/publish-action@v0.3.0
with: with:
source-tag: ${{ env.TAG_NAME }} source-tag: ${{ env.TAG_NAME }}
slack-webhook: ${{ secrets.SLACK_WEBHOOK }} slack-webhook: ${{ secrets.SLACK_WEBHOOK }}

View File

@@ -110,6 +110,7 @@ Currently, the following distributions are supported:
| `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) | `sapmachine` | SAP SapMachine JDK/JRE | [Link](https://sapmachine.io/) | [Link](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
| `graalvm` | Oracle GraalVM | [Link](https://www.graalvm.org/) | [Link](https://www.oracle.com/downloads/licenses/graal-free-license.html) | `graalvm` | Oracle GraalVM | [Link](https://www.graalvm.org/) | [Link](https://www.oracle.com/downloads/licenses/graal-free-license.html)
| `jetbrains` | JetBrains Runtime | [Link](https://github.com/JetBrains/JetBrainsRuntime/) | [Link](https://github.com/JetBrains/JetBrainsRuntime/blob/main/LICENSE)
**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.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,120 @@
import https from 'https';
import {HttpClient} from '@actions/http-client';
import {JetBrainsDistribution} from '../../src/distributions/jetbrains/installer';
import manifestData from '../data/jetbrains.json';
import os from 'os';
describe('getAvailableVersions', () => {
let spyHttpClient: jest.SpyInstance;
beforeEach(() => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValue({
statusCode: 200,
headers: {},
result: []
});
});
afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
});
it('load available versions', async () => {
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
spyHttpClient.mockReturnValueOnce({
statusCode: 200,
headers: {},
result: manifestData as any
});
const distribution = new JetBrainsDistribution({
version: '17',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
const availableVersions = await distribution['getAvailableVersions']();
expect(availableVersions).not.toBeNull();
const length =
os.platform() === 'win32'
? manifestData.length - 1
: manifestData.length + 1;
expect(availableVersions.length).toBe(length);
}, 10_000);
});
describe('findPackageForDownload', () => {
it.each([
['17', '17.0.11+1207.24'],
['11.0', '11.0.16+2043.64'],
['11.0.11', '11.0.11+1542.1'],
['21.0.2', '21.0.2+375.1'],
['21', '21.0.3+465.3'],
['x', '21.0.3+465.3']
])('version is resolved correctly %s -> %s', async (input, expected) => {
const distribution = new JetBrainsDistribution({
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload'](input);
expect(resolvedVersion.version).toBe(expected);
});
it.each(['17', '11.0', '11.0.11', '21.0.2', '21'])(
'version %s can be downloaded',
async input => {
const distribution = new JetBrainsDistribution({
version: input,
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
const resolvedVersion = await distribution['findPackageForDownload'](
input
);
const url = resolvedVersion.url;
const options = {method: 'HEAD'};
https.request(url, options, res => {
// JetBrains uses 403 for inexistent packages
expect(res.statusCode).not.toBe(403);
res.resume();
});
}
);
it('version is not found', async () => {
const distribution = new JetBrainsDistribution({
version: '8.0.452',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => manifestData as any;
await expect(distribution['findPackageForDownload']('8.x')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});
it('version list is empty', async () => {
const distribution = new JetBrainsDistribution({
version: '8',
architecture: 'x64',
packageType: 'jdk',
checkLatest: false
});
distribution['getAvailableVersions'] = async () => [];
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
/Could not find satisfied version for SemVer */
);
});
});

View File

@@ -3,7 +3,8 @@ import * as core from '@actions/core';
import { import {
convertVersionToSemver, convertVersionToSemver,
isVersionSatisfies, isVersionSatisfies,
isCacheFeatureAvailable isCacheFeatureAvailable,
isGhes
} from '../src/util'; } from '../src/util';
jest.mock('@actions/cache'); jest.mock('@actions/cache');
@@ -80,3 +81,41 @@ describe('convertVersionToSemver', () => {
expect(actual).toBe(expected); expect(actual).toBe(expected);
}); });
}); });
describe('isGhes', () => {
const pristineEnv = process.env;
beforeEach(() => {
jest.resetModules();
process.env = {...pristineEnv};
});
afterAll(() => {
process.env = pristineEnv;
});
it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => {
delete process.env['GITHUB_SERVER_URL'];
expect(isGhes()).toBeFalsy();
});
it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => {
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
expect(isGhes()).toBeFalsy();
});
it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => {
process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com';
expect(isGhes()).toBeFalsy();
});
it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => {
process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost';
expect(isGhes()).toBeFalsy();
});
it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => {
process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com';
expect(isGhes()).toBeTruthy();
});
});

19
dist/cleanup/index.js vendored
View File

@@ -88470,7 +88470,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.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; exports.renameWinArchive = exports.getGitHubHttpHeaders = exports.convertVersionToSemver = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
const os_1 = __importDefault(__nccwpck_require__(2037)); const os_1 = __importDefault(__nccwpck_require__(2037));
const path_1 = __importDefault(__nccwpck_require__(1017)); const path_1 = __importDefault(__nccwpck_require__(1017));
const fs = __importStar(__nccwpck_require__(7147)); const fs = __importStar(__nccwpck_require__(7147));
@@ -88552,7 +88552,11 @@ function isJobStatusSuccess() {
exports.isJobStatusSuccess = isJobStatusSuccess; exports.isJobStatusSuccess = isJobStatusSuccess;
function isGhes() { function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase();
const isGitHubHost = hostname === 'GITHUB.COM';
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
const isLocalHost = hostname.endsWith('.LOCALHOST');
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
} }
exports.isGhes = isGhes; exports.isGhes = isGhes;
function isCacheFeatureAvailable() { function isCacheFeatureAvailable() {
@@ -88630,6 +88634,17 @@ function getGitHubHttpHeaders() {
return headers; return headers;
} }
exports.getGitHubHttpHeaders = getGitHubHttpHeaders; exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
// Rename archive to add extension because after downloading
// archive does not contain extension type and it leads to some issues
// on Windows runners without PowerShell Core.
//
// For default PowerShell Windows it should contain extension type to unpack it.
function renameWinArchive(javaArchivePath) {
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
fs.renameSync(javaArchivePath, javaArchivePathRenamed);
return javaArchivePathRenamed;
}
exports.renameWinArchive = renameWinArchive;
/***/ }), /***/ }),

325
dist/setup/index.js vendored
View File

@@ -123578,9 +123578,12 @@ class AdoptDistribution extends base_installer_1.JavaBase {
downloadTool(javaRelease) { downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = (0, util_1.getDownloadArchiveExtension)(); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32') {
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
}
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
@@ -123914,9 +123917,13 @@ class CorrettoDistribution extends base_installer_1.JavaBase {
downloadTool(javaRelease) { downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)()); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32') {
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
}
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
const version = this.getToolcacheVersionName(javaRelease.version); const version = this.getToolcacheVersionName(javaRelease.version);
@@ -124051,6 +124058,7 @@ 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__(52869);
const installer_12 = __nccwpck_require__(55644); const installer_12 = __nccwpck_require__(55644);
const installer_13 = __nccwpck_require__(12634);
var JavaDistribution; var JavaDistribution;
(function (JavaDistribution) { (function (JavaDistribution) {
JavaDistribution["Adopt"] = "adopt"; JavaDistribution["Adopt"] = "adopt";
@@ -124067,6 +124075,7 @@ var JavaDistribution;
JavaDistribution["Dragonwell"] = "dragonwell"; JavaDistribution["Dragonwell"] = "dragonwell";
JavaDistribution["SapMachine"] = "sapmachine"; JavaDistribution["SapMachine"] = "sapmachine";
JavaDistribution["GraalVM"] = "graalvm"; JavaDistribution["GraalVM"] = "graalvm";
JavaDistribution["JetBrains"] = "jetbrains";
})(JavaDistribution || (JavaDistribution = {})); })(JavaDistribution || (JavaDistribution = {}));
function getJavaDistribution(distributionName, installerOptions, jdkFile) { function getJavaDistribution(distributionName, installerOptions, jdkFile) {
switch (distributionName) { switch (distributionName) {
@@ -124097,6 +124106,8 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
return new installer_11.SapMachineDistribution(installerOptions); return new installer_11.SapMachineDistribution(installerOptions);
case JavaDistribution.GraalVM: case JavaDistribution.GraalVM:
return new installer_12.GraalVMDistribution(installerOptions); return new installer_12.GraalVMDistribution(installerOptions);
case JavaDistribution.JetBrains:
return new installer_13.JetBrainsDistribution(installerOptions);
default: default:
return null; return null;
} }
@@ -124209,9 +124220,13 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
downloadTool(javaRelease) { downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)()); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32') {
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
}
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
const version = this.getToolcacheVersionName(javaRelease.version); const version = this.getToolcacheVersionName(javaRelease.version);
@@ -124375,9 +124390,12 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
downloadTool(javaRelease) { downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = (0, util_1.getDownloadArchiveExtension)(); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32') {
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
}
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
@@ -124480,6 +124498,231 @@ class GraalVMDistribution extends base_installer_1.JavaBase {
exports.GraalVMDistribution = GraalVMDistribution; exports.GraalVMDistribution = GraalVMDistribution;
/***/ }),
/***/ 12634:
/***/ (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.JetBrainsDistribution = void 0;
const core = __importStar(__nccwpck_require__(42186));
const tc = __importStar(__nccwpck_require__(27784));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const path_1 = __importDefault(__nccwpck_require__(71017));
const semver_1 = __importDefault(__nccwpck_require__(11383));
const base_installer_1 = __nccwpck_require__(59741);
const util_1 = __nccwpck_require__(92629);
const http_client_1 = __nccwpck_require__(96255);
class JetBrainsDistribution extends base_installer_1.JavaBase {
constructor(installerOptions) {
super('JetBrains', installerOptions);
}
findPackageForDownload(range) {
return __awaiter(this, void 0, void 0, function* () {
const versionsRaw = yield this.getAvailableVersions();
const versions = versionsRaw.map(v => {
const formattedVersion = `${v.semver}+${v.build}`;
return {
version: formattedVersion,
url: v.url
};
});
const satisfiedVersions = versions
.filter(item => (0, util_1.isVersionSatisfies)(range, item.version))
.sort((a, b) => {
return -semver_1.default.compareBuild(a.version, b.version);
});
const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
if (!resolvedFullVersion) {
const availableOptions = versionsRaw
.map(item => `${item.tag_name} (${item.semver}+${item.build})`)
.join(', ');
const availableOptionsMessage = availableOptions
? `\nAvailable versions: ${availableOptions}`
: '';
throw new Error(`Could not find satisfied version for SemVer '${range}'. ${availableOptionsMessage}`);
}
return resolvedFullVersion;
});
}
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, 'tar.gz');
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 };
});
}
getAvailableVersions() {
return __awaiter(this, void 0, void 0, function* () {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
if (core.isDebug()) {
console.time('Retrieving available versions for JBR took'); // eslint-disable-line no-console
}
// need to iterate through all pages to retrieve the list of all versions
// GitHub API doesn't provide way to retrieve the count of pages to iterate so infinity loop
let page_index = 1;
const rawVersions = [];
const bearerToken = process.env.GITHUB_TOKEN;
while (true) {
const requestArguments = `per_page=100&page=${page_index}`;
const requestHeaders = {};
if (bearerToken) {
requestHeaders['Authorization'] = `Bearer ${bearerToken}`;
}
const rawUrl = `https://api.github.com/repos/JetBrains/JetBrainsRuntime/releases?${requestArguments}`;
if (core.isDebug() && page_index === 1) {
// url is identical except page_index so print it once for debug
core.debug(`Gathering available versions from '${rawUrl}'`);
}
const paginationPage = (yield this.http.getJson(rawUrl, requestHeaders)).result;
if (!paginationPage || paginationPage.length === 0) {
// break infinity loop because we have reached end of pagination
break;
}
rawVersions.push(...paginationPage);
page_index++;
}
// Add versions not available from the API but are downloadable
const hidden = ['11_0_10b1145.115', '11_0_11b1341.60'];
rawVersions.push(...hidden.map(tag => ({ tag_name: tag, name: tag })));
const versions0 = rawVersions.map((v) => __awaiter(this, void 0, void 0, function* () {
var _a;
// Release tags look like one of these:
// jbr-release-21.0.3b465.3
// jbr17-b87.7
// jb11_0_11-b87.7
// jbr11_0_15b2043.56
// 11_0_11b1536.2
// 11_0_11-b1522
const tag = v.tag_name;
// Extract version string
const vstring = tag
.replace('jbr-release-', '')
.replace('jbr', '')
.replace('jb', '')
.replace('-', '');
const vsplit = vstring.split('b');
let semver = vsplit[0];
const build = +vsplit[1];
// Normalize semver
if (!semver.includes('.') && !semver.includes('_'))
semver = `${semver}.0.0`;
// Construct URL
let type;
switch ((_a = this.packageType) !== null && _a !== void 0 ? _a : '') {
case 'jre':
type = 'jbr';
break;
case 'jdk+jcef':
type = 'jbrsdk_jcef';
break;
case 'jre+jcef':
type = 'jbr_jcef';
break;
case 'jdk+ft':
type = 'jbrsdk_ft';
break;
case 'jre+ft':
type = 'jbr_ft';
break;
default:
type = 'jbrsdk';
break;
}
let url = `https://cache-redirector.jetbrains.com/intellij-jbr/${type}-${semver}-${platform}-${arch}-b${build}.tar.gz`;
let include = false;
const res = yield this.http.head(url);
if (res.message.statusCode === http_client_1.HttpCodes.OK) {
include = true;
}
else {
url = `https://cache-redirector.jetbrains.com/intellij-jbr/${type}_nomod-${semver}-${platform}-${arch}-b${build}.tar.gz`;
const res2 = yield this.http.head(url);
if (res2.message.statusCode === http_client_1.HttpCodes.OK) {
include = true;
}
}
const version = {
tag_name: tag,
semver: semver.replace(/_/g, '.'),
build: build,
url: url
};
return {
item: version,
include: include
};
}));
const versions = yield Promise.all(versions0).then(res => res.filter(item => item.include).map(item => item.item));
if (core.isDebug()) {
core.startGroup('Print information about available versions');
console.timeEnd('Retrieving available versions for JBR took'); // eslint-disable-line no-console
core.debug(`Available versions: [${versions.length}]`);
core.debug(versions.map(item => item.semver).join(', '));
core.endGroup();
}
return versions;
});
}
getPlatformOption() {
// Jetbrains has own platform names so need to map them
switch (process.platform) {
case 'darwin':
return 'osx';
case 'win32':
return 'windows';
default:
return process.platform;
}
}
}
exports.JetBrainsDistribution = JetBrainsDistribution;
/***/ }), /***/ }),
/***/ 40883: /***/ 40883:
@@ -124543,11 +124786,8 @@ class LibericaDistributions extends base_installer_1.JavaBase {
let javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = (0, util_1.getDownloadArchiveExtension)(); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32' && if (process.platform === 'win32') {
(this.architecture === 'arm64' || this.architecture === 'aarch64')) { javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed);
javaArchivePath = javaArchivePathRenamed;
} }
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
@@ -124829,19 +125069,11 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
let javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
// Rename archive to add extension because after downloading
// archive does not contain extension type and it leads to some issues
// on Windows runners without PowerShell Core.
//
// For default PowerShell Windows it should contain extension type to unpack it.
if (process.platform === 'win32' &&
(this.architecture === 'arm64' || this.architecture === 'aarch64')) {
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed);
javaArchivePath = javaArchivePathRenamed;
}
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = (0, util_1.getDownloadArchiveExtension)(); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32') {
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
}
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
@@ -124978,9 +125210,12 @@ class OracleDistribution extends base_installer_1.JavaBase {
downloadTool(javaRelease) { downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = (0, util_1.getDownloadArchiveExtension)(); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32') {
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
}
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
@@ -125151,9 +125386,13 @@ class SapMachineDistribution extends base_installer_1.JavaBase {
downloadTool(javaRelease) { downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, (0, util_1.getDownloadArchiveExtension)()); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32') {
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
}
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
const version = this.getToolcacheVersionName(javaRelease.version); const version = this.getToolcacheVersionName(javaRelease.version);
@@ -125370,9 +125609,12 @@ class SemeruDistribution extends base_installer_1.JavaBase {
downloadTool(javaRelease) { downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = (0, util_1.getDownloadArchiveExtension)(); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32') {
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
}
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
@@ -125546,9 +125788,12 @@ class TemurinDistribution extends base_installer_1.JavaBase {
downloadTool(javaRelease) { downloadTool(javaRelease) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
const javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = (0, util_1.getDownloadArchiveExtension)(); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32') {
javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
}
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
const archivePath = path_1.default.join(extractedJavaPath, archiveName); const archivePath = path_1.default.join(extractedJavaPath, archiveName);
@@ -125724,11 +125969,8 @@ class ZuluDistribution extends base_installer_1.JavaBase {
let javaArchivePath = yield tc.downloadTool(javaRelease.url); let javaArchivePath = yield tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = (0, util_1.getDownloadArchiveExtension)(); const extension = (0, util_1.getDownloadArchiveExtension)();
if (process.platform === 'win32' && if (process.platform === 'win32') {
(this.architecture === 'arm64' || this.architecture === 'aarch64')) { javaArchivePath = (0, util_1.renameWinArchive)(javaArchivePath);
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
yield fs_1.default.renameSync(javaArchivePath, javaArchivePathRenamed);
javaArchivePath = javaArchivePathRenamed;
} }
const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension); const extractedJavaPath = yield (0, util_1.extractJdkFile)(javaArchivePath, extension);
const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0];
@@ -126233,7 +126475,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.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; exports.renameWinArchive = 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__(22037)); const os_1 = __importDefault(__nccwpck_require__(22037));
const path_1 = __importDefault(__nccwpck_require__(71017)); const path_1 = __importDefault(__nccwpck_require__(71017));
const fs = __importStar(__nccwpck_require__(57147)); const fs = __importStar(__nccwpck_require__(57147));
@@ -126315,7 +126557,11 @@ function isJobStatusSuccess() {
exports.isJobStatusSuccess = isJobStatusSuccess; exports.isJobStatusSuccess = isJobStatusSuccess;
function isGhes() { function isGhes() {
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; const hostname = ghUrl.hostname.trimEnd().toUpperCase();
const isGitHubHost = hostname === 'GITHUB.COM';
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
const isLocalHost = hostname.endsWith('.LOCALHOST');
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
} }
exports.isGhes = isGhes; exports.isGhes = isGhes;
function isCacheFeatureAvailable() { function isCacheFeatureAvailable() {
@@ -126393,6 +126639,17 @@ function getGitHubHttpHeaders() {
return headers; return headers;
} }
exports.getGitHubHttpHeaders = getGitHubHttpHeaders; exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
// Rename archive to add extension because after downloading
// archive does not contain extension type and it leads to some issues
// on Windows runners without PowerShell Core.
//
// For default PowerShell Windows it should contain extension type to unpack it.
function renameWinArchive(javaArchivePath) {
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
fs.renameSync(javaArchivePath, javaArchivePathRenamed);
return javaArchivePathRenamed;
}
exports.renameWinArchive = renameWinArchive;
/***/ }), /***/ }),

View File

@@ -10,6 +10,7 @@
- [Alibaba Dragonwell](#Alibaba-Dragonwell) - [Alibaba Dragonwell](#Alibaba-Dragonwell)
- [SapMachine](#SapMachine) - [SapMachine](#SapMachine)
- [GraalVM](#GraalVM) - [GraalVM](#GraalVM)
- [JetBrains](#JetBrains)
- [Installing custom Java package type](#Installing-custom-Java-package-type) - [Installing custom Java package type](#Installing-custom-Java-package-type)
- [Installing custom Java architecture](#Installing-custom-Java-architecture) - [Installing custom Java architecture](#Installing-custom-Java-architecture)
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file) - [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
@@ -171,6 +172,64 @@ steps:
native-image -cp java HelloWorldApp native-image -cp java HelloWorldApp
``` ```
### JetBrains
**NOTE:** JetBrains is only available for LTS versions on 11 or later (11, 17, 21, etc.).
Not all minor LTS versions are guarenteed to be available, since JetBrains considers what to ship IntelliJ IDEA with, most commonly on JDK 11.
For example, `11.0.24` is not available but `11.0.16` is.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'jetbrains'
java-version: '11'
- run: java -cp java HelloWorldApp
```
The JetBrains installer uses the GitHub API to fetch the latest version. If you believe your project is going to be running into rate limits, you can provide a
GitHub token to the action to increase the rate limit. Set the `GITHUB_TOKEN` environment variable to the value of your GitHub token in the workflow file.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'jetbrains'
java-version: '17'
java-package: 'jdk' # optional (jdk, jre, jdk+jcef, jre+jcef, jdk+ft, or jre+ft) - defaults to jdk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: java -cp java HelloWorldApp
```
You can specify your package type (as shown in the [releases page](https://github.com/JetBrains/JetBrainsRuntime/releases/)) in the `java-package` parameter.
The available package types are:
- `jdk` - JBRSDK
- `jre` - JBR (Vanilla)
- `jdk+jcef` - JBRSDK with JCEF
- `jre+jcef` - JBR with JCEF
- `jdk+ft` - JBRSDK (FreeType)
- `jre+ft` - JBR (FreeType)
### GraalVM
**NOTE:** Oracle GraalVM is only available for JDK 17 and later.
```yaml
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'graalvm'
java-version: '21'
- run: |
java -cp java HelloWorldApp
native-image -cp java HelloWorldApp
```
## Installing custom Java package type ## Installing custom Java package type
```yaml ```yaml
steps: steps:
@@ -183,7 +242,6 @@ steps:
- run: java -cp java HelloWorldApp - run: java -cp java HelloWorldApp
``` ```
## Installing custom Java architecture ## Installing custom Java architecture
```yaml ```yaml

16
package-lock.json generated
View File

@@ -2495,10 +2495,11 @@
} }
}, },
"node_modules/cross-spawn": { "node_modules/cross-spawn": {
"version": "7.0.3", "version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"path-key": "^3.1.0", "path-key": "^3.1.0",
"shebang-command": "^2.0.0", "shebang-command": "^2.0.0",
@@ -4322,12 +4323,13 @@
} }
}, },
"node_modules/micromatch": { "node_modules/micromatch": {
"version": "4.0.5", "version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"braces": "^3.0.2", "braces": "^3.0.3",
"picomatch": "^2.3.1" "picomatch": "^2.3.1"
}, },
"engines": { "engines": {

View File

@@ -15,7 +15,8 @@ import {
import { import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
isVersionSatisfies isVersionSatisfies,
renameWinArchive
} from '../../util'; } from '../../util';
export enum AdoptImplementation { export enum AdoptImplementation {
@@ -73,11 +74,13 @@ export class AdoptDistribution extends JavaBase {
core.info( core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
); );
const javaArchivePath = await tc.downloadTool(javaRelease.url); let javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension(); const extension = getDownloadArchiveExtension();
if (process.platform === 'win32') {
javaArchivePath = renameWinArchive(javaArchivePath);
}
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archiveName = fs.readdirSync(extractedJavaPath)[0];

View File

@@ -5,7 +5,8 @@ import path from 'path';
import { import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
convertVersionToSemver convertVersionToSemver,
renameWinArchive
} from '../../util'; } from '../../util';
import {JavaBase} from '../base-installer'; import {JavaBase} from '../base-installer';
import { import {
@@ -29,14 +30,14 @@ export class CorrettoDistribution extends JavaBase {
core.info( core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
); );
const javaArchivePath = await tc.downloadTool(javaRelease.url); let javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension();
const extractedJavaPath = await extractJdkFile( if (process.platform === 'win32') {
javaArchivePath, javaArchivePath = renameWinArchive(javaArchivePath);
getDownloadArchiveExtension() }
); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archiveName = fs.readdirSync(extractedJavaPath)[0];
const archivePath = path.join(extractedJavaPath, archiveName); const archivePath = path.join(extractedJavaPath, archiveName);

View File

@@ -12,6 +12,7 @@ import {OracleDistribution} from './oracle/installer';
import {DragonwellDistribution} from './dragonwell/installer'; import {DragonwellDistribution} from './dragonwell/installer';
import {SapMachineDistribution} from './sapmachine/installer'; import {SapMachineDistribution} from './sapmachine/installer';
import {GraalVMDistribution} from './graalvm/installer'; import {GraalVMDistribution} from './graalvm/installer';
import {JetBrainsDistribution} from './jetbrains/installer';
enum JavaDistribution { enum JavaDistribution {
Adopt = 'adopt', Adopt = 'adopt',
@@ -27,7 +28,8 @@ enum JavaDistribution {
Oracle = 'oracle', Oracle = 'oracle',
Dragonwell = 'dragonwell', Dragonwell = 'dragonwell',
SapMachine = 'sapmachine', SapMachine = 'sapmachine',
GraalVM = 'graalvm' GraalVM = 'graalvm',
JetBrains = 'jetbrains'
} }
export function getJavaDistribution( export function getJavaDistribution(
@@ -72,6 +74,8 @@ export function getJavaDistribution(
return new SapMachineDistribution(installerOptions); return new SapMachineDistribution(installerOptions);
case JavaDistribution.GraalVM: case JavaDistribution.GraalVM:
return new GraalVMDistribution(installerOptions); return new GraalVMDistribution(installerOptions);
case JavaDistribution.JetBrains:
return new JetBrainsDistribution(installerOptions);
default: default:
return null; return null;
} }

View File

@@ -11,7 +11,8 @@ import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
getGitHubHttpHeaders, getGitHubHttpHeaders,
isVersionSatisfies isVersionSatisfies,
renameWinArchive
} from '../../util'; } from '../../util';
import {IDragonwellVersions, IDragonwellAllVersions} from './models'; import {IDragonwellVersions, IDragonwellAllVersions} from './models';
import { import {
@@ -100,14 +101,14 @@ export class DragonwellDistribution extends JavaBase {
core.info( core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
); );
const javaArchivePath = await tc.downloadTool(javaRelease.url); let javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension();
const extractedJavaPath = await extractJdkFile( if (process.platform === 'win32') {
javaArchivePath, javaArchivePath = renameWinArchive(javaArchivePath);
getDownloadArchiveExtension() }
); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archiveName = fs.readdirSync(extractedJavaPath)[0];
const archivePath = path.join(extractedJavaPath, archiveName); const archivePath = path.join(extractedJavaPath, archiveName);

View File

@@ -13,7 +13,8 @@ import {
import { import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
getGitHubHttpHeaders getGitHubHttpHeaders,
renameWinArchive
} from '../../util'; } from '../../util';
import {HttpCodes} from '@actions/http-client'; import {HttpCodes} from '@actions/http-client';
import {GraalVMEAVersion} from './models'; import {GraalVMEAVersion} from './models';
@@ -33,11 +34,13 @@ export class GraalVMDistribution extends JavaBase {
core.info( core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
); );
const javaArchivePath = await tc.downloadTool(javaRelease.url); let javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension(); const extension = getDownloadArchiveExtension();
if (process.platform === 'win32') {
javaArchivePath = renameWinArchive(javaArchivePath);
}
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archiveName = fs.readdirSync(extractedJavaPath)[0];

View File

@@ -0,0 +1,233 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import fs from 'fs';
import path from 'path';
import semver from 'semver';
import {JavaBase} from '../base-installer';
import {IJetBrainsRawVersion, IJetBrainsVersion} from './models';
import {
JavaDownloadRelease,
JavaInstallerOptions,
JavaInstallerResults
} from '../base-models';
import {extractJdkFile, isVersionSatisfies} from '../../util';
import {OutgoingHttpHeaders} from 'http';
import {HttpCodes} from '@actions/http-client';
export class JetBrainsDistribution extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) {
super('JetBrains', installerOptions);
}
protected async findPackageForDownload(
range: string
): Promise<JavaDownloadRelease> {
const versionsRaw = await this.getAvailableVersions();
const versions = versionsRaw.map(v => {
const formattedVersion = `${v.semver}+${v.build}`;
return {
version: formattedVersion,
url: v.url
} as JavaDownloadRelease;
});
const satisfiedVersions = versions
.filter(item => isVersionSatisfies(range, item.version))
.sort((a, b) => {
return -semver.compareBuild(a.version, b.version);
});
const resolvedFullVersion =
satisfiedVersions.length > 0 ? satisfiedVersions[0] : null;
if (!resolvedFullVersion) {
const availableOptions = versionsRaw
.map(item => `${item.tag_name} (${item.semver}+${item.build})`)
.join(', ');
const availableOptionsMessage = availableOptions
? `\nAvailable versions: ${availableOptions}`
: '';
throw new Error(
`Could not find satisfied version for SemVer '${range}'. ${availableOptionsMessage}`
);
}
return resolvedFullVersion;
}
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, 'tar.gz');
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 async getAvailableVersions(): Promise<IJetBrainsVersion[]> {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
if (core.isDebug()) {
console.time('Retrieving available versions for JBR took'); // eslint-disable-line no-console
}
// need to iterate through all pages to retrieve the list of all versions
// GitHub API doesn't provide way to retrieve the count of pages to iterate so infinity loop
let page_index = 1;
const rawVersions: IJetBrainsRawVersion[] = [];
const bearerToken = process.env.GITHUB_TOKEN;
while (true) {
const requestArguments = `per_page=100&page=${page_index}`;
const requestHeaders: OutgoingHttpHeaders = {};
if (bearerToken) {
requestHeaders['Authorization'] = `Bearer ${bearerToken}`;
}
const rawUrl = `https://api.github.com/repos/JetBrains/JetBrainsRuntime/releases?${requestArguments}`;
if (core.isDebug() && page_index === 1) {
// url is identical except page_index so print it once for debug
core.debug(`Gathering available versions from '${rawUrl}'`);
}
const paginationPage = (
await this.http.getJson<IJetBrainsRawVersion[]>(rawUrl, requestHeaders)
).result;
if (!paginationPage || paginationPage.length === 0) {
// break infinity loop because we have reached end of pagination
break;
}
rawVersions.push(...paginationPage);
page_index++;
}
// Add versions not available from the API but are downloadable
const hidden = ['11_0_10b1145.115', '11_0_11b1341.60'];
rawVersions.push(...hidden.map(tag => ({tag_name: tag, name: tag})));
const versions0 = rawVersions.map(async v => {
// Release tags look like one of these:
// jbr-release-21.0.3b465.3
// jbr17-b87.7
// jb11_0_11-b87.7
// jbr11_0_15b2043.56
// 11_0_11b1536.2
// 11_0_11-b1522
const tag = v.tag_name;
// Extract version string
const vstring = tag
.replace('jbr-release-', '')
.replace('jbr', '')
.replace('jb', '')
.replace('-', '');
const vsplit = vstring.split('b');
let semver = vsplit[0];
const build = +vsplit[1];
// Normalize semver
if (!semver.includes('.') && !semver.includes('_'))
semver = `${semver}.0.0`;
// Construct URL
let type: string;
switch (this.packageType ?? '') {
case 'jre':
type = 'jbr';
break;
case 'jdk+jcef':
type = 'jbrsdk_jcef';
break;
case 'jre+jcef':
type = 'jbr_jcef';
break;
case 'jdk+ft':
type = 'jbrsdk_ft';
break;
case 'jre+ft':
type = 'jbr_ft';
break;
default:
type = 'jbrsdk';
break;
}
let url = `https://cache-redirector.jetbrains.com/intellij-jbr/${type}-${semver}-${platform}-${arch}-b${build}.tar.gz`;
let include = false;
const res = await this.http.head(url);
if (res.message.statusCode === HttpCodes.OK) {
include = true;
} else {
url = `https://cache-redirector.jetbrains.com/intellij-jbr/${type}_nomod-${semver}-${platform}-${arch}-b${build}.tar.gz`;
const res2 = await this.http.head(url);
if (res2.message.statusCode === HttpCodes.OK) {
include = true;
}
}
const version = {
tag_name: tag,
semver: semver.replace(/_/g, '.'),
build: build,
url: url
} as IJetBrainsVersion;
return {
item: version,
include: include
};
});
const versions = await Promise.all(versions0).then(res =>
res.filter(item => item.include).map(item => item.item)
);
if (core.isDebug()) {
core.startGroup('Print information about available versions');
console.timeEnd('Retrieving available versions for JBR took'); // eslint-disable-line no-console
core.debug(`Available versions: [${versions.length}]`);
core.debug(versions.map(item => item.semver).join(', '));
core.endGroup();
}
return versions;
}
private getPlatformOption(): string {
// Jetbrains has own platform names so need to map them
switch (process.platform) {
case 'darwin':
return 'osx';
case 'win32':
return 'windows';
default:
return process.platform;
}
}
}

View File

@@ -0,0 +1,13 @@
// Raw Model from https://api.github.com/repos/JetBrains/JetBrainsRuntime/releases
export interface IJetBrainsRawVersion {
tag_name: string;
name: string;
}
export interface IJetBrainsVersion {
tag_name: string;
semver: string;
build: number;
url: string;
}

View File

@@ -8,7 +8,8 @@ import semver from 'semver';
import { import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
isVersionSatisfies isVersionSatisfies,
renameWinArchive
} from '../../util'; } from '../../util';
import * as core from '@actions/core'; import * as core from '@actions/core';
import {ArchitectureOptions, LibericaVersion, OsVersions} from './models'; import {ArchitectureOptions, LibericaVersion, OsVersions} from './models';
@@ -35,13 +36,8 @@ export class LibericaDistributions extends JavaBase {
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension(); const extension = getDownloadArchiveExtension();
if ( if (process.platform === 'win32') {
process.platform === 'win32' && javaArchivePath = renameWinArchive(javaArchivePath);
(this.architecture === 'arm64' || this.architecture === 'aarch64')
) {
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
await fs.renameSync(javaArchivePath, javaArchivePathRenamed);
javaArchivePath = javaArchivePathRenamed;
} }
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);

View File

@@ -7,7 +7,8 @@ import {
import { import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
getGitHubHttpHeaders getGitHubHttpHeaders,
renameWinArchive
} from '../../util'; } from '../../util';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
@@ -27,22 +28,12 @@ export class MicrosoftDistributions extends JavaBase {
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
); );
let javaArchivePath = await tc.downloadTool(javaRelease.url); let javaArchivePath = await tc.downloadTool(javaRelease.url);
// Rename archive to add extension because after downloading
// archive does not contain extension type and it leads to some issues
// on Windows runners without PowerShell Core.
//
// For default PowerShell Windows it should contain extension type to unpack it.
if (
process.platform === 'win32' &&
(this.architecture === 'arm64' || this.architecture === 'aarch64')
) {
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
await fs.renameSync(javaArchivePath, javaArchivePathRenamed);
javaArchivePath = javaArchivePathRenamed;
}
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension(); const extension = getDownloadArchiveExtension();
if (process.platform === 'win32') {
javaArchivePath = renameWinArchive(javaArchivePath);
}
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archiveName = fs.readdirSync(extractedJavaPath)[0];

View File

@@ -10,7 +10,11 @@ import {
JavaInstallerOptions, JavaInstallerOptions,
JavaInstallerResults JavaInstallerResults
} from '../base-models'; } from '../base-models';
import {extractJdkFile, getDownloadArchiveExtension} from '../../util'; import {
extractJdkFile,
getDownloadArchiveExtension,
renameWinArchive
} from '../../util';
import {HttpCodes} from '@actions/http-client'; import {HttpCodes} from '@actions/http-client';
const ORACLE_DL_BASE = 'https://download.oracle.com/java'; const ORACLE_DL_BASE = 'https://download.oracle.com/java';
@@ -26,11 +30,13 @@ export class OracleDistribution extends JavaBase {
core.info( core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
); );
const javaArchivePath = await tc.downloadTool(javaRelease.url); let javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension(); const extension = getDownloadArchiveExtension();
if (process.platform === 'win32') {
javaArchivePath = renameWinArchive(javaArchivePath);
}
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archiveName = fs.readdirSync(extractedJavaPath)[0];

View File

@@ -9,7 +9,8 @@ import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
getGitHubHttpHeaders, getGitHubHttpHeaders,
isVersionSatisfies isVersionSatisfies,
renameWinArchive
} from '../../util'; } from '../../util';
import {JavaBase} from '../base-installer'; import {JavaBase} from '../base-installer';
import { import {
@@ -104,14 +105,14 @@ export class SapMachineDistribution extends JavaBase {
core.info( core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
); );
const javaArchivePath = await tc.downloadTool(javaRelease.url); let javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension();
const extractedJavaPath = await extractJdkFile( if (process.platform === 'win32') {
javaArchivePath, javaArchivePath = renameWinArchive(javaArchivePath);
getDownloadArchiveExtension() }
); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archiveName = fs.readdirSync(extractedJavaPath)[0];
const archivePath = path.join(extractedJavaPath, archiveName); const archivePath = path.join(extractedJavaPath, archiveName);

View File

@@ -8,7 +8,8 @@ import semver from 'semver';
import { import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
isVersionSatisfies isVersionSatisfies,
renameWinArchive
} from '../../util'; } from '../../util';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
@@ -98,11 +99,13 @@ export class SemeruDistribution extends JavaBase {
core.info( core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
); );
const javaArchivePath = await tc.downloadTool(javaRelease.url); let javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension(); const extension = getDownloadArchiveExtension();
if (process.platform === 'win32') {
javaArchivePath = renameWinArchive(javaArchivePath);
}
const extractedJavaPath: string = await extractJdkFile( const extractedJavaPath: string = await extractJdkFile(
javaArchivePath, javaArchivePath,
extension extension

View File

@@ -15,7 +15,8 @@ import {
import { import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
isVersionSatisfies isVersionSatisfies,
renameWinArchive
} from '../../util'; } from '../../util';
export enum TemurinImplementation { export enum TemurinImplementation {
@@ -76,11 +77,13 @@ export class TemurinDistribution extends JavaBase {
core.info( core.info(
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...` `Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
); );
const javaArchivePath = await tc.downloadTool(javaRelease.url); let javaArchivePath = await tc.downloadTool(javaRelease.url);
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension(); const extension = getDownloadArchiveExtension();
if (process.platform === 'win32') {
javaArchivePath = renameWinArchive(javaArchivePath);
}
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
const archiveName = fs.readdirSync(extractedJavaPath)[0]; const archiveName = fs.readdirSync(extractedJavaPath)[0];

View File

@@ -11,7 +11,8 @@ import {
extractJdkFile, extractJdkFile,
getDownloadArchiveExtension, getDownloadArchiveExtension,
convertVersionToSemver, convertVersionToSemver,
isVersionSatisfies isVersionSatisfies,
renameWinArchive
} from '../../util'; } from '../../util';
import { import {
JavaDownloadRelease, JavaDownloadRelease,
@@ -80,13 +81,8 @@ export class ZuluDistribution extends JavaBase {
core.info(`Extracting Java archive...`); core.info(`Extracting Java archive...`);
const extension = getDownloadArchiveExtension(); const extension = getDownloadArchiveExtension();
if ( if (process.platform === 'win32') {
process.platform === 'win32' && javaArchivePath = renameWinArchive(javaArchivePath);
(this.architecture === 'arm64' || this.architecture === 'aarch64')
) {
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
await fs.renameSync(javaArchivePath, javaArchivePathRenamed);
javaArchivePath = javaArchivePathRenamed;
} }
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension); const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);

View File

@@ -92,7 +92,13 @@ export function isGhes(): boolean {
const ghUrl = new URL( const ghUrl = new URL(
process.env['GITHUB_SERVER_URL'] || 'https://github.com' process.env['GITHUB_SERVER_URL'] || 'https://github.com'
); );
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
const isGitHubHost = hostname === 'GITHUB.COM';
const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM');
const isLocalHost = hostname.endsWith('.LOCALHOST');
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
} }
export function isCacheFeatureAvailable(): boolean { export function isCacheFeatureAvailable(): boolean {
@@ -190,3 +196,14 @@ export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
} }
return headers; return headers;
} }
// Rename archive to add extension because after downloading
// archive does not contain extension type and it leads to some issues
// on Windows runners without PowerShell Core.
//
// For default PowerShell Windows it should contain extension type to unpack it.
export function renameWinArchive(javaArchivePath: string): string {
const javaArchivePathRenamed = `${javaArchivePath}.zip`;
fs.renameSync(javaArchivePath, javaArchivePathRenamed);
return javaArchivePathRenamed;
}