diff --git a/.github/workflows/example-builds-nightly.yml b/.github/workflows/example-builds-nightly.yml index 5c941f71..7f6ba26f 100644 --- a/.github/workflows/example-builds-nightly.yml +++ b/.github/workflows/example-builds-nightly.yml @@ -33,4 +33,5 @@ jobs: with: version: nightly arch: ${{ matrix.julia-arch }} + show-versioninfo: 'true' - run: julia --version diff --git a/.github/workflows/example-builds.yml b/.github/workflows/example-builds.yml index 4c19aafe..2e4bc86e 100644 --- a/.github/workflows/example-builds.yml +++ b/.github/workflows/example-builds.yml @@ -26,8 +26,10 @@ jobs: npm run pack - name: "Set up Julia" + id: setup-julia uses: ./ with: version: ${{ matrix.julia-version }} arch: ${{ matrix.julia-arch }} + show-versioninfo: 'true' - run: julia --version diff --git a/action.yml b/action.yml index 2238557e..e4692d1e 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,9 @@ inputs: description: 'Display InteractiveUtils.versioninfo() after installing' required: false default: 'false' +outputs: + julia-bindir: + description: 'Path to the directory containing the Julia executable. Equivalent to JULIA_BINDIR: https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_BINDIR' runs: using: 'node12' main: 'dist/index.js' diff --git a/lib/installer.js b/lib/installer.js index cde29b55..87409244 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -18,6 +18,7 @@ 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 os = __importStar(require("os")); const path = __importStar(require("path")); const semver = __importStar(require("semver")); @@ -108,28 +109,26 @@ function installJulia(version, arch) { const downloadURL = getDownloadURL(version, arch); core.debug(`downloading Julia from ${downloadURL}`); const juliaDownloadPath = yield tc.downloadTool(downloadURL); + const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`); // Install it switch (osPlat) { case 'linux': // tc.extractTar doesn't support stripping components, so we have to call tar manually - yield exec.exec('mkdir', [`${process.env.HOME}/julia`]); - yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', `${process.env.HOME}/julia`]); - return `${process.env.HOME}/julia`; + yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]); + return tempInstallDir; case 'win32': - const juliaInstallationPath = path.join('C:', 'Julia'); if (version == 'nightly' || semver.gtr(version, '1.3', { includePrerelease: true })) { // The installer changed in 1.4: https://github.com/JuliaLang/julia/blob/ef0c9108b12f3ae177c51037934351ffa703b0b5/NEWS.md#build-system-changes - yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${juliaInstallationPath}" -NoNewWindow -Wait`]); + yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]); } else { - yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`]); + yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]); } - return juliaInstallationPath; + return tempInstallDir; case 'darwin': yield exec.exec('hdiutil', ['attach', juliaDownloadPath]); - yield exec.exec('mkdir', [`${process.env.HOME}/julia`]); - yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${process.env.HOME}`]); - return `${process.env.HOME}/julia`; + yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]); + return path.join(tempInstallDir, 'julia'); default: throw new Error(`Platform ${osPlat} is not supported`); } diff --git a/lib/setup-julia.js b/lib/setup-julia.js index 0ac7c0b6..2554c654 100644 --- a/lib/setup-julia.js +++ b/lib/setup-julia.js @@ -18,6 +18,7 @@ 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")); @@ -65,12 +66,16 @@ function run() { // 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 diff --git a/package-lock.json b/package-lock.json index f8d821fc..ff51c38b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-julia", - "version": "1.2.2", + "version": "1.3.0-DEV", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f525253a..cf0b62ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-julia", - "version": "1.2.2", + "version": "1.3.0-DEV", "private": true, "description": "setup Julia action", "main": "lib/setup-julia.js", diff --git a/src/installer.ts b/src/installer.ts index 04bb60d4..9f3e99f0 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -2,6 +2,7 @@ import * as core from '@actions/core' import * as exec from '@actions/exec' import * as tc from '@actions/tool-cache' +import * as fs from 'fs' import * as os from 'os' import * as path from 'path' @@ -102,27 +103,26 @@ export async function installJulia(version: string, arch: string): Promise