mirror of
https://github.com/julia-actions/setup-julia.git
synced 2026-02-17 21:46:54 +08:00
Use cached Julia if available
This commit is contained in:
@@ -66,34 +66,49 @@ function getFileName(version) {
|
|||||||
}
|
}
|
||||||
return `julia-${version}${versionExt}.${ext}`;
|
return `julia-${version}${versionExt}.${ext}`;
|
||||||
}
|
}
|
||||||
|
function installJulia(version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// Download Julia
|
||||||
|
const downloadURL = getDownloadURL(version);
|
||||||
|
core.debug(`downloading Julia from ${downloadURL}`);
|
||||||
|
const juliaDownloadPath = yield tc.downloadTool(downloadURL);
|
||||||
|
// Install it
|
||||||
|
switch (osPlat) {
|
||||||
|
case 'linux':
|
||||||
|
const juliaExtractedFolder = yield tc.extractTar(juliaDownloadPath);
|
||||||
|
return path.join(juliaExtractedFolder, `julia-${version}`);
|
||||||
|
case 'win32':
|
||||||
|
const juliaInstallationPath = path.join('C:', 'Julia');
|
||||||
|
yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`]);
|
||||||
|
return juliaInstallationPath;
|
||||||
|
case 'darwin':
|
||||||
|
yield exec.exec('hdiutil', ['attach', juliaDownloadPath]);
|
||||||
|
return `/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`;
|
||||||
|
default:
|
||||||
|
throw `Platform ${osPlat} is not supported`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const version = core.getInput('version');
|
const version = core.getInput('version');
|
||||||
core.debug(`selected Julia version: ${version}`);
|
core.debug(`selected Julia version: ${version}`);
|
||||||
// Download Julia
|
// Search in cache
|
||||||
const downloadURL = getDownloadURL(version);
|
let juliaPath;
|
||||||
core.debug(`download Julia from ${downloadURL}`);
|
juliaPath = tc.find('julia', version);
|
||||||
const juliaDownloadPath = yield tc.downloadTool(downloadURL);
|
if (!juliaPath) {
|
||||||
// Install Julia
|
core.debug(`could not find Julia ${version} in cache`);
|
||||||
if (osPlat === 'linux') { // Linux
|
const juliaInstallationPath = yield installJulia(version);
|
||||||
const juliaExtractedFolder = yield tc.extractTar(juliaDownloadPath);
|
// Add it to cache
|
||||||
const juliaCachedPath = yield tc.cacheDir(juliaExtractedFolder, 'julia', version);
|
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version);
|
||||||
const juliaPath = path.join(juliaCachedPath, `julia-${version}`);
|
core.debug(`added Julia to cache: ${juliaPath}`);
|
||||||
core.addPath(path.join(juliaPath, 'bin'));
|
|
||||||
}
|
}
|
||||||
else if (osPlat === 'win32') { // Windows
|
else {
|
||||||
// Install Julia in C:\Julia
|
core.debug(`using cached version of Julia: ${juliaPath}`);
|
||||||
const juliaInstallationPath = path.join('C:', 'Julia');
|
|
||||||
yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`]);
|
|
||||||
const juliaCachedPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version);
|
|
||||||
core.addPath(path.join(juliaCachedPath, 'bin'));
|
|
||||||
}
|
|
||||||
else if (osPlat === 'darwin') { // macOS
|
|
||||||
yield exec.exec('hdiutil', ['attach', juliaDownloadPath]);
|
|
||||||
const juliaCachedPath = yield tc.cacheDir(`/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`, 'julia', version);
|
|
||||||
core.addPath(path.join(juliaCachedPath, 'bin'));
|
|
||||||
}
|
}
|
||||||
|
// Add it to PATH
|
||||||
|
core.addPath(path.join(juliaPath, 'bin'));
|
||||||
// Test if Julia has been installed by showing versioninfo()
|
// Test if Julia has been installed by showing versioninfo()
|
||||||
yield exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']);
|
yield exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,36 +53,52 @@ function getFileName(version: string): string {
|
|||||||
return `julia-${version}${versionExt}.${ext}`
|
return `julia-${version}${versionExt}.${ext}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function installJulia(version: string): Promise<string> {
|
||||||
|
// Download Julia
|
||||||
|
const downloadURL = getDownloadURL(version)
|
||||||
|
core.debug(`downloading Julia from ${downloadURL}`)
|
||||||
|
const juliaDownloadPath = await tc.downloadTool(downloadURL)
|
||||||
|
|
||||||
|
// Install it
|
||||||
|
switch (osPlat) {
|
||||||
|
case 'linux':
|
||||||
|
const juliaExtractedFolder = await tc.extractTar(juliaDownloadPath)
|
||||||
|
return path.join(juliaExtractedFolder, `julia-${version}`)
|
||||||
|
case 'win32':
|
||||||
|
const juliaInstallationPath = path.join('C:', 'Julia')
|
||||||
|
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`])
|
||||||
|
return juliaInstallationPath
|
||||||
|
case 'darwin':
|
||||||
|
await exec.exec('hdiutil', ['attach', juliaDownloadPath])
|
||||||
|
return `/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`
|
||||||
|
default:
|
||||||
|
throw `Platform ${osPlat} is not supported`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const version = core.getInput('version')
|
const version = core.getInput('version')
|
||||||
core.debug(`selected Julia version: ${version}`)
|
core.debug(`selected Julia version: ${version}`)
|
||||||
|
|
||||||
// Download Julia
|
// Search in cache
|
||||||
const downloadURL = getDownloadURL(version)
|
let juliaPath: string;
|
||||||
core.debug(`download Julia from ${downloadURL}`)
|
juliaPath = tc.find('julia', version)
|
||||||
const juliaDownloadPath = await tc.downloadTool(downloadURL)
|
|
||||||
|
|
||||||
// Install Julia
|
if (!juliaPath) {
|
||||||
if (osPlat === 'linux') { // Linux
|
core.debug(`could not find Julia ${version} in cache`)
|
||||||
const juliaExtractedFolder = await tc.extractTar(juliaDownloadPath)
|
const juliaInstallationPath = await installJulia(version);
|
||||||
const juliaCachedPath = await tc.cacheDir(juliaExtractedFolder, 'julia', version)
|
|
||||||
const juliaPath = path.join(juliaCachedPath, `julia-${version}`)
|
// Add it to cache
|
||||||
core.addPath(path.join(juliaPath, 'bin'))
|
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version)
|
||||||
|
core.debug(`added Julia to cache: ${juliaPath}`)
|
||||||
} else if (osPlat === 'win32') { // Windows
|
} else {
|
||||||
// Install Julia in C:\Julia
|
core.debug(`using cached version of Julia: ${juliaPath}`)
|
||||||
const juliaInstallationPath = path.join('C:', 'Julia')
|
|
||||||
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`])
|
|
||||||
const juliaCachedPath = await tc.cacheDir(juliaInstallationPath, 'julia', version)
|
|
||||||
core.addPath(path.join(juliaCachedPath, 'bin'))
|
|
||||||
|
|
||||||
} else if (osPlat === 'darwin') { // macOS
|
|
||||||
await exec.exec('hdiutil', ['attach', juliaDownloadPath])
|
|
||||||
const juliaCachedPath = await tc.cacheDir(`/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`, 'julia', version)
|
|
||||||
core.addPath(path.join(juliaCachedPath, 'bin'))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add it to PATH
|
||||||
|
core.addPath(path.join(juliaPath, 'bin'))
|
||||||
|
|
||||||
// Test if Julia has been installed by showing versioninfo()
|
// Test if Julia has been installed by showing versioninfo()
|
||||||
await exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()'])
|
await exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()'])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user