Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
0aa6f2a84f | |||
dc1a9f2791 | |||
e886040dc2 | |||
efbea1411b | |||
c41070eda4 | |||
f69f00b5e5 | |||
2e1dfa1fb4 | |||
a12e082d83 | |||
04d53533c2 | |||
d8da887cad | |||
f0bb916062 | |||
d23aed3c80 | |||
8d22286106 | |||
db2f350d2b | |||
6df0b04fb5 | |||
a1ad2000b3 | |||
faa22ddfbc | |||
a388b3faf4 |
5
.github/workflows/build.yml
vendored
Executable file → Normal file
5
.github/workflows/build.yml
vendored
Executable file → Normal file
@ -20,10 +20,11 @@ jobs:
|
|||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Setup Node.JS 12
|
- name: Setup Node.JS 16
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 16.x
|
||||||
|
cache: npm
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
- run: npm run format-check
|
- run: npm run format-check
|
||||||
|
4
.github/workflows/check-dist.yml
vendored
4
.github/workflows/check-dist.yml
vendored
@ -23,10 +23,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set Node.js 12.x
|
- name: Set Node.js 16.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 16.x
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
18
.github/workflows/e2e-versions.yml
vendored
18
.github/workflows/e2e-versions.yml
vendored
@ -20,8 +20,11 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-latest, windows-latest, ubuntu-latest]
|
||||||
distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica'] # internally 'adopt-hotspot' is the same as 'adopt'
|
distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft' ] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||||
version: ['8', '11', '16']
|
version: ['8', '11', '16']
|
||||||
|
exclude:
|
||||||
|
- distribution: microsoft
|
||||||
|
version: 8
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@ -174,16 +177,17 @@ 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-custom-architecture:
|
# Only Liberica and Zulu provide x86
|
||||||
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x86) - ${{ matrix.os }}
|
setup-java-x86:
|
||||||
|
name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-${{ matrix.architecture }}) - ${{ matrix.os }}
|
||||||
needs: setup-java-major-minor-versions
|
needs: setup-java-major-minor-versions
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
# Only Zulu and Liberica provides x86 arch for now and only for windows / ubuntu
|
# x86 is not supported on macOS
|
||||||
os: [windows-latest, ubuntu-latest]
|
os: [windows-latest, ubuntu-latest]
|
||||||
distribution: ['zulu', 'liberica']
|
distribution: ['liberica', 'zulu']
|
||||||
version: ['11']
|
version: ['11']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -194,7 +198,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
distribution: ${{ matrix.distribution }}
|
distribution: ${{ matrix.distribution }}
|
||||||
java-version: ${{ matrix.version }}
|
java-version: ${{ matrix.version }}
|
||||||
architecture: x86
|
architecture: 'x86'
|
||||||
- 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
|
||||||
|
|
||||||
|
# Only Microsoft provides AArch64. However, GitHub-hosted runners do not support this architecture.
|
3
.github/workflows/licensed.yml
vendored
3
.github/workflows/licensed.yml
vendored
@ -7,6 +7,7 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@ -18,7 +19,7 @@ jobs:
|
|||||||
- name: Install licensed
|
- name: Install licensed
|
||||||
run: |
|
run: |
|
||||||
cd $RUNNER_TEMP
|
cd $RUNNER_TEMP
|
||||||
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
|
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz
|
||||||
sudo tar -xzf licensed.tar.gz
|
sudo tar -xzf licensed.tar.gz
|
||||||
sudo mv licensed /usr/local/bin/licensed
|
sudo mv licensed /usr/local/bin/licensed
|
||||||
- run: licensed status
|
- run: licensed status
|
||||||
|
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/node-fetch.dep.yml
generated
BIN
.licenses/npm/node-fetch.dep.yml
generated
Binary file not shown.
@ -59,13 +59,18 @@ Currently, the following distributions are supported:
|
|||||||
| `adopt` or `adopt-hotspot` | Adopt OpenJDK Hotspot | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
|
| `adopt` or `adopt-hotspot` | Adopt OpenJDK Hotspot | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
|
||||||
| `adopt-openj9` | Adopt OpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
|
| `adopt-openj9` | Adopt OpenJDK OpenJ9 | [Link](https://adoptopenjdk.net/) | [Link](https://adoptopenjdk.net/about.html) |
|
||||||
| `liberica` | Liberica JDK | [Link](https://bell-sw.com/) | [Link](https://bell-sw.com/liberica_eula/) |
|
| `liberica` | Liberica JDK | [Link](https://bell-sw.com/) | [Link](https://bell-sw.com/liberica_eula/) |
|
||||||
|
| `microsoft` | Microsoft Build of OpenJDK | [Link](https://www.microsoft.com/openjdk) | [Link](https://docs.microsoft.com/java/openjdk/faq)
|
||||||
|
|
||||||
**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.
|
||||||
|
|
||||||
**NOTE:** Adopt OpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` to `temurin` to keep receiving software and security updates. See more details in the [Good-bye AdoptOpenJDK post](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/).
|
**NOTE:** Adopt OpenJDK got moved to Eclipse Temurin and won't be updated anymore. It is highly recommended to migrate workflows from `adopt` to `temurin` to keep receiving software and security updates. See more details in the [Good-bye AdoptOpenJDK post](https://blog.adoptopenjdk.net/2021/08/goodbye-adoptopenjdk-hello-adoptium/).
|
||||||
|
|
||||||
### Caching packages dependencies
|
### Caching packages dependencies
|
||||||
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle and maven. The cache input is optional, and caching is turned off by default.
|
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle and maven. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
|
||||||
|
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`
|
||||||
|
- maven: `**/pom.xml`
|
||||||
|
|
||||||
|
The cache input is optional, and caching is turned off by default.
|
||||||
|
|
||||||
#### Caching gradle dependencies
|
#### Caching gradle dependencies
|
||||||
```yaml
|
```yaml
|
||||||
|
88
__tests__/distributors/microsoft-installer.test.ts
Normal file
88
__tests__/distributors/microsoft-installer.test.ts
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
import { MicrosoftDistributions } from '../../src/distributions/microsoft/installer';
|
||||||
|
|
||||||
|
describe('findPackageForDownload', () => {
|
||||||
|
let distribution: MicrosoftDistributions;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
distribution = new MicrosoftDistributions({
|
||||||
|
version: '',
|
||||||
|
architecture: 'x64',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'17.x',
|
||||||
|
'17.0.1',
|
||||||
|
'https://aka.ms/download-jdk/microsoft-jdk-17.0.1.12.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'16.0.x',
|
||||||
|
'16.0.2',
|
||||||
|
'https://aka.ms/download-jdk/microsoft-jdk-16.0.2.7.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'11.0.13',
|
||||||
|
'11.0.13',
|
||||||
|
'https://aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-{{OS_TYPE}}-x64.{{ARCHIVE_TYPE}}'
|
||||||
|
]
|
||||||
|
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
|
||||||
|
const result = await distribution['findPackageForDownload'](input);
|
||||||
|
expect(result.version).toBe(expectedVersion);
|
||||||
|
let os: string;
|
||||||
|
let archive: string;
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'darwin':
|
||||||
|
os = 'macos';
|
||||||
|
archive = 'tar.gz';
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
os = 'windows';
|
||||||
|
archive = 'zip';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
os = process.platform.toString();
|
||||||
|
archive = 'tar.gz';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const url = expectedUrl.replace('{{OS_TYPE}}', os).replace('{{ARCHIVE_TYPE}}', archive);
|
||||||
|
expect(result.url).toBe(url);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw an error', async () => {
|
||||||
|
await expect(distribution['findPackageForDownload']('8')).rejects.toThrow(
|
||||||
|
/Could not find satisfied version for SemVer */
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getPlatformOption', () => {
|
||||||
|
const distributions = new MicrosoftDistributions({
|
||||||
|
architecture: 'x64',
|
||||||
|
version: '11',
|
||||||
|
packageType: 'jdk',
|
||||||
|
checkLatest: false
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['linux', 'tar.gz', 'linux'],
|
||||||
|
['darwin', 'tar.gz', 'macos'],
|
||||||
|
['win32', 'zip', 'windows']
|
||||||
|
])('os version %s -> %s', (input, expectedArchive, expectedOs) => {
|
||||||
|
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
|
||||||
|
|
||||||
|
expect(actual.archive).toEqual(expectedArchive);
|
||||||
|
expect(actual.os).toEqual(expectedOs);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each(['aix', 'android', 'freebsd', 'openbsd', 'netbsd', 'solaris', 'cygwin'])(
|
||||||
|
'not support os version %s',
|
||||||
|
input => {
|
||||||
|
expect(() => distributions['getPlatformOption'](input as NodeJS.Platform)).toThrow(
|
||||||
|
/Platform '\w+' is not supported\. Supported platforms: .+/
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
@ -139,6 +139,7 @@ describe('findPackageForDownload', () => {
|
|||||||
packageType: 'jdk',
|
packageType: 'jdk',
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
|
distribution['getAvailableVersions'] = async () => manifestData;
|
||||||
await expect(
|
await expect(
|
||||||
distribution['findPackageForDownload'](distribution['version'])
|
distribution['findPackageForDownload'](distribution['version'])
|
||||||
).rejects.toThrowError(/Could not find satisfied version for semver */);
|
).rejects.toThrowError(/Could not find satisfied version for semver */);
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
import { isVersionSatisfies } from '../src/util';
|
import * as cache from '@actions/cache';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import { isVersionSatisfies, isCacheFeatureAvailable } from '../src/util';
|
||||||
|
|
||||||
|
jest.mock('@actions/cache');
|
||||||
|
jest.mock('@actions/core');
|
||||||
|
|
||||||
describe('isVersionSatisfies', () => {
|
describe('isVersionSatisfies', () => {
|
||||||
it.each([
|
it.each([
|
||||||
@ -20,3 +25,38 @@ describe('isVersionSatisfies', () => {
|
|||||||
expect(actual).toBe(expected);
|
expect(actual).toBe(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('isCacheFeatureAvailable', () => {
|
||||||
|
it('isCacheFeatureAvailable disabled on GHES', () => {
|
||||||
|
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false);
|
||||||
|
try {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'http://example.com';
|
||||||
|
isCacheFeatureAvailable();
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toHaveProperty(
|
||||||
|
'message',
|
||||||
|
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
delete process.env['GITHUB_SERVER_URL'];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isCacheFeatureAvailable disabled on dotcom', () => {
|
||||||
|
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false);
|
||||||
|
const infoMock = jest.spyOn(core, 'warning');
|
||||||
|
const message = 'The runner was not able to contact the cache service. Caching will be skipped';
|
||||||
|
try {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'http://github.com';
|
||||||
|
expect(isCacheFeatureAvailable()).toBe(false);
|
||||||
|
expect(infoMock).toHaveBeenCalledWith(message);
|
||||||
|
} finally {
|
||||||
|
delete process.env['GITHUB_SERVER_URL'];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isCacheFeatureAvailable is enabled', () => {
|
||||||
|
jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => true);
|
||||||
|
expect(isCacheFeatureAvailable()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -67,6 +67,6 @@ outputs:
|
|||||||
path:
|
path:
|
||||||
description: 'Path to where the java environment has been installed (same as $JAVA_HOME)'
|
description: 'Path to where the java environment has been installed (same as $JAVA_HOME)'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node16'
|
||||||
main: 'dist/setup/index.js'
|
main: 'dist/setup/index.js'
|
||||||
post: 'dist/cleanup/index.js'
|
post: 'dist/cleanup/index.js'
|
||||||
|
166
dist/cleanup/index.js
vendored
166
dist/cleanup/index.js
vendored
@ -3730,10 +3730,7 @@ const options_1 = __webpack_require__(538);
|
|||||||
const requestUtils_1 = __webpack_require__(899);
|
const requestUtils_1 = __webpack_require__(899);
|
||||||
const versionSalt = '1.0';
|
const versionSalt = '1.0';
|
||||||
function getCacheApiUrl(resource) {
|
function getCacheApiUrl(resource) {
|
||||||
// Ideally we just use ACTIONS_CACHE_URL
|
const baseUrl = process.env['ACTIONS_CACHE_URL'] || '';
|
||||||
const baseUrl = (process.env['ACTIONS_CACHE_URL'] ||
|
|
||||||
process.env['ACTIONS_RUNTIME_URL'] ||
|
|
||||||
'').replace('pipelines', 'artifactcache');
|
|
||||||
if (!baseUrl) {
|
if (!baseUrl) {
|
||||||
throw new Error('Cache Service Url not found, unable to restore cache.');
|
throw new Error('Cache Service Url not found, unable to restore cache.');
|
||||||
}
|
}
|
||||||
@ -5932,7 +5929,35 @@ module.exports = {
|
|||||||
/* 193 */,
|
/* 193 */,
|
||||||
/* 194 */,
|
/* 194 */,
|
||||||
/* 195 */,
|
/* 195 */,
|
||||||
/* 196 */,
|
/* 196 */
|
||||||
|
/***/ (function(__unusedmodule, exports) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
||||||
|
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
||||||
|
exports.INPUT_JAVA_VERSION = 'java-version';
|
||||||
|
exports.INPUT_ARCHITECTURE = 'architecture';
|
||||||
|
exports.INPUT_JAVA_PACKAGE = 'java-package';
|
||||||
|
exports.INPUT_DISTRIBUTION = 'distribution';
|
||||||
|
exports.INPUT_JDK_FILE = 'jdkFile';
|
||||||
|
exports.INPUT_CHECK_LATEST = 'check-latest';
|
||||||
|
exports.INPUT_SERVER_ID = 'server-id';
|
||||||
|
exports.INPUT_SERVER_USERNAME = 'server-username';
|
||||||
|
exports.INPUT_SERVER_PASSWORD = 'server-password';
|
||||||
|
exports.INPUT_SETTINGS_PATH = 'settings-path';
|
||||||
|
exports.INPUT_OVERWRITE_SETTINGS = 'overwrite-settings';
|
||||||
|
exports.INPUT_GPG_PRIVATE_KEY = 'gpg-private-key';
|
||||||
|
exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
|
||||||
|
exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined;
|
||||||
|
exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
||||||
|
exports.INPUT_CACHE = 'cache';
|
||||||
|
exports.INPUT_JOB_STATUS = 'job-status';
|
||||||
|
exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
/* 197 */
|
/* 197 */
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
@ -6092,7 +6117,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
exports.run = void 0;
|
exports.run = void 0;
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const gpg = __importStar(__webpack_require__(884));
|
const gpg = __importStar(__webpack_require__(884));
|
||||||
const constants = __importStar(__webpack_require__(694));
|
const constants = __importStar(__webpack_require__(196));
|
||||||
const util_1 = __webpack_require__(322);
|
const util_1 = __webpack_require__(322);
|
||||||
const cache_1 = __webpack_require__(913);
|
const cache_1 = __webpack_require__(913);
|
||||||
function removePrivateKeyFromKeychain() {
|
function removePrivateKeyFromKeychain() {
|
||||||
@ -6889,7 +6914,8 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
|
|||||||
//
|
//
|
||||||
// If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB
|
// If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB
|
||||||
// on 64-bit systems), split the download into multiple segments
|
// on 64-bit systems), split the download into multiple segments
|
||||||
const maxSegmentSize = buffer.constants.MAX_LENGTH;
|
// ~2 GB = 2147483647, beyond this, we start getting out of range error. So, capping it accordingly.
|
||||||
|
const maxSegmentSize = Math.min(2147483647, buffer.constants.MAX_LENGTH);
|
||||||
const downloadProgress = new DownloadProgress(contentLength);
|
const downloadProgress = new DownloadProgress(contentLength);
|
||||||
const fd = fs.openSync(archivePath, 'w');
|
const fd = fs.openSync(archivePath, 'w');
|
||||||
try {
|
try {
|
||||||
@ -9110,14 +9136,15 @@ 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.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0;
|
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(__webpack_require__(87));
|
const os_1 = __importDefault(__webpack_require__(87));
|
||||||
const path_1 = __importDefault(__webpack_require__(622));
|
const path_1 = __importDefault(__webpack_require__(622));
|
||||||
const fs = __importStar(__webpack_require__(747));
|
const fs = __importStar(__webpack_require__(747));
|
||||||
const semver = __importStar(__webpack_require__(876));
|
const semver = __importStar(__webpack_require__(876));
|
||||||
|
const cache = __importStar(__webpack_require__(692));
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const tc = __importStar(__webpack_require__(533));
|
const tc = __importStar(__webpack_require__(533));
|
||||||
const constants_1 = __webpack_require__(694);
|
const constants_1 = __webpack_require__(196);
|
||||||
function getTempDir() {
|
function getTempDir() {
|
||||||
let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir();
|
let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir();
|
||||||
return tempDirectory;
|
return tempDirectory;
|
||||||
@ -9187,6 +9214,24 @@ function isJobStatusSuccess() {
|
|||||||
return jobStatus === 'success';
|
return jobStatus === 'success';
|
||||||
}
|
}
|
||||||
exports.isJobStatusSuccess = isJobStatusSuccess;
|
exports.isJobStatusSuccess = isJobStatusSuccess;
|
||||||
|
function isGhes() {
|
||||||
|
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||||
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
||||||
|
}
|
||||||
|
exports.isGhes = isGhes;
|
||||||
|
function isCacheFeatureAvailable() {
|
||||||
|
if (!cache.isFeatureAvailable()) {
|
||||||
|
if (isGhes()) {
|
||||||
|
throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -41953,7 +41998,7 @@ __exportStar(__webpack_require__(220), exports);
|
|||||||
__exportStar(__webpack_require__(932), exports);
|
__exportStar(__webpack_require__(932), exports);
|
||||||
__exportStar(__webpack_require__(975), exports);
|
__exportStar(__webpack_require__(975), exports);
|
||||||
__exportStar(__webpack_require__(207), exports);
|
__exportStar(__webpack_require__(207), exports);
|
||||||
__exportStar(__webpack_require__(773), exports);
|
__exportStar(__webpack_require__(694), exports);
|
||||||
__exportStar(__webpack_require__(695), exports);
|
__exportStar(__webpack_require__(695), exports);
|
||||||
var spancontext_utils_1 = __webpack_require__(629);
|
var spancontext_utils_1 = __webpack_require__(629);
|
||||||
Object.defineProperty(exports, "isSpanContextValid", { enumerable: true, get: function () { return spancontext_utils_1.isSpanContextValid; } });
|
Object.defineProperty(exports, "isSpanContextValid", { enumerable: true, get: function () { return spancontext_utils_1.isSpanContextValid; } });
|
||||||
@ -43501,9 +43546,17 @@ AbortError.prototype = Object.create(Error.prototype);
|
|||||||
AbortError.prototype.constructor = AbortError;
|
AbortError.prototype.constructor = AbortError;
|
||||||
AbortError.prototype.name = 'AbortError';
|
AbortError.prototype.name = 'AbortError';
|
||||||
|
|
||||||
|
const URL$1 = Url.URL || whatwgUrl.URL;
|
||||||
|
|
||||||
// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
|
// fix an issue where "PassThrough", "resolve" aren't a named export for node <10
|
||||||
const PassThrough$1 = Stream.PassThrough;
|
const PassThrough$1 = Stream.PassThrough;
|
||||||
const resolve_url = Url.resolve;
|
|
||||||
|
const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) {
|
||||||
|
const orig = new URL$1(original).hostname;
|
||||||
|
const dest = new URL$1(destination).hostname;
|
||||||
|
|
||||||
|
return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch function
|
* Fetch function
|
||||||
@ -43591,7 +43644,19 @@ function fetch(url, opts) {
|
|||||||
const location = headers.get('Location');
|
const location = headers.get('Location');
|
||||||
|
|
||||||
// HTTP fetch step 5.3
|
// HTTP fetch step 5.3
|
||||||
const locationURL = location === null ? null : resolve_url(request.url, location);
|
let locationURL = null;
|
||||||
|
try {
|
||||||
|
locationURL = location === null ? null : new URL$1(location, request.url).toString();
|
||||||
|
} catch (err) {
|
||||||
|
// error here can only be invalid URL in Location: header
|
||||||
|
// do not throw when options.redirect == manual
|
||||||
|
// let the user extract the errorneous redirect URL
|
||||||
|
if (request.redirect !== 'manual') {
|
||||||
|
reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect'));
|
||||||
|
finalize();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// HTTP fetch step 5.5
|
// HTTP fetch step 5.5
|
||||||
switch (request.redirect) {
|
switch (request.redirect) {
|
||||||
@ -43639,6 +43704,12 @@ function fetch(url, opts) {
|
|||||||
size: request.size
|
size: request.size
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!isDomainOrSubdomain(request.url, locationURL)) {
|
||||||
|
for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
|
||||||
|
requestOpts.headers.delete(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// HTTP-redirect fetch step 9
|
// HTTP-redirect fetch step 9
|
||||||
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
|
if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) {
|
||||||
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
|
reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect'));
|
||||||
@ -53480,6 +53551,15 @@ function checkKey(key) {
|
|||||||
throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`);
|
throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* isFeatureAvailable to check the presence of Actions cache service
|
||||||
|
*
|
||||||
|
* @returns boolean return true if Actions cache service feature is available, otherwise false
|
||||||
|
*/
|
||||||
|
function isFeatureAvailable() {
|
||||||
|
return !!process.env['ACTIONS_CACHE_URL'];
|
||||||
|
}
|
||||||
|
exports.isFeatureAvailable = isFeatureAvailable;
|
||||||
/**
|
/**
|
||||||
* Restores cache from keys
|
* Restores cache from keys
|
||||||
*
|
*
|
||||||
@ -53600,28 +53680,23 @@ exports.saveCache = saveCache;
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0;
|
//# sourceMappingURL=tracer_provider.js.map
|
||||||
exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home';
|
|
||||||
exports.INPUT_JAVA_VERSION = 'java-version';
|
|
||||||
exports.INPUT_ARCHITECTURE = 'architecture';
|
|
||||||
exports.INPUT_JAVA_PACKAGE = 'java-package';
|
|
||||||
exports.INPUT_DISTRIBUTION = 'distribution';
|
|
||||||
exports.INPUT_JDK_FILE = 'jdkFile';
|
|
||||||
exports.INPUT_CHECK_LATEST = 'check-latest';
|
|
||||||
exports.INPUT_SERVER_ID = 'server-id';
|
|
||||||
exports.INPUT_SERVER_USERNAME = 'server-username';
|
|
||||||
exports.INPUT_SERVER_PASSWORD = 'server-password';
|
|
||||||
exports.INPUT_SETTINGS_PATH = 'settings-path';
|
|
||||||
exports.INPUT_OVERWRITE_SETTINGS = 'overwrite-settings';
|
|
||||||
exports.INPUT_GPG_PRIVATE_KEY = 'gpg-private-key';
|
|
||||||
exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase';
|
|
||||||
exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined;
|
|
||||||
exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE';
|
|
||||||
exports.INPUT_CACHE = 'cache';
|
|
||||||
exports.INPUT_JOB_STATUS = 'job-status';
|
|
||||||
exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
/* 695 */
|
/* 695 */
|
||||||
@ -55688,30 +55763,7 @@ module.exports = function(dst, src) {
|
|||||||
/* 770 */,
|
/* 770 */,
|
||||||
/* 771 */,
|
/* 771 */,
|
||||||
/* 772 */,
|
/* 772 */,
|
||||||
/* 773 */
|
/* 773 */,
|
||||||
/***/ (function(__unusedmodule, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright The OpenTelemetry Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=tracer_provider.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
/* 774 */,
|
/* 774 */,
|
||||||
/* 775 */,
|
/* 775 */,
|
||||||
/* 776 */,
|
/* 776 */,
|
||||||
|
1471
dist/setup/index.js
vendored
1471
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -65,6 +65,17 @@ steps:
|
|||||||
- run: java -cp java HelloWorldApp
|
- run: java -cp java HelloWorldApp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Microsoft
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
distribution: 'microsoft'
|
||||||
|
java-version: '11'
|
||||||
|
- run: java -cp java HelloWorldApp
|
||||||
|
```
|
||||||
|
|
||||||
## Installing custom Java package type
|
## Installing custom Java package type
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
|
6695
package-lock.json
generated
6695
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-java",
|
"name": "setup-java",
|
||||||
"version": "2.0.0",
|
"version": "3.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "setup java action",
|
"description": "setup java action",
|
||||||
"main": "dist/setup/index.js",
|
"main": "dist/setup/index.js",
|
||||||
@ -24,7 +24,7 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^1.0.8",
|
"@actions/cache": "^2.0.0",
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
@ -36,7 +36,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^12.19.13",
|
"@types/node": "^16.11.25",
|
||||||
"@types/semver": "^7.3.4",
|
"@types/semver": "^7.3.4",
|
||||||
"@zeit/ncc": "^0.20.5",
|
"@zeit/ncc": "^0.20.5",
|
||||||
"jest": "^27.2.5",
|
"jest": "^27.2.5",
|
||||||
@ -44,11 +44,5 @@
|
|||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"ts-jest": "^27.0.5",
|
"ts-jest": "^27.0.5",
|
||||||
"typescript": "^4.2.3"
|
"typescript": "^4.2.3"
|
||||||
},
|
|
||||||
"husky": {
|
|
||||||
"skipCI": true,
|
|
||||||
"hooks": {
|
|
||||||
"pre-commit": "npm run build && npm run format"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import { ZuluDistribution } from './zulu/installer';
|
|||||||
import { AdoptDistribution, AdoptImplementation } from './adopt/installer';
|
import { AdoptDistribution, AdoptImplementation } from './adopt/installer';
|
||||||
import { TemurinDistribution, TemurinImplementation } from './temurin/installer';
|
import { TemurinDistribution, TemurinImplementation } from './temurin/installer';
|
||||||
import { LibericaDistributions } from './liberica/installer';
|
import { LibericaDistributions } from './liberica/installer';
|
||||||
|
import { MicrosoftDistributions } from './microsoft/installer';
|
||||||
|
|
||||||
enum JavaDistribution {
|
enum JavaDistribution {
|
||||||
Adopt = 'adopt',
|
Adopt = 'adopt',
|
||||||
@ -13,7 +14,8 @@ enum JavaDistribution {
|
|||||||
Temurin = 'temurin',
|
Temurin = 'temurin',
|
||||||
Zulu = 'zulu',
|
Zulu = 'zulu',
|
||||||
Liberica = 'liberica',
|
Liberica = 'liberica',
|
||||||
JdkFile = 'jdkfile'
|
JdkFile = 'jdkfile',
|
||||||
|
Microsoft = 'microsoft'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getJavaDistribution(
|
export function getJavaDistribution(
|
||||||
@ -35,6 +37,8 @@ export function getJavaDistribution(
|
|||||||
return new ZuluDistribution(installerOptions);
|
return new ZuluDistribution(installerOptions);
|
||||||
case JavaDistribution.Liberica:
|
case JavaDistribution.Liberica:
|
||||||
return new LibericaDistributions(installerOptions);
|
return new LibericaDistributions(installerOptions);
|
||||||
|
case JavaDistribution.Microsoft:
|
||||||
|
return new MicrosoftDistributions(installerOptions);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
124
src/distributions/microsoft/installer.ts
Normal file
124
src/distributions/microsoft/installer.ts
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
import { JavaBase } from '../base-installer';
|
||||||
|
import { JavaDownloadRelease, JavaInstallerOptions, JavaInstallerResults } from '../base-models';
|
||||||
|
import semver from 'semver';
|
||||||
|
import { extractJdkFile, getDownloadArchiveExtension, isVersionSatisfies } from '../../util';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import { MicrosoftVersion, PlatformOptions } from './models';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
export class MicrosoftDistributions extends JavaBase {
|
||||||
|
constructor(installerOptions: JavaInstallerOptions) {
|
||||||
|
super('Microsoft', installerOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 extension = getDownloadArchiveExtension();
|
||||||
|
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||||
|
|
||||||
|
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||||
|
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||||
|
|
||||||
|
const javaPath = await tc.cacheDir(
|
||||||
|
archivePath,
|
||||||
|
this.toolcacheFolderName,
|
||||||
|
this.getToolcacheVersionName(javaRelease.version),
|
||||||
|
this.architecture
|
||||||
|
);
|
||||||
|
|
||||||
|
return { version: javaRelease.version, path: javaPath };
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async findPackageForDownload(range: string): Promise<JavaDownloadRelease> {
|
||||||
|
if (this.architecture !== 'x64' && this.architecture !== 'aarch64') {
|
||||||
|
throw new Error(`Unsupported architecture: ${this.architecture}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.stable) {
|
||||||
|
throw new Error('Early access versions are not supported');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.packageType !== 'jdk') {
|
||||||
|
throw new Error('Microsoft Build of OpenJDK provides only the `jdk` package type');
|
||||||
|
}
|
||||||
|
|
||||||
|
const availableVersionsRaw = await this.getAvailableVersions();
|
||||||
|
|
||||||
|
const opts = this.getPlatformOption();
|
||||||
|
const availableVersions = availableVersionsRaw.map(item => ({
|
||||||
|
url: `https://aka.ms/download-jdk/microsoft-jdk-${item.version.join('.')}-${opts.os}-${
|
||||||
|
this.architecture
|
||||||
|
}.${opts.archive}`,
|
||||||
|
version: this.convertVersionToSemver(item)
|
||||||
|
}));
|
||||||
|
|
||||||
|
const satisfiedVersion = availableVersions
|
||||||
|
.filter(item => isVersionSatisfies(range, item.version))
|
||||||
|
.sort((a, b) => -semver.compareBuild(a.version, b.version))[0];
|
||||||
|
|
||||||
|
if (!satisfiedVersion) {
|
||||||
|
const availableOptions = availableVersions.map(item => item.version).join(', ');
|
||||||
|
const availableOptionsMessage = availableOptions
|
||||||
|
? `\nAvailable versions: ${availableOptions}`
|
||||||
|
: '';
|
||||||
|
throw new Error(
|
||||||
|
`Could not find satisfied version for SemVer ${range}. ${availableOptionsMessage}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return satisfiedVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async getAvailableVersions(): Promise<MicrosoftVersion[]> {
|
||||||
|
// TODO get these dynamically!
|
||||||
|
// We will need Microsoft to add an endpoint where we can query for versions.
|
||||||
|
const jdkVersions = [
|
||||||
|
{
|
||||||
|
version: [17, 0, 1, 12, 1]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
version: [16, 0, 2, 7, 1]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
// M1 is only supported for Java 16 & 17
|
||||||
|
if (process.platform !== 'darwin' || this.architecture !== 'aarch64') {
|
||||||
|
jdkVersions.push({
|
||||||
|
version: [11, 0, 13, 8, 1]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return jdkVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getPlatformOption(
|
||||||
|
platform: NodeJS.Platform = process.platform /* for testing */
|
||||||
|
): PlatformOptions {
|
||||||
|
switch (platform) {
|
||||||
|
case 'darwin':
|
||||||
|
return { archive: 'tar.gz', os: 'macos' };
|
||||||
|
case 'win32':
|
||||||
|
return { archive: 'zip', os: 'windows' };
|
||||||
|
case 'linux':
|
||||||
|
return { archive: 'tar.gz', os: 'linux' };
|
||||||
|
default:
|
||||||
|
throw new Error(
|
||||||
|
`Platform '${platform}' is not supported. Supported platforms: 'darwin', 'linux', 'win32'`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private convertVersionToSemver(version: MicrosoftVersion): string {
|
||||||
|
const major = version.version[0];
|
||||||
|
const minor = version.version[1];
|
||||||
|
const patch = version.version[2];
|
||||||
|
return `${major}.${minor}.${patch}`;
|
||||||
|
}
|
||||||
|
}
|
12
src/distributions/microsoft/models.ts
Normal file
12
src/distributions/microsoft/models.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
type OsVersions = 'linux' | 'macos' | 'windows';
|
||||||
|
type ArchiveType = 'tar.gz' | 'zip';
|
||||||
|
|
||||||
|
export interface PlatformOptions {
|
||||||
|
archive: ArchiveType;
|
||||||
|
os: OsVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MicrosoftVersion {
|
||||||
|
downloadUrl?: string;
|
||||||
|
version: Array<number>;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as auth from './auth';
|
import * as auth from './auth';
|
||||||
import { getBooleanInput } from './util';
|
import { getBooleanInput, isCacheFeatureAvailable } from './util';
|
||||||
import * as constants from './constants';
|
import * as constants from './constants';
|
||||||
import { restore } from './cache';
|
import { restore } from './cache';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@ -42,7 +42,7 @@ async function run() {
|
|||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
||||||
|
|
||||||
await auth.configureAuthentication();
|
await auth.configureAuthentication();
|
||||||
if (cache) {
|
if (cache && isCacheFeatureAvailable()) {
|
||||||
await restore(cache);
|
await restore(cache);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
22
src/util.ts
22
src/util.ts
@ -2,6 +2,7 @@ import os from 'os';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
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';
|
||||||
@ -77,3 +78,24 @@ export function isJobStatusSuccess() {
|
|||||||
|
|
||||||
return jobStatus === 'success';
|
return jobStatus === 'success';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isGhes(): boolean {
|
||||||
|
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||||
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isCacheFeatureAvailable(): boolean {
|
||||||
|
if (!cache.isFeatureAvailable()) {
|
||||||
|
if (isGhes()) {
|
||||||
|
throw new Error(
|
||||||
|
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user