使用qtoa作为Microsoft的java版本信息仓库

This commit is contained in:
moweilin 2024-01-20 10:59:21 +08:00
parent 7a445ee88d
commit 771fcd6a25
3 changed files with 4391 additions and 4299 deletions

8662
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ import * as tc from '@actions/tool-cache';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import {TypedResponse} from '@actions/http-client/lib/interfaces'; import {TypedResponse} from '@actions/http-client/lib/interfaces';
import * as this_e from '../../manifest-util';
export class MicrosoftDistributions extends JavaBase { export class MicrosoftDistributions extends JavaBase {
constructor(installerOptions: JavaInstallerOptions) { constructor(installerOptions: JavaInstallerOptions) {
super('Microsoft', installerOptions); super('Microsoft', installerOptions);
@ -63,7 +63,7 @@ export class MicrosoftDistributions extends JavaBase {
); );
} }
const manifest = await this.getAvailableVersions(); const manifest = await this_e.getAvailableVersions();
if (!manifest) { if (!manifest) {
throw new Error('Could not load manifest for Microsoft Build of OpenJDK'); throw new Error('Could not load manifest for Microsoft Build of OpenJDK');

24
src/manifest-util.ts Normal file
View File

@ -0,0 +1,24 @@
import * as httpm from '@actions/http-client'
import * as tc from '@actions/tool-cache';
import * as core from '@actions/core';
export async function getManifestFromRepo(
owner: string,
repo: string,
auth?: string,
branch = 'master'
): Promise<tc.IToolRelease[]> {
const manifestUrl = `https://git.qtoa.cn/${owner}/${repo}/raw/branch/${branch}/versions-manifest.json`
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache')
const headers: any = {}
const response = await http.getJson<tc.IToolRelease[]>(manifestUrl, headers)
const result = response.result ?? []
core.info(`versions-manifest.json:\n${result}`)
return result;
}
export async function getAvailableVersions(): Promise<tc.IToolRelease[] | null> {
const owner = 'actions';
const repository = 'java-versions';
const branch = 'main';
return await getManifestFromRepo(owner,repository,undefined,branch)
}