mirror of
https://github.com/julia-actions/setup-julia.git
synced 2026-02-12 02:56:54 +08:00
Support 32-bit Julia binaries
This commit is contained in:
@@ -5,6 +5,10 @@ inputs:
|
||||
version:
|
||||
description: 'The Julia version to download (if necessary) and use. Example: 1.0.4'
|
||||
default: '1.0.4'
|
||||
arch:
|
||||
description: 'Architecture of the Julia binaries. Defaults to x64.'
|
||||
required: false
|
||||
default: 'x64'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'lib/setup-julia.js'
|
||||
|
||||
@@ -26,39 +26,42 @@ core.debug(`platform: ${osPlat}`);
|
||||
function getMajorMinorVersion(version) {
|
||||
return version.split('.').slice(0, 2).join('.');
|
||||
}
|
||||
function getDownloadURL(version) {
|
||||
function getDownloadURL(version, arch) {
|
||||
const baseURL = 'https://julialang-s3.julialang.org/bin';
|
||||
let platform, arch;
|
||||
let platform;
|
||||
const versionDir = getMajorMinorVersion(version);
|
||||
if (osPlat === 'win32') { // Windows
|
||||
platform = 'winnt';
|
||||
arch = 'x64';
|
||||
}
|
||||
else if (osPlat === 'darwin') { // macOS
|
||||
if (arch == 'x86') {
|
||||
throw '32-bit Julia is not available on macOS';
|
||||
}
|
||||
platform = 'mac';
|
||||
arch = 'x64';
|
||||
}
|
||||
else if (osPlat === 'linux') { // Linux
|
||||
platform = 'linux';
|
||||
arch = 'x64';
|
||||
}
|
||||
else {
|
||||
throw `Platform ${osPlat} is not supported`;
|
||||
}
|
||||
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version)}`;
|
||||
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`;
|
||||
}
|
||||
function getFileName(version) {
|
||||
function getFileName(version, arch) {
|
||||
let versionExt, ext;
|
||||
if (osPlat === 'win32') { // Windows
|
||||
versionExt = '-win64';
|
||||
versionExt = arch == 'x64' ? '-win64' : '-win32';
|
||||
ext = 'exe';
|
||||
}
|
||||
else if (osPlat === 'darwin') { // macOS
|
||||
if (arch == 'x86') {
|
||||
throw '32-bit Julia is not available on macOS';
|
||||
}
|
||||
versionExt = '-mac64';
|
||||
ext = 'dmg';
|
||||
}
|
||||
else if (osPlat === 'linux') { // Linux
|
||||
versionExt = '-linux-x86_64';
|
||||
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686';
|
||||
ext = 'tar.gz';
|
||||
}
|
||||
else {
|
||||
@@ -66,10 +69,10 @@ function getFileName(version) {
|
||||
}
|
||||
return `julia-${version}${versionExt}.${ext}`;
|
||||
}
|
||||
function installJulia(version) {
|
||||
function installJulia(version, arch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// Download Julia
|
||||
const downloadURL = getDownloadURL(version);
|
||||
const downloadURL = getDownloadURL(version, arch);
|
||||
core.debug(`downloading Julia from ${downloadURL}`);
|
||||
const juliaDownloadPath = yield tc.downloadTool(downloadURL);
|
||||
// Install it
|
||||
@@ -93,15 +96,16 @@ function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const version = core.getInput('version');
|
||||
core.debug(`selected Julia version: ${version}`);
|
||||
const arch = core.getInput('arch');
|
||||
core.debug(`selected Julia version: ${arch}/${version}`);
|
||||
// Search in cache
|
||||
let juliaPath;
|
||||
juliaPath = tc.find('julia', version);
|
||||
juliaPath = tc.find('julia', version, arch);
|
||||
if (!juliaPath) {
|
||||
core.debug(`could not find Julia ${version} in cache`);
|
||||
const juliaInstallationPath = yield installJulia(version);
|
||||
const juliaInstallationPath = yield installJulia(version, arch);
|
||||
// Add it to cache
|
||||
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version);
|
||||
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch);
|
||||
core.debug(`added Julia to cache: ${juliaPath}`);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -13,38 +13,41 @@ function getMajorMinorVersion(version: string): string {
|
||||
return version.split('.').slice(0, 2).join('.')
|
||||
}
|
||||
|
||||
function getDownloadURL(version: string): string {
|
||||
function getDownloadURL(version: string, arch: string): string {
|
||||
const baseURL = 'https://julialang-s3.julialang.org/bin'
|
||||
let platform: string, arch: string
|
||||
let platform: string
|
||||
const versionDir = getMajorMinorVersion(version)
|
||||
|
||||
if (osPlat === 'win32') { // Windows
|
||||
platform = 'winnt'
|
||||
arch = 'x64'
|
||||
} else if (osPlat === 'darwin') { // macOS
|
||||
if (arch == 'x86') {
|
||||
throw '32-bit Julia is not available on macOS'
|
||||
}
|
||||
platform = 'mac'
|
||||
arch = 'x64'
|
||||
} else if (osPlat === 'linux') { // Linux
|
||||
platform = 'linux'
|
||||
arch = 'x64'
|
||||
} else {
|
||||
throw `Platform ${osPlat} is not supported`
|
||||
}
|
||||
|
||||
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version)}`
|
||||
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`
|
||||
}
|
||||
|
||||
function getFileName(version: string): string {
|
||||
function getFileName(version: string, arch: string): string {
|
||||
let versionExt: string, ext: string
|
||||
|
||||
if (osPlat === 'win32') { // Windows
|
||||
versionExt = '-win64'
|
||||
versionExt = arch == 'x64' ? '-win64' : '-win32'
|
||||
ext = 'exe'
|
||||
} else if (osPlat === 'darwin') { // macOS
|
||||
if (arch == 'x86') {
|
||||
throw '32-bit Julia is not available on macOS'
|
||||
}
|
||||
versionExt = '-mac64'
|
||||
ext = 'dmg'
|
||||
} else if (osPlat === 'linux') { // Linux
|
||||
versionExt = '-linux-x86_64'
|
||||
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686'
|
||||
ext = 'tar.gz'
|
||||
} else {
|
||||
throw `Platform ${osPlat} is not supported`
|
||||
@@ -53,9 +56,9 @@ function getFileName(version: string): string {
|
||||
return `julia-${version}${versionExt}.${ext}`
|
||||
}
|
||||
|
||||
async function installJulia(version: string): Promise<string> {
|
||||
async function installJulia(version: string, arch: string): Promise<string> {
|
||||
// Download Julia
|
||||
const downloadURL = getDownloadURL(version)
|
||||
const downloadURL = getDownloadURL(version, arch)
|
||||
core.debug(`downloading Julia from ${downloadURL}`)
|
||||
const juliaDownloadPath = await tc.downloadTool(downloadURL)
|
||||
|
||||
@@ -79,18 +82,19 @@ async function installJulia(version: string): Promise<string> {
|
||||
async function run() {
|
||||
try {
|
||||
const version = core.getInput('version')
|
||||
core.debug(`selected Julia version: ${version}`)
|
||||
const arch = core.getInput('arch')
|
||||
core.debug(`selected Julia version: ${arch}/${version}`)
|
||||
|
||||
// Search in cache
|
||||
let juliaPath: string;
|
||||
juliaPath = tc.find('julia', version)
|
||||
juliaPath = tc.find('julia', version, arch)
|
||||
|
||||
if (!juliaPath) {
|
||||
core.debug(`could not find Julia ${version} in cache`)
|
||||
const juliaInstallationPath = await installJulia(version);
|
||||
const juliaInstallationPath = await installJulia(version, arch);
|
||||
|
||||
// Add it to cache
|
||||
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version)
|
||||
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch)
|
||||
core.debug(`added Julia to cache: ${juliaPath}`)
|
||||
} else {
|
||||
core.debug(`using cached version of Julia: ${juliaPath}`)
|
||||
|
||||
Reference in New Issue
Block a user