diff --git a/.github/workflows/example-builds.yml b/.github/workflows/example-builds.yml index f3ebd9d..7af6411 100644 --- a/.github/workflows/example-builds.yml +++ b/.github/workflows/example-builds.yml @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - julia-version: ['1.0.5', '1', '^1.5.0-beta1'] + julia-version: ['1.0.5', '1.2', '^1.5.0-beta1', '1'] julia-arch: [x64, x86] os: [ubuntu-latest, macOS-latest, windows-latest] # 32-bit Julia binaries are not available on macOS diff --git a/lib/installer.js b/lib/installer.js index e97e625..6b2a9d4 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -102,30 +102,57 @@ function getJuliaVersion(availableReleases, versionInput) { return version; } exports.getJuliaVersion = getJuliaVersion; +function getDesiredFileExts() { + let fileExt1; + let hasFileExt2; + let fileExt2; + if (osPlat == 'win32') { + fileExt1 = 'exe'; + hasFileExt2 = false; + fileExt2 = ''; + } + else if (osPlat == 'darwin') { + fileExt1 = 'tar.gz'; + hasFileExt2 = true; + fileExt2 = 'dmg'; + } + else if (osPlat === 'linux') { + fileExt1 = 'tar.gz'; + hasFileExt2 = false; + fileExt2 = ''; + } + else { + throw new Error(`Platform ${osPlat} is not supported`); + } + return [fileExt1, hasFileExt2, fileExt2]; +} function getNightlyFileName(arch) { - let versionExt, ext; + let versionExt; + let fileExt1; + [fileExt1, ,] = getDesiredFileExts(); if (osPlat == 'win32') { versionExt = arch == 'x64' ? '-win64' : '-win32'; - ext = 'exe'; } else if (osPlat == 'darwin') { if (arch == 'x86') { throw new Error('32-bit Julia is not available on macOS'); } versionExt = '-mac64'; - ext = 'dmg'; } else if (osPlat === 'linux') { versionExt = arch == 'x64' ? '-linux64' : '-linux32'; - ext = 'tar.gz'; } else { throw new Error(`Platform ${osPlat} is not supported`); } - return `julia-latest${versionExt}.${ext}`; + return `julia-latest${versionExt}.${fileExt1}`; } function getFileInfo(versionInfo, version, arch) { const err = `Could not find ${archMap[arch]}/${version} binaries`; + let fileExt1; + let hasFileExt2; + let fileExt2; + [fileExt1, hasFileExt2, fileExt2] = getDesiredFileExts(); if (version.endsWith('nightly')) { return null; } @@ -134,7 +161,19 @@ function getFileInfo(versionInfo, version, arch) { } for (let file of versionInfo[version].files) { if (file.os == osMap[osPlat] && file.arch == archMap[arch]) { - return file; + if (file.extension == fileExt1) { + return file; + } + } + } + if (hasFileExt2) { + core.debug(`Could not find ${fileExt1}; trying to find ${fileExt2} instead`); + for (let file of versionInfo[version].files) { + if (file.os == osMap[osPlat] && file.arch == archMap[arch]) { + if (file.extension == fileExt2) { + return file; + } + } } } throw err; @@ -201,9 +240,17 @@ function installJulia(versionInfo, version, arch) { } return tempInstallDir; case 'darwin': - yield exec.exec('hdiutil', ['attach', juliaDownloadPath]); - yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]); - return path.join(tempInstallDir, 'julia'); + if (fileInfo !== null && fileInfo.extension == 'dmg') { + core.debug(`Support for .dmg files is deprecated and may be removed in a future release`); + yield exec.exec('hdiutil', ['attach', juliaDownloadPath]); + yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]); + return path.join(tempInstallDir, 'julia'); + } + else { + // tc.extractTar doesn't support stripping components, so we have to call tar manually + yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]); + return tempInstallDir; + } default: throw new Error(`Platform ${osPlat} is not supported`); } diff --git a/src/installer.ts b/src/installer.ts index 8a1e94b..9307706 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -93,31 +93,59 @@ export function getJuliaVersion(availableReleases: string[], versionInput: strin return version } +function getDesiredFileExts(): [string, boolean, string] { + let fileExt1: string + let hasFileExt2: boolean + let fileExt2: string + + if (osPlat == 'win32') { + fileExt1 = 'exe' + hasFileExt2 = false + fileExt2 = '' + } else if (osPlat == 'darwin') { + fileExt1 = 'tar.gz' + hasFileExt2 = true + fileExt2 = 'dmg' + } else if (osPlat === 'linux') { + fileExt1 = 'tar.gz' + hasFileExt2 = false + fileExt2 = '' + } else { + throw new Error(`Platform ${osPlat} is not supported`) + } + + return [fileExt1, hasFileExt2, fileExt2] +} + function getNightlyFileName(arch: string): string { - let versionExt: string, ext: string + let versionExt: string + let fileExt1: string + [fileExt1, , ] = getDesiredFileExts() if (osPlat == 'win32') { versionExt = arch == 'x64' ? '-win64' : '-win32' - ext = 'exe' } else if (osPlat == 'darwin') { if (arch == 'x86') { throw new Error('32-bit Julia is not available on macOS') } versionExt = '-mac64' - ext = 'dmg' } else if (osPlat === 'linux') { versionExt = arch == 'x64' ? '-linux64' : '-linux32' - ext = 'tar.gz' } else { throw new Error(`Platform ${osPlat} is not supported`) } - return `julia-latest${versionExt}.${ext}` + return `julia-latest${versionExt}.${fileExt1}` } export function getFileInfo(versionInfo, version: string, arch: string) { const err = `Could not find ${archMap[arch]}/${version} binaries` + let fileExt1: string + let hasFileExt2: boolean + let fileExt2: string + [fileExt1, hasFileExt2, fileExt2] = getDesiredFileExts() + if (version.endsWith('nightly')) { return null } @@ -128,7 +156,20 @@ export function getFileInfo(versionInfo, version: string, arch: string) { for (let file of versionInfo[version].files) { if (file.os == osMap[osPlat] && file.arch == archMap[arch]) { - return file + if (file.extension == fileExt1) { + return file + } + } + } + + if (hasFileExt2) { + core.debug(`Could not find ${fileExt1}; trying to find ${fileExt2} instead`) + for (let file of versionInfo[version].files) { + if (file.os == osMap[osPlat] && file.arch == archMap[arch]) { + if (file.extension == fileExt2) { + return file + } + } } } @@ -172,7 +213,6 @@ export async function installJulia(versionInfo, version: string, arch: string): } }) - // Verify checksum if (!version.endsWith('nightly')) { const checkSum = await calculateChecksum(juliaDownloadPath) @@ -201,9 +241,16 @@ export async function installJulia(versionInfo, version: string, arch: string): } return tempInstallDir case 'darwin': - await exec.exec('hdiutil', ['attach', juliaDownloadPath]) - await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]) - return path.join(tempInstallDir, 'julia') + if (fileInfo !== null && fileInfo.extension == 'dmg') { + core.debug(`Support for .dmg files is deprecated and may be removed in a future release`) + await exec.exec('hdiutil', ['attach', juliaDownloadPath]) + await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]) + return path.join(tempInstallDir, 'julia') + } else { + // tc.extractTar doesn't support stripping components, so we have to call tar manually + await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]) + return tempInstallDir + } default: throw new Error(`Platform ${osPlat} is not supported`) }