mirror of
https://github.com/julia-actions/setup-julia.git
synced 2026-02-12 02:56:54 +08:00
macOS: Default to tarball (.tar.gz) if available (#117)
* On macOS, first try to find a tarball (`.tar.gz`) file, but fall back to `.dmg` if we can't find a tarball * Add an "Example builds" job for Julia 1.2
This commit is contained in:
2
.github/workflows/example-builds.yml
vendored
2
.github/workflows/example-builds.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
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]
|
julia-arch: [x64, x86]
|
||||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||||
# 32-bit Julia binaries are not available on macOS
|
# 32-bit Julia binaries are not available on macOS
|
||||||
|
|||||||
57
lib/installer.js
generated
57
lib/installer.js
generated
@@ -102,30 +102,57 @@ function getJuliaVersion(availableReleases, versionInput) {
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
exports.getJuliaVersion = getJuliaVersion;
|
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) {
|
function getNightlyFileName(arch) {
|
||||||
let versionExt, ext;
|
let versionExt;
|
||||||
|
let fileExt1;
|
||||||
|
[fileExt1, ,] = getDesiredFileExts();
|
||||||
if (osPlat == 'win32') {
|
if (osPlat == 'win32') {
|
||||||
versionExt = arch == 'x64' ? '-win64' : '-win32';
|
versionExt = arch == 'x64' ? '-win64' : '-win32';
|
||||||
ext = 'exe';
|
|
||||||
}
|
}
|
||||||
else if (osPlat == 'darwin') {
|
else if (osPlat == 'darwin') {
|
||||||
if (arch == 'x86') {
|
if (arch == 'x86') {
|
||||||
throw new Error('32-bit Julia is not available on macOS');
|
throw new Error('32-bit Julia is not available on macOS');
|
||||||
}
|
}
|
||||||
versionExt = '-mac64';
|
versionExt = '-mac64';
|
||||||
ext = 'dmg';
|
|
||||||
}
|
}
|
||||||
else if (osPlat === 'linux') {
|
else if (osPlat === 'linux') {
|
||||||
versionExt = arch == 'x64' ? '-linux64' : '-linux32';
|
versionExt = arch == 'x64' ? '-linux64' : '-linux32';
|
||||||
ext = 'tar.gz';
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error(`Platform ${osPlat} is not supported`);
|
throw new Error(`Platform ${osPlat} is not supported`);
|
||||||
}
|
}
|
||||||
return `julia-latest${versionExt}.${ext}`;
|
return `julia-latest${versionExt}.${fileExt1}`;
|
||||||
}
|
}
|
||||||
function getFileInfo(versionInfo, version, arch) {
|
function getFileInfo(versionInfo, version, arch) {
|
||||||
const err = `Could not find ${archMap[arch]}/${version} binaries`;
|
const err = `Could not find ${archMap[arch]}/${version} binaries`;
|
||||||
|
let fileExt1;
|
||||||
|
let hasFileExt2;
|
||||||
|
let fileExt2;
|
||||||
|
[fileExt1, hasFileExt2, fileExt2] = getDesiredFileExts();
|
||||||
if (version.endsWith('nightly')) {
|
if (version.endsWith('nightly')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -134,9 +161,21 @@ function getFileInfo(versionInfo, version, arch) {
|
|||||||
}
|
}
|
||||||
for (let file of versionInfo[version].files) {
|
for (let file of versionInfo[version].files) {
|
||||||
if (file.os == osMap[osPlat] && file.arch == archMap[arch]) {
|
if (file.os == osMap[osPlat] && file.arch == archMap[arch]) {
|
||||||
|
if (file.extension == fileExt1) {
|
||||||
return file;
|
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;
|
throw err;
|
||||||
}
|
}
|
||||||
exports.getFileInfo = getFileInfo;
|
exports.getFileInfo = getFileInfo;
|
||||||
@@ -201,9 +240,17 @@ function installJulia(versionInfo, version, arch) {
|
|||||||
}
|
}
|
||||||
return tempInstallDir;
|
return tempInstallDir;
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
|
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('hdiutil', ['attach', juliaDownloadPath]);
|
||||||
yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]);
|
yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]);
|
||||||
return path.join(tempInstallDir, 'julia');
|
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:
|
default:
|
||||||
throw new Error(`Platform ${osPlat} is not supported`);
|
throw new Error(`Platform ${osPlat} is not supported`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,31 +93,59 @@ export function getJuliaVersion(availableReleases: string[], versionInput: strin
|
|||||||
return version
|
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 {
|
function getNightlyFileName(arch: string): string {
|
||||||
let versionExt: string, ext: string
|
let versionExt: string
|
||||||
|
let fileExt1: string
|
||||||
|
[fileExt1, , ] = getDesiredFileExts()
|
||||||
|
|
||||||
if (osPlat == 'win32') {
|
if (osPlat == 'win32') {
|
||||||
versionExt = arch == 'x64' ? '-win64' : '-win32'
|
versionExt = arch == 'x64' ? '-win64' : '-win32'
|
||||||
ext = 'exe'
|
|
||||||
} else if (osPlat == 'darwin') {
|
} else if (osPlat == 'darwin') {
|
||||||
if (arch == 'x86') {
|
if (arch == 'x86') {
|
||||||
throw new Error('32-bit Julia is not available on macOS')
|
throw new Error('32-bit Julia is not available on macOS')
|
||||||
}
|
}
|
||||||
versionExt = '-mac64'
|
versionExt = '-mac64'
|
||||||
ext = 'dmg'
|
|
||||||
} else if (osPlat === 'linux') {
|
} else if (osPlat === 'linux') {
|
||||||
versionExt = arch == 'x64' ? '-linux64' : '-linux32'
|
versionExt = arch == 'x64' ? '-linux64' : '-linux32'
|
||||||
ext = 'tar.gz'
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Platform ${osPlat} is not supported`)
|
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) {
|
export function getFileInfo(versionInfo, version: string, arch: string) {
|
||||||
const err = `Could not find ${archMap[arch]}/${version} binaries`
|
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')) {
|
if (version.endsWith('nightly')) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -128,9 +156,22 @@ export function getFileInfo(versionInfo, version: string, arch: string) {
|
|||||||
|
|
||||||
for (let file of versionInfo[version].files) {
|
for (let file of versionInfo[version].files) {
|
||||||
if (file.os == osMap[osPlat] && file.arch == archMap[arch]) {
|
if (file.os == osMap[osPlat] && file.arch == archMap[arch]) {
|
||||||
|
if (file.extension == fileExt1) {
|
||||||
return file
|
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
|
throw err
|
||||||
}
|
}
|
||||||
@@ -172,7 +213,6 @@ export async function installJulia(versionInfo, version: string, arch: string):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// Verify checksum
|
// Verify checksum
|
||||||
if (!version.endsWith('nightly')) {
|
if (!version.endsWith('nightly')) {
|
||||||
const checkSum = await calculateChecksum(juliaDownloadPath)
|
const checkSum = await calculateChecksum(juliaDownloadPath)
|
||||||
@@ -201,9 +241,16 @@ export async function installJulia(versionInfo, version: string, arch: string):
|
|||||||
}
|
}
|
||||||
return tempInstallDir
|
return tempInstallDir
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
|
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('hdiutil', ['attach', juliaDownloadPath])
|
||||||
await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`])
|
await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`])
|
||||||
return path.join(tempInstallDir, 'julia')
|
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:
|
default:
|
||||||
throw new Error(`Platform ${osPlat} is not supported`)
|
throw new Error(`Platform ${osPlat} is not supported`)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user