Compare commits

..

No commits in common. "2e4e4de3b40545707193845e18b18d0fb7cfb4e5" and "cf4e1422a00f261bdaf87904e8ae63ed1d2ad2dd" have entirely different histories.

5 changed files with 54 additions and 137 deletions

12
dist/cleanup/index.js vendored
View File

@ -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.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.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,16 +67157,6 @@ 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
View File

@ -102683,15 +102683,22 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
return __awaiter(this, void 0, void 0, function* () {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
let fetchedDragonwellJson = yield this.fetchJsonFromPrimaryUrl();
if (!fetchedDragonwellJson) {
fetchedDragonwellJson = yield this.fetchJsonFromBackupUrl();
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}`);
}
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);
const availableVersions = this.parseVersions(platform, arch, fetchedDragonwellVersions);
if (core.isDebug()) {
core.startGroup('Print information about available versions');
core.debug(availableVersions.map(item => item.jdk_version).join(', '));
@ -102776,39 +102783,6 @@ 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;
@ -103185,13 +103159,18 @@ 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 = util_1.getGitHubHttpHeaders();
const headers = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw'
};
let response = null;
if (core.isDebug()) {
console.time('Retrieving available versions for Microsoft took'); // eslint-disable-line no-console
@ -104284,7 +104263,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
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.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));
@ -104421,16 +104400,6 @@ 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;
/***/ }),

View File

@ -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,26 +62,37 @@ export class DragonwellDistribution extends JavaBase {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
let fetchedDragonwellJson = await this.fetchJsonFromPrimaryUrl();
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';
if (!fetchedDragonwellJson) {
fetchedDragonwellJson = await this.fetchJsonFromBackupUrl();
}
const availableVersionsUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
if (!fetchedDragonwellJson) {
const headers: OutgoingHttpHeaders = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw'
};
const fetchedDragonwellVersions = (
await this.http.getJson<IDragonwellAllVersions>(
availableVersionsUrl,
headers
)
).result;
if (!fetchedDragonwellVersions) {
throw new Error(
`Couldn't fetch dragonwell versions information from both primary and backup urls`
`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`
);
}
core.debug(
'Successfully fetched information about available dragonwell versions'
);
const availableVersions = this.parseVersions(
platform,
arch,
fetchedDragonwellJson
fetchedDragonwellVersions
);
if (core.isDebug()) {
@ -199,48 +210,4 @@ 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;
}
}
}

View File

@ -4,13 +4,10 @@ import {
JavaInstallerOptions,
JavaInstallerResults
} from '../base-models';
import {
extractJdkFile,
getDownloadArchiveExtension,
getGitHubHttpHeaders
} from '../../util';
import {extractJdkFile, getDownloadArchiveExtension} 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';
@ -88,6 +85,8 @@ 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';
@ -97,7 +96,10 @@ 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 = getGitHubHttpHeaders();
const headers: OutgoingHttpHeaders = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw'
};
let response: ITypedResponse<tc.IToolRelease[]> | null = null;

View File

@ -7,7 +7,6 @@ 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();
@ -162,13 +161,3 @@ 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;
}