mirror of
https://github.com/julia-actions/setup-julia.git
synced 2026-02-12 02:56:54 +08:00
94 lines
4.5 KiB
JavaScript
Generated
94 lines
4.5 KiB
JavaScript
Generated
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const core = __importStar(require("@actions/core"));
|
|
const exec = __importStar(require("@actions/exec"));
|
|
const tc = __importStar(require("@actions/tool-cache"));
|
|
const fs = __importStar(require("fs"));
|
|
const https = __importStar(require("https"));
|
|
const path = __importStar(require("path"));
|
|
const installer = __importStar(require("./installer"));
|
|
function run() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
// Debugging info
|
|
if (core.isDebug()) {
|
|
// Log Runner IP Address
|
|
https.get('https://httpbin.julialang.org/ip', resp => {
|
|
let data = '';
|
|
resp.on('data', chunk => {
|
|
data += chunk;
|
|
});
|
|
resp.on('end', () => {
|
|
core.debug(`Runner IP address: ${JSON.parse(data).origin}`);
|
|
});
|
|
}).on('error', err => {
|
|
core.debug(`ERROR: Could not retrieve runner IP: ${err}`);
|
|
});
|
|
}
|
|
// Inputs
|
|
const versionInput = core.getInput('version');
|
|
const arch = core.getInput('arch');
|
|
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
|
|
// while the strategy matrix only contains a key `${{ matrix.version }}`.
|
|
// In that case, we want the action to fail, rather than trying to download julia from an URL that's missing parts and 404ing.
|
|
// We _could_ fall back to the default but that means that builds silently do things differently than they're meant to, which
|
|
// is worse than failing the build.
|
|
if (!versionInput) {
|
|
throw new Error('Version input must not be null');
|
|
}
|
|
if (!arch) {
|
|
throw new Error(`Arch input must not be null`);
|
|
}
|
|
const versionInfo = yield installer.getJuliaVersionInfo();
|
|
const availableReleases = yield installer.getJuliaVersions(versionInfo);
|
|
const version = installer.getJuliaVersion(availableReleases, versionInput);
|
|
core.debug(`selected Julia version: ${arch}/${version}`);
|
|
core.setOutput('julia-version', version);
|
|
// Search in cache
|
|
let juliaPath;
|
|
juliaPath = tc.find('julia', version, arch);
|
|
if (!juliaPath) {
|
|
core.debug(`could not find Julia ${arch}/${version} in cache`);
|
|
const juliaInstallationPath = yield installer.installJulia(versionInfo, version, arch);
|
|
// Add it to cache
|
|
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch);
|
|
core.debug(`added Julia to cache: ${juliaPath}`);
|
|
// Remove temporary dir
|
|
fs.rmdirSync(juliaInstallationPath, { recursive: true });
|
|
}
|
|
else {
|
|
core.debug(`using cached version of Julia: ${juliaPath}`);
|
|
}
|
|
// Add it to PATH
|
|
core.addPath(path.join(juliaPath, 'bin'));
|
|
// Set output
|
|
core.setOutput('julia-bindir', path.join(juliaPath, 'bin'));
|
|
// Test if Julia has been installed
|
|
exec.exec('julia', ['--version']);
|
|
// If enabled, also show the full version info
|
|
if (core.getInput('show-versioninfo') == 'true') {
|
|
exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']);
|
|
}
|
|
}
|
|
catch (error) {
|
|
core.setFailed(error.message);
|
|
}
|
|
});
|
|
}
|
|
run();
|