From a7c1edc063c1692f1e842cb3db31070095a9690e Mon Sep 17 00:00:00 2001 From: Sascha Mann Date: Wed, 21 Aug 2019 15:34:52 +0200 Subject: [PATCH] Support 32-bit Julia binaries --- action.yml | 4 ++++ lib/setup-julia.js | 34 +++++++++++++++++++--------------- src/setup-julia.ts | 34 +++++++++++++++++++--------------- 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/action.yml b/action.yml index 539dd09..4fef336 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/lib/setup-julia.js b/lib/setup-julia.js index 52a24fa..93079c6 100644 --- a/lib/setup-julia.js +++ b/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 { diff --git a/src/setup-julia.ts b/src/setup-julia.ts index 5436d3c..8dc74ff 100644 --- a/src/setup-julia.ts +++ b/src/setup-julia.ts @@ -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 { +async function installJulia(version: string, arch: string): Promise { // 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 { 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}`)