mirror of
https://github.com/graalvm/setup-graalvm.git
synced 2025-12-06 07:48:06 +08:00
19
dist/main.js
generated
vendored
19
dist/main.js
generated
vendored
@@ -3,7 +3,7 @@ import require$$0$4, { createHash, randomUUID as randomUUID$2, createHmac } from
|
||||
import * as fs from 'fs';
|
||||
import fs__default, { readdirSync, readFileSync, existsSync } from 'fs';
|
||||
import * as require$$1$1 from 'path';
|
||||
import require$$1__default, { join, basename as basename$1 } from 'path';
|
||||
import require$$1__default, { join, extname, basename as basename$1 } from 'path';
|
||||
import require$$0$5 from 'http';
|
||||
import require$$1$2 from 'https';
|
||||
import require$$0$7 from 'net';
|
||||
@@ -38705,6 +38705,15 @@ async function downloadExtractAndCacheJDK(downloader, toolName, version) {
|
||||
}
|
||||
return findJavaHomeInSubfolder(toolPath);
|
||||
}
|
||||
async function downloadFile(downloadUrl) {
|
||||
const dest = join(_getTempDirectory(), crypto.randomUUID(), extname(downloadUrl));
|
||||
return toolCacheExports.downloadTool(downloadUrl, dest);
|
||||
}
|
||||
function _getTempDirectory() {
|
||||
const tempDirectory = process.env['RUNNER_TEMP'] || '';
|
||||
ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
|
||||
return tempDirectory;
|
||||
}
|
||||
function calculateSHA256(filePath) {
|
||||
const hashSum = createHash('sha256');
|
||||
hashSum.update(readFileSync(filePath));
|
||||
@@ -40549,7 +40558,7 @@ function determineToolName$2(javaVersion, isCommunity) {
|
||||
}
|
||||
async function downloadGraalVMJDK(downloadUrl, javaVersion) {
|
||||
try {
|
||||
return await toolCacheExports.downloadTool(downloadUrl);
|
||||
return await downloadFile(downloadUrl);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
@@ -40636,7 +40645,7 @@ async function downloadGraalVMCELegacy(version, javaVersion) {
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(false, version, javaVersion);
|
||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${GRAALVM_FILE_EXTENSION}`;
|
||||
try {
|
||||
return await toolCacheExports.downloadTool(downloadUrl);
|
||||
return await downloadFile(downloadUrl);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
@@ -93574,7 +93583,7 @@ async function setUpLiberica(javaVersion, javaPackage) {
|
||||
const resolvedJavaVersion = await findLatestLibericaJavaVersion(javaVersion);
|
||||
const downloadUrl = await findLibericaURL(resolvedJavaVersion, javaPackage);
|
||||
const toolName = determineToolName(javaVersion, javaPackage);
|
||||
return downloadExtractAndCacheJDK(async () => toolCacheExports.downloadTool(downloadUrl), toolName, javaVersion);
|
||||
return downloadExtractAndCacheJDK(async () => downloadFile(downloadUrl), toolName, javaVersion);
|
||||
}
|
||||
async function findLatestLibericaJavaVersion(javaVersion) {
|
||||
const matchingRefs = await getMatchingTags(LIBERICA_GH_USER, LIBERICA_RELEASES_REPO, `${LIBERICA_JDK_TAG_PREFIX}${javaVersion}`);
|
||||
@@ -93667,7 +93676,7 @@ async function setUpNativeImageMusl() {
|
||||
}
|
||||
else {
|
||||
coreExports.startGroup(`Setting up musl for GraalVM Native Image...`);
|
||||
const muslDownloadPath = await toolCacheExports.downloadTool(`https://gds.oracle.com/download/bfs/archive/musl-toolchain-${MUSL_VERSION}-linux-amd64.tar.gz`);
|
||||
const muslDownloadPath = await downloadFile(`https://gds.oracle.com/download/bfs/archive/musl-toolchain-${MUSL_VERSION}-linux-amd64.tar.gz`);
|
||||
const muslExtractPath = await toolCacheExports.extractTar(muslDownloadPath);
|
||||
const muslPath = join(muslExtractPath, MUSL_NAME);
|
||||
coreExports.info(`Adding ${MUSL_NAME} ${MUSL_VERSION} to tool-cache ...`);
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as c from '../constants.js'
|
||||
import * as core from '@actions/core'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import { join } from 'path'
|
||||
import { downloadFile } from '../utils.js'
|
||||
|
||||
const MUSL_NAME = 'musl-toolchain'
|
||||
const MUSL_VERSION = '1.2.5-oracle-00001'
|
||||
@@ -16,7 +17,7 @@ export async function setUpNativeImageMusl(): Promise<void> {
|
||||
core.info(`Found ${MUSL_NAME} ${MUSL_VERSION} in tool-cache @ ${toolPath}`)
|
||||
} else {
|
||||
core.startGroup(`Setting up musl for GraalVM Native Image...`)
|
||||
const muslDownloadPath = await tc.downloadTool(
|
||||
const muslDownloadPath = await downloadFile(
|
||||
`https://gds.oracle.com/download/bfs/archive/musl-toolchain-${MUSL_VERSION}-linux-amd64.tar.gz`
|
||||
)
|
||||
const muslExtractPath = await tc.extractTar(muslDownloadPath)
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as c from './constants.js'
|
||||
import * as core from '@actions/core'
|
||||
import * as semver from 'semver'
|
||||
import {
|
||||
downloadFile,
|
||||
downloadAndExtractJDK,
|
||||
downloadExtractAndCacheJDK,
|
||||
getContents,
|
||||
@@ -10,7 +11,6 @@ import {
|
||||
getTaggedRelease
|
||||
} from './utils.js'
|
||||
import { downloadGraalVM, downloadGraalVMEELegacy } from './gds.js'
|
||||
import { downloadTool } from '@actions/tool-cache'
|
||||
import { basename } from 'path'
|
||||
|
||||
const GRAALVM_DL_BASE = 'https://download.oracle.com/graalvm'
|
||||
@@ -153,7 +153,7 @@ function determineToolName(javaVersion: string, isCommunity: boolean) {
|
||||
|
||||
async function downloadGraalVMJDK(downloadUrl: string, javaVersion: string): Promise<string> {
|
||||
try {
|
||||
return await downloadTool(downloadUrl)
|
||||
return await downloadFile(downloadUrl)
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
// Not Found
|
||||
@@ -260,7 +260,7 @@ async function downloadGraalVMCELegacy(version: string, javaVersion: string): Pr
|
||||
const graalVMIdentifier = determineGraalVMLegacyIdentifier(false, version, javaVersion)
|
||||
const downloadUrl = `${GRAALVM_CE_DL_BASE}/${GRAALVM_TAG_PREFIX}${version}/${graalVMIdentifier}${c.GRAALVM_FILE_EXTENSION}`
|
||||
try {
|
||||
return await downloadTool(downloadUrl)
|
||||
return await downloadFile(downloadUrl)
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.includes('404')) {
|
||||
// Not Found
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as c from './constants.js'
|
||||
import * as semver from 'semver'
|
||||
import { downloadExtractAndCacheJDK, getTaggedRelease, getMatchingTags } from './utils.js'
|
||||
import { downloadTool } from '@actions/tool-cache'
|
||||
import { downloadFile, downloadExtractAndCacheJDK, getTaggedRelease, getMatchingTags } from './utils.js'
|
||||
import { spawnSync } from 'child_process'
|
||||
|
||||
const LIBERICA_GH_USER = 'bell-sw'
|
||||
@@ -13,7 +12,7 @@ export async function setUpLiberica(javaVersion: string, javaPackage: string): P
|
||||
const resolvedJavaVersion = await findLatestLibericaJavaVersion(javaVersion)
|
||||
const downloadUrl = await findLibericaURL(resolvedJavaVersion, javaPackage)
|
||||
const toolName = determineToolName(javaVersion, javaPackage)
|
||||
return downloadExtractAndCacheJDK(async () => downloadTool(downloadUrl), toolName, javaVersion)
|
||||
return downloadExtractAndCacheJDK(async () => downloadFile(downloadUrl), toolName, javaVersion)
|
||||
}
|
||||
|
||||
export async function findLatestLibericaJavaVersion(javaVersion: string): Promise<string> {
|
||||
|
||||
14
src/utils.ts
14
src/utils.ts
@@ -5,9 +5,10 @@ import * as semver from 'semver'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import * as fs from 'fs'
|
||||
import { ExecOptions, exec as e } from '@actions/exec'
|
||||
import { ok } from 'assert'
|
||||
import { readFileSync, readdirSync } from 'fs'
|
||||
import { createHash } from 'crypto'
|
||||
import { join } from 'path'
|
||||
import { extname, join } from 'path'
|
||||
import { tmpdir } from 'os'
|
||||
import { GitHub } from '@actions/github/lib/utils.js'
|
||||
|
||||
@@ -86,6 +87,17 @@ export async function downloadExtractAndCacheJDK(
|
||||
return findJavaHomeInSubfolder(toolPath)
|
||||
}
|
||||
|
||||
export async function downloadFile(downloadUrl: string): Promise<string> {
|
||||
const dest = join(_getTempDirectory(), crypto.randomUUID(), extname(downloadUrl))
|
||||
return tc.downloadTool(downloadUrl, dest)
|
||||
}
|
||||
|
||||
function _getTempDirectory(): string {
|
||||
const tempDirectory = process.env['RUNNER_TEMP'] || ''
|
||||
ok(tempDirectory, 'Expected RUNNER_TEMP to be defined')
|
||||
return tempDirectory
|
||||
}
|
||||
|
||||
export function calculateSHA256(filePath: string): string {
|
||||
const hashSum = createHash('sha256')
|
||||
hashSum.update(readFileSync(filePath))
|
||||
|
||||
Reference in New Issue
Block a user