From 767e91ee6ed013bfc60d6e2599d6997a2ac26884 Mon Sep 17 00:00:00 2001 From: Sascha Mann Date: Sun, 24 Nov 2019 20:55:13 +0100 Subject: [PATCH] Support nightly Julia builds --- README.md | 1 + __tests__/main.test.ts | 4 ++++ lib/installer.js | 21 ++++++++++++++++++--- src/installer.ts | 23 ++++++++++++++++++++--- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3321d40..6e45260 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ You can either specify specific Julia versions or version ranges. If you specify - `1.2.0` is a valid semver version. The action will try to download exactly this version. If it's not available, the build step will fail. - `1.0` is a version range that will match the highest available Julia version that starts with `1.0`, e.g. `1.0.5`. - `^1.3.0-rc1` is a caret version range that includes preleases. It matches all versions `≥ 1.3.0-rc1` and `< 1.4.0`. +- `nightly` will install the latest nightly build. Internally the action uses node's semver package to resolve version ranges. Its [documentation](https://github.com/npm/node-semver#advanced-range-syntax) contains more details on the version range syntax. diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index fad41f0..1074f03 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -14,6 +14,10 @@ describe('installer tests', () => { expect(await installer.getJuliaVersion(['v1.2.0', 'v1.3.0-alpha', 'v1.3.0-rc1', 'v1.3.0'], '1.3.0-alpha')).toEqual('1.3.0-alpha') expect(await installer.getJuliaVersion([], '1.3.0-rc2')).toEqual('1.3.0-rc2') }) + it('Doesn\'t change the version when given `nightly`', async () => { + expect(await installer.getJuliaVersion([], 'nightly')).toEqual('nightly') + expect(await installer.getJuliaVersion(testVersions, 'nightly')).toEqual('nightly') + }) }) describe('version ranges', () => { it('Chooses the highest available version that matches the input', async () => { diff --git a/lib/installer.js b/lib/installer.js index 0cd05ff..b74fbed 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -32,6 +32,10 @@ function getJuliaVersion(availableReleases, versionInput) { // versionInput is a valid version, use it directly return versionInput; } + // nightlies + if (versionInput == 'nightly') { + return 'nightly'; + } // Use the highest available version that matches versionInput let version = semver.maxSatisfying(availableReleases, versionInput); if (version == null) { @@ -47,9 +51,7 @@ function getMajorMinorVersion(version) { return version.split('.').slice(0, 2).join('.'); } function getDownloadURL(version, arch) { - const baseURL = 'https://julialang-s3.julialang.org/bin'; let platform; - const versionDir = getMajorMinorVersion(version); if (osPlat === 'win32') { // Windows platform = 'winnt'; } @@ -65,6 +67,14 @@ function getDownloadURL(version, arch) { else { throw `Platform ${osPlat} is not supported`; } + // nightlies + if (version == 'nightly') { + const baseURL = 'https://julialangnightlies-s3.julialang.org/bin'; + return `${baseURL}/${platform}/${arch}/${getFileName('latest', arch)}`; + } + // normal versions + const baseURL = 'https://julialang-s3.julialang.org/bin'; + const versionDir = getMajorMinorVersion(version); return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`; } function getFileName(version, arch) { @@ -81,7 +91,12 @@ function getFileName(version, arch) { ext = 'dmg'; } else if (osPlat === 'linux') { // Linux - versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686'; + if (version == 'latest') { // nightly version + versionExt = arch == 'x64' ? '-linux64' : '-linux32'; + } + else { + versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686'; + } ext = 'tar.gz'; } else { diff --git a/src/installer.ts b/src/installer.ts index 4b6b5be..afe6e33 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -21,6 +21,11 @@ export async function getJuliaVersion(availableReleases: string[], versionInput: return versionInput } + // nightlies + if (versionInput == 'nightly') { + return 'nightly' + } + // Use the highest available version that matches versionInput let version = semver.maxSatisfying(availableReleases, versionInput) if (version == null) { @@ -38,9 +43,7 @@ function getMajorMinorVersion(version: string): string { } function getDownloadURL(version: string, arch: string): string { - const baseURL = 'https://julialang-s3.julialang.org/bin' let platform: string - const versionDir = getMajorMinorVersion(version) if (osPlat === 'win32') { // Windows platform = 'winnt' @@ -55,6 +58,16 @@ function getDownloadURL(version: string, arch: string): string { throw `Platform ${osPlat} is not supported` } + // nightlies + if (version == 'nightly') { + const baseURL = 'https://julialangnightlies-s3.julialang.org/bin' + return `${baseURL}/${platform}/${arch}/${getFileName('latest', arch)}` + } + + // normal versions + const baseURL = 'https://julialang-s3.julialang.org/bin' + const versionDir = getMajorMinorVersion(version) + return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}` } @@ -71,7 +84,11 @@ function getFileName(version: string, arch: string): string { versionExt = '-mac64' ext = 'dmg' } else if (osPlat === 'linux') { // Linux - versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686' + if (version == 'latest') { // nightly version + versionExt = arch == 'x64' ? '-linux64' : '-linux32' + } else { + versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686' + } ext = 'tar.gz' } else { throw `Platform ${osPlat} is not supported`