2019-07-10 14:54:25 +00:00
|
|
|
import * as core from '@actions/core';
|
2019-07-11 03:11:48 +00:00
|
|
|
import * as installer from './installer';
|
2019-11-16 00:01:13 +00:00
|
|
|
import * as auth from './auth';
|
2020-05-02 11:33:15 +00:00
|
|
|
import * as gpg from './gpg';
|
2020-07-16 01:53:39 +00:00
|
|
|
import * as constants from './constants';
|
2019-07-12 02:57:54 +00:00
|
|
|
import * as path from 'path';
|
2019-07-10 14:54:25 +00:00
|
|
|
|
|
|
|
async function run() {
|
2019-07-11 03:11:48 +00:00
|
|
|
try {
|
2020-07-16 01:53:39 +00:00
|
|
|
let version = core.getInput(constants.INPUT_VERSION);
|
2019-08-13 20:24:39 +00:00
|
|
|
if (!version) {
|
2020-07-16 01:53:39 +00:00
|
|
|
version = core.getInput(constants.INPUT_JAVA_VERSION, {required: true});
|
2019-08-13 20:24:39 +00:00
|
|
|
}
|
2020-08-24 10:35:41 +00:00
|
|
|
|
2020-07-16 01:53:39 +00:00
|
|
|
const arch = core.getInput(constants.INPUT_ARCHITECTURE, {required: true});
|
2020-08-24 10:35:41 +00:00
|
|
|
if (!['x86', 'x64'].includes(arch)) {
|
|
|
|
throw new Error(`architecture "${arch}" is not in [x86 | x64]`);
|
|
|
|
}
|
|
|
|
|
2020-07-16 01:53:39 +00:00
|
|
|
const javaPackage = core.getInput(constants.INPUT_JAVA_PACKAGE, {
|
|
|
|
required: true
|
|
|
|
});
|
|
|
|
const jdkFile = core.getInput(constants.INPUT_JDK_FILE, {required: false});
|
2019-07-11 03:11:48 +00:00
|
|
|
|
2019-11-03 04:39:35 +00:00
|
|
|
await installer.getJava(version, arch, jdkFile, javaPackage);
|
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')}`);
|
|
|
|
|
|
|
|
const id = core.getInput(constants.INPUT_SERVER_ID, {required: false});
|
|
|
|
const username = core.getInput(constants.INPUT_SERVER_USERNAME, {
|
|
|
|
required: false
|
|
|
|
});
|
|
|
|
const password = core.getInput(constants.INPUT_SERVER_PASSWORD, {
|
|
|
|
required: false
|
|
|
|
});
|
2020-07-16 03:15:27 +00:00
|
|
|
const gpgPrivateKey =
|
|
|
|
core.getInput(constants.INPUT_GPG_PRIVATE_KEY, {required: false}) ||
|
|
|
|
constants.INPUT_DEFAULT_GPG_PRIVATE_KEY;
|
2020-05-02 11:33:15 +00:00
|
|
|
const gpgPassphrase =
|
2020-07-16 01:53:39 +00:00
|
|
|
core.getInput(constants.INPUT_GPG_PASSPHRASE, {required: false}) ||
|
|
|
|
(gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined);
|
2019-11-16 00:01:13 +00:00
|
|
|
|
2020-05-23 04:30:38 +00:00
|
|
|
if (gpgPrivateKey) {
|
|
|
|
core.setSecret(gpgPrivateKey);
|
|
|
|
}
|
|
|
|
|
2020-05-02 11:33:15 +00:00
|
|
|
await auth.configAuthentication(id, username, password, gpgPassphrase);
|
|
|
|
|
|
|
|
if (gpgPrivateKey) {
|
2020-07-16 01:53:39 +00:00
|
|
|
core.info('importing private key');
|
2020-05-02 11:33:15 +00:00
|
|
|
const keyFingerprint = (await gpg.importKey(gpgPrivateKey)) || '';
|
2020-07-16 01:53:39 +00:00
|
|
|
core.saveState(
|
|
|
|
constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT,
|
|
|
|
keyFingerprint
|
|
|
|
);
|
2020-05-02 11:33:15 +00:00
|
|
|
}
|
2019-07-11 03:11:48 +00:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
2019-07-10 14:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
run();
|