mirror of
https://github.com/actions/setup-java.git
synced 2024-11-13 21:48:05 +00:00
Compare commits
5 Commits
cf4e1422a0
...
2e4e4de3b4
Author | SHA1 | Date | |
---|---|---|---|
|
2e4e4de3b4 | ||
|
8afb584024 | ||
|
4f1c6f6018 | ||
|
b93179bb91 | ||
|
6ba9d9dd2c |
12
dist/cleanup/index.js
vendored
12
dist/cleanup/index.js
vendored
@ -67020,7 +67020,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
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.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 path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
@ -67157,6 +67157,16 @@ function convertVersionToSemver(version) {
|
||||
return mainVersion;
|
||||
}
|
||||
exports.convertVersionToSemver = convertVersionToSemver;
|
||||
function getGitHubHttpHeaders() {
|
||||
const token = core.getInput('token');
|
||||
const auth = !token ? undefined : `token ${token}`;
|
||||
const headers = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
return headers;
|
||||
}
|
||||
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
75
dist/setup/index.js
vendored
75
dist/setup/index.js
vendored
@ -102683,22 +102683,15 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const platform = this.getPlatformOption();
|
||||
const arch = this.distributionArchitecture();
|
||||
const token = core.getInput('token');
|
||||
const auth = !token ? undefined : `token ${token}`;
|
||||
const owner = 'dragonwell-releng';
|
||||
const repository = 'dragonwell-setup-java';
|
||||
const branch = 'main';
|
||||
const filePath = 'releases.json';
|
||||
const availableVersionsUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
const headers = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
const fetchedDragonwellVersions = (yield this.http.getJson(availableVersionsUrl, headers)).result;
|
||||
if (!fetchedDragonwellVersions) {
|
||||
throw new Error(`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`);
|
||||
let fetchedDragonwellJson = yield this.fetchJsonFromPrimaryUrl();
|
||||
if (!fetchedDragonwellJson) {
|
||||
fetchedDragonwellJson = yield this.fetchJsonFromBackupUrl();
|
||||
}
|
||||
const availableVersions = this.parseVersions(platform, arch, fetchedDragonwellVersions);
|
||||
if (!fetchedDragonwellJson) {
|
||||
throw new Error(`Couldn't fetch dragonwell versions information from both primary and backup urls`);
|
||||
}
|
||||
core.debug('Successfully fetched information about available dragonwell versions');
|
||||
const availableVersions = this.parseVersions(platform, arch, fetchedDragonwellJson);
|
||||
if (core.isDebug()) {
|
||||
core.startGroup('Print information about available versions');
|
||||
core.debug(availableVersions.map(item => item.jdk_version).join(', '));
|
||||
@ -102783,6 +102776,39 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
|
||||
return process.platform;
|
||||
}
|
||||
}
|
||||
fetchJsonFromPrimaryUrl() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json';
|
||||
try {
|
||||
core.debug(`Trying to fetch available versions info from the primary url: ${primaryUrl}`);
|
||||
const fetchedDragonwellJson = (yield this.http.getJson(primaryUrl)).result;
|
||||
return fetchedDragonwellJson;
|
||||
}
|
||||
catch (err) {
|
||||
core.debug(`Fetching from the primary link: ${primaryUrl} ended up with the error: ${err.message}`);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
fetchJsonFromBackupUrl() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const owner = 'dragonwell-releng';
|
||||
const repository = 'dragonwell-setup-java';
|
||||
const branch = 'main';
|
||||
const filePath = 'releases.json';
|
||||
const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
const headers = util_1.getGitHubHttpHeaders();
|
||||
try {
|
||||
core.debug(`Trying to fetch available versions info from the backup url: ${backupUrl}`);
|
||||
const fetchedDragonwellVersions = (yield this.http.getJson(backupUrl, headers)).result;
|
||||
return fetchedDragonwellVersions;
|
||||
}
|
||||
catch (err) {
|
||||
core.debug(`Fetching from the backup url: ${backupUrl} ended up with the error: ${err.message}`);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.DragonwellDistribution = DragonwellDistribution;
|
||||
|
||||
@ -103159,18 +103185,13 @@ class MicrosoftDistributions extends base_installer_1.JavaBase {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// TODO get these dynamically!
|
||||
// We will need Microsoft to add an endpoint where we can query for versions.
|
||||
const token = core.getInput('token');
|
||||
const auth = !token ? undefined : `token ${token}`;
|
||||
const owner = 'actions';
|
||||
const repository = 'setup-java';
|
||||
const branch = 'main';
|
||||
const filePath = 'src/distributions/microsoft/microsoft-openjdk-versions.json';
|
||||
let releases = null;
|
||||
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
const headers = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
const headers = util_1.getGitHubHttpHeaders();
|
||||
let response = null;
|
||||
if (core.isDebug()) {
|
||||
console.time('Retrieving available versions for Microsoft took'); // eslint-disable-line no-console
|
||||
@ -104263,7 +104284,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
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.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 path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
const fs = __importStar(__nccwpck_require__(7147));
|
||||
@ -104400,6 +104421,16 @@ function convertVersionToSemver(version) {
|
||||
return mainVersion;
|
||||
}
|
||||
exports.convertVersionToSemver = convertVersionToSemver;
|
||||
function getGitHubHttpHeaders() {
|
||||
const token = core.getInput('token');
|
||||
const auth = !token ? undefined : `token ${token}`;
|
||||
const headers = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
return headers;
|
||||
}
|
||||
exports.getGitHubHttpHeaders = getGitHubHttpHeaders;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
@ -4,12 +4,12 @@ import semver from 'semver';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
|
||||
import {JavaBase} from '../base-installer';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
getGitHubHttpHeaders,
|
||||
isVersionSatisfies
|
||||
} from '../../util';
|
||||
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
|
||||
@ -62,37 +62,26 @@ export class DragonwellDistribution extends JavaBase {
|
||||
const platform = this.getPlatformOption();
|
||||
const arch = this.distributionArchitecture();
|
||||
|
||||
const token = core.getInput('token');
|
||||
const auth = !token ? undefined : `token ${token}`;
|
||||
const owner = 'dragonwell-releng';
|
||||
const repository = 'dragonwell-setup-java';
|
||||
const branch = 'main';
|
||||
const filePath = 'releases.json';
|
||||
let fetchedDragonwellJson = await this.fetchJsonFromPrimaryUrl();
|
||||
|
||||
const availableVersionsUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
if (!fetchedDragonwellJson) {
|
||||
fetchedDragonwellJson = await this.fetchJsonFromBackupUrl();
|
||||
}
|
||||
|
||||
const headers: OutgoingHttpHeaders = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
|
||||
const fetchedDragonwellVersions = (
|
||||
await this.http.getJson<IDragonwellAllVersions>(
|
||||
availableVersionsUrl,
|
||||
headers
|
||||
)
|
||||
).result;
|
||||
|
||||
if (!fetchedDragonwellVersions) {
|
||||
if (!fetchedDragonwellJson) {
|
||||
throw new Error(
|
||||
`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`
|
||||
`Couldn't fetch dragonwell versions information from both primary and backup urls`
|
||||
);
|
||||
}
|
||||
|
||||
core.debug(
|
||||
'Successfully fetched information about available dragonwell versions'
|
||||
);
|
||||
|
||||
const availableVersions = this.parseVersions(
|
||||
platform,
|
||||
arch,
|
||||
fetchedDragonwellVersions
|
||||
fetchedDragonwellJson
|
||||
);
|
||||
|
||||
if (core.isDebug()) {
|
||||
@ -210,4 +199,48 @@ export class DragonwellDistribution extends JavaBase {
|
||||
return process.platform;
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchJsonFromPrimaryUrl(): Promise<IDragonwellAllVersions | null> {
|
||||
const primaryUrl = 'https://dragonwell-jdk.io/map_with_checksum.json';
|
||||
try {
|
||||
core.debug(
|
||||
`Trying to fetch available versions info from the primary url: ${primaryUrl}`
|
||||
);
|
||||
const fetchedDragonwellJson = (
|
||||
await this.http.getJson<IDragonwellAllVersions>(primaryUrl)
|
||||
).result;
|
||||
return fetchedDragonwellJson;
|
||||
} catch (err) {
|
||||
core.debug(
|
||||
`Fetching from the primary link: ${primaryUrl} ended up with the error: ${err.message}`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchJsonFromBackupUrl(): Promise<IDragonwellAllVersions | null> {
|
||||
const owner = 'dragonwell-releng';
|
||||
const repository = 'dragonwell-setup-java';
|
||||
const branch = 'main';
|
||||
const filePath = 'releases.json';
|
||||
|
||||
const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
|
||||
const headers = getGitHubHttpHeaders();
|
||||
|
||||
try {
|
||||
core.debug(
|
||||
`Trying to fetch available versions info from the backup url: ${backupUrl}`
|
||||
);
|
||||
const fetchedDragonwellVersions = (
|
||||
await this.http.getJson<IDragonwellAllVersions>(backupUrl, headers)
|
||||
).result;
|
||||
return fetchedDragonwellVersions;
|
||||
} catch (err) {
|
||||
core.debug(
|
||||
`Fetching from the backup url: ${backupUrl} ended up with the error: ${err.message}`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,13 @@ import {
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models';
|
||||
import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
getGitHubHttpHeaders
|
||||
} from '../../util';
|
||||
import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {ITypedResponse} from '@actions/http-client/interfaces';
|
||||
@ -85,8 +88,6 @@ export class MicrosoftDistributions extends JavaBase {
|
||||
private async getAvailableVersions(): Promise<tc.IToolRelease[] | null> {
|
||||
// TODO get these dynamically!
|
||||
// We will need Microsoft to add an endpoint where we can query for versions.
|
||||
const token = core.getInput('token');
|
||||
const auth = !token ? undefined : `token ${token}`;
|
||||
const owner = 'actions';
|
||||
const repository = 'setup-java';
|
||||
const branch = 'main';
|
||||
@ -96,10 +97,7 @@ export class MicrosoftDistributions extends JavaBase {
|
||||
let releases: tc.IToolRelease[] | null = null;
|
||||
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||
|
||||
const headers: OutgoingHttpHeaders = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
const headers = getGitHubHttpHeaders();
|
||||
|
||||
let response: ITypedResponse<tc.IToolRelease[]> | null = null;
|
||||
|
||||
|
11
src/util.ts
11
src/util.ts
@ -7,6 +7,7 @@ import * as core from '@actions/core';
|
||||
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import {INPUT_JOB_STATUS, DISTRIBUTIONS_ONLY_MAJOR_VERSION} from './constants';
|
||||
import {OutgoingHttpHeaders} from 'http';
|
||||
|
||||
export function getTempDir() {
|
||||
const tempDirectory = process.env['RUNNER_TEMP'] || os.tmpdir();
|
||||
@ -161,3 +162,13 @@ export function convertVersionToSemver(version: number[] | string) {
|
||||
}
|
||||
return mainVersion;
|
||||
}
|
||||
|
||||
export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
|
||||
const token = core.getInput('token');
|
||||
const auth = !token ? undefined : `token ${token}`;
|
||||
const headers: OutgoingHttpHeaders = {
|
||||
authorization: auth,
|
||||
accept: 'application/vnd.github.VERSION.raw'
|
||||
};
|
||||
return headers;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user