2019-07-10 14:54:25 +00:00
|
|
|
import * as core from '@actions/core';
|
2019-11-16 00:01:13 +00:00
|
|
|
import * as auth from './auth';
|
2022-03-31 19:09:57 +00:00
|
|
|
import { getBooleanInput, isCacheFeatureAvailable } from './util';
|
2020-07-16 01:53:39 +00:00
|
|
|
import * as constants from './constants';
|
2021-08-19 17:19:35 +00:00
|
|
|
import { restore } from './cache';
|
2019-07-12 02:57:54 +00:00
|
|
|
import * as path from 'path';
|
2021-04-05 10:02:27 +00:00
|
|
|
import { getJavaDistribution } from './distributions/distribution-factory';
|
|
|
|
import { JavaInstallerOptions } from './distributions/base-models';
|
2019-07-10 14:54:25 +00:00
|
|
|
|
|
|
|
async function run() {
|
2019-07-11 03:11:48 +00:00
|
|
|
try {
|
2021-04-05 10:02:27 +00:00
|
|
|
const version = core.getInput(constants.INPUT_JAVA_VERSION, { required: true });
|
|
|
|
const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true });
|
|
|
|
const architecture = core.getInput(constants.INPUT_ARCHITECTURE);
|
|
|
|
const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE);
|
|
|
|
const jdkFile = core.getInput(constants.INPUT_JDK_FILE);
|
2021-08-19 17:19:35 +00:00
|
|
|
const cache = core.getInput(constants.INPUT_CACHE);
|
2021-04-05 10:02:27 +00:00
|
|
|
const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false);
|
|
|
|
|
|
|
|
const installerOptions: JavaInstallerOptions = {
|
|
|
|
architecture,
|
|
|
|
packageType,
|
|
|
|
version,
|
|
|
|
checkLatest
|
|
|
|
};
|
|
|
|
|
|
|
|
const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile);
|
|
|
|
if (!distribution) {
|
|
|
|
throw new Error(`No supported distribution was found for input ${distributionName}`);
|
2019-08-13 20:24:39 +00:00
|
|
|
}
|
2020-08-24 10:35:41 +00:00
|
|
|
|
2021-04-05 10:02:27 +00:00
|
|
|
const result = await distribution.setupJava();
|
2019-07-11 03:11:48 +00:00
|
|
|
|
2021-04-05 10:02:27 +00:00
|
|
|
core.info('');
|
|
|
|
core.info('Java configuration:');
|
|
|
|
core.info(` Distribution: ${distributionName}`);
|
|
|
|
core.info(` Version: ${result.version}`);
|
|
|
|
core.info(` Path: ${result.path}`);
|
|
|
|
core.info('');
|
2019-07-12 02:57:54 +00:00
|
|
|
|
2020-05-02 11:33:15 +00:00
|
|
|
const matchersPath = path.join(__dirname, '..', '..', '.github');
|
2020-07-16 01:53:39 +00:00
|
|
|
core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
|
|
|
|
|
2021-04-05 10:02:27 +00:00
|
|
|
await auth.configureAuthentication();
|
2022-03-31 19:09:57 +00:00
|
|
|
if (cache && isCacheFeatureAvailable()) {
|
2021-08-19 17:19:35 +00:00
|
|
|
await restore(cache);
|
|
|
|
}
|
2019-07-11 03:11:48 +00:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
2019-07-10 14:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
run();
|