Compare commits

...

69 Commits

Author SHA1 Message Date
Sascha Mann
fac69f5780 Add TODO 2020-06-25 13:46:40 +02:00
Sascha Mann
ead3831d7a Cache artifacts directory by default 2020-06-25 13:39:22 +02:00
Sascha Mann
8945494c8c Document pre-release version range syntax -0
Also add a link to REPL.it to play with the version matching logic.
2020-06-01 22:48:13 +02:00
Sascha Mann
a81735fc3d Add Julia 1.5.0-beta1 2020-05-29 10:24:13 +02:00
Sascha Mann
2c2ccf4805 Add Julia 1.4.2 and update deps 2020-05-28 12:02:01 +02:00
Sascha Mann
0352b39425 Bump action version to 1.1.4 2020-04-15 14:04:09 +02:00
Sascha Mann
5ed1ab9531 Add Julia 1.4.1 2020-04-15 13:54:34 +02:00
Sascha Mann
b440227ef4 Use @zeit/ncc to distribute action 2020-03-24 20:05:33 +01:00
Sascha Mann
e07eb0ff2a Remove debugging steps from workflows 2020-03-22 18:16:49 +01:00
Sascha Mann
0c24e24eb5 Add Julia 1.4.0 2020-03-22 18:09:09 +01:00
Sascha Mann
abd4c5ae03 Run npm audit fix 2020-03-22 18:07:32 +01:00
Sascha Mann
51f7dbcff0 Add 'v1.4.0-rc2' 2020-03-11 14:19:14 +01:00
Sascha Mann
06264a4b68 Run npm audit fix --force 2020-03-11 14:19:14 +01:00
Sascha Mann
8f56a5b739 Remove @actions/github dependency
(fixes #27)
2020-03-11 14:19:02 +01:00
Sascha Mann
83f4f82909 Don't show versioninfo() by default (#25)
* Only show versioninfo() in debug mode

* Add input to specify if versioninfo() is displayed

* No access to secrets
2020-02-19 20:45:01 +01:00
Sascha Mann
eba5daa7a3 Add shell: bash to examples
fixes #23
2020-02-17 13:59:12 +01:00
Sascha Mann
150b180e77 Fix v1.4.0-rc1 version string 2020-02-13 10:48:40 +01:00
Sascha Mann
df27cccb6d Add Julia 1.4.0-rc1 to version list 2020-01-23 23:51:41 +01:00
Sascha Mann
4e8b9a1f06 Revert "Temporarily increase frequency of nightly builds"
This reverts commit 6c0c21977e.
2020-01-08 21:12:02 +01:00
Sascha Mann
960c1f45ca Delete release checklist
No longer needed, the bash script `bin/build-release` covers all of this.
2019-12-31 11:08:25 +01:00
Sascha Mann
ca58c641a5 Add Julia 1.3.1 to version list (#22) 2019-12-31 10:53:40 +01:00
Sascha Mann
6c0c21977e Temporarily increase frequency of nightly builds
The download of the nightly linux binaries still fails seemingly randomly. To get more information, the build will be run every 15 minutes temporarily.
2019-12-09 11:34:15 +01:00
Sascha Mann
6a79c57a32 Include debug info in CI builds (#19) 2019-12-05 20:21:48 +01:00
Sascha Mann
2efcc69643 Add Julia 1.3.0 to versions 2019-11-26 21:12:15 +01:00
Sascha Mann
d8b4778b2d Add (scheduled) CI runs (#15) 2019-11-26 17:05:08 +01:00
Sascha Mann
c8ae0bede2 Update versions in README 2019-11-25 14:56:26 +01:00
Sascha Mann
34454fe7cf Remove nightly from README TODOs 2019-11-25 14:22:23 +01:00
Sascha Mann
689d600802 Fix Windows install script 2019-11-25 14:22:23 +01:00
Sascha Mann
df485a1da6 Fix macOS install script 2019-11-25 14:22:23 +01:00
Sascha Mann
41539df7fe Fix linux install script 2019-11-25 14:22:23 +01:00
Sascha Mann
767e91ee6e Support nightly Julia builds 2019-11-25 14:22:23 +01:00
Sascha Mann
b199a80ea6 Add script to build test release 2019-11-25 14:22:23 +01:00
Sascha Mann
67ef5af2fd Run npm audit fix 2019-11-20 20:00:27 +01:00
Sascha Mann
7e7f2c80d1 Add v1.3.0-rc5 2019-11-20 19:58:43 +01:00
Sascha Mann
062cb2b1a5 Default to Julia version 1 2019-11-20 19:58:43 +01:00
Sascha Mann
61303b8b4b Add warning about quotes around versions 2019-11-20 19:58:43 +01:00
Sascha Mann
0f80dc983e Remove unit tests from README ToDo 2019-11-20 19:58:43 +01:00
Sascha Mann
29cdcebc07 Add tests for range input 2019-11-20 19:58:43 +01:00
Sascha Mann
b75da77172 Update documentation of ranges 2019-11-20 19:58:43 +01:00
Sascha Mann
dc7c0defbe Always use hardcoded versions to match ranges 2019-11-20 19:58:43 +01:00
Sascha Mann
5354e1e908 Fall back to hardcoded versions when API errors
This is a temporary fix until we can get Julia versions directly
from julialang.org. Right now the GitHub API randomly fails due to
rate limiting which leads to builds failing even if a valid specific
version was specified.
2019-11-20 19:58:43 +01:00
Sascha Mann
2900978394 Document version ranges & tidy up README 2019-11-20 19:58:43 +01:00
Sascha Mann
0f0b1bb9ba Add some unit tests for getJuliaVersions 2019-11-20 19:58:43 +01:00
Sascha Mann
16c0aaf600 Refactor getJuliaVersion to make it testable 2019-11-20 19:58:43 +01:00
Sascha Mann
dc7dce0a2d Move functions to separate file for easier unit testing 2019-11-20 19:58:43 +01:00
Sascha Mann
3861b0a708 Print full response in debug logs 2019-11-20 19:58:43 +01:00
Sascha Mann
8007d2c472 Remove trailing v from versions before download 2019-11-20 19:58:43 +01:00
Sascha Mann
955535b050 Support version ranges as input version 2019-11-20 19:58:43 +01:00
dependabot-preview[bot]
53af7ff088 Bump @types/node from 12.6.9 to 12.12.7 (#12) 2019-11-10 16:40:58 +00:00
dependabot-preview[bot]
1fef3e0e61 Bump @types/jest from 24.0.16 to 24.0.22 (#13) 2019-11-10 16:38:24 +00:00
dependabot-preview[bot]
f126476e08 Bump ts-jest from 24.0.2 to 24.1.0 (#11) 2019-11-10 16:38:18 +00:00
dependabot-preview[bot]
48e7b97239 Bump @actions/github from 1.0.0 to 1.1.0 (#10) 2019-11-10 16:38:15 +00:00
dependabot-preview[bot]
5c3252fb75 Bump prettier from 1.18.2 to 1.19.1 (#9) 2019-11-10 16:34:19 +00:00
Sascha Mann
425aaf9321 Add Dependabot information to README 2019-11-10 12:27:28 +01:00
Sascha Mann
d82325fb86 Add bash script to build & tag release 2019-11-09 18:23:27 +01:00
Sascha Mann
5334cf1301 Update examples in README 2019-11-05 15:19:11 +01:00
Sascha Mann
df0206ad59 Fix link to renamed template in README 2019-10-05 18:43:04 +02:00
Sascha Mann
2898e23df6 Hide generated JS code from diffs and stats 2019-10-02 17:23:56 +02:00
Sascha Mann
17e9ecd238 Apply fix: vulnerability in transitive dependency
Fixed by running `npm audit fix`.

More details: https://www.npmjs.com/advisories/1164

`handlebars` is a transitive dependency of jest.
2019-09-25 16:28:53 +02:00
Sascha Mann
d6aba32515 Fix versions in README example 2019-08-21 16:40:16 +02:00
Sascha Mann
2a0ae40f1c Remove 32-bit ToDo from README 2019-08-21 15:57:08 +02:00
Sascha Mann
295f753b1e Add 32-bit example workflows to README 2019-08-21 15:51:40 +02:00
Sascha Mann
a7c1edc063 Support 32-bit Julia binaries 2019-08-21 15:51:35 +02:00
Sascha Mann
6f01df9c38 Add release checklist 2019-08-17 18:27:44 +02:00
Sascha Mann
a8a77e20fd Use cached Julia if available 2019-08-17 18:05:37 +02:00
Sascha Mann
58832d0813 Add action versioning guidelines to README 2019-08-14 15:21:25 +02:00
Sascha Mann
7ac67b152e Fix typo in description in README 2019-08-14 14:29:38 +02:00
Sascha Mann
c11753280f Add table of contents to README 2019-08-14 14:21:09 +02:00
Sascha Mann
3ebbe69222 Change phrasing of npm warning in README 2019-08-14 13:22:48 +02:00
17 changed files with 3363 additions and 1274 deletions

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Hide generated JS code from diffs and language stats
lib/*.js linguist-generated=true

View File

@@ -0,0 +1,36 @@
name: Example builds (nightly)
on:
push:
pull_request:
schedule:
- cron: '0 3 * * *'
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
julia-arch: [x64, x86]
os: [ubuntu-latest, macOS-latest, windows-latest]
# 32-bit Julia binaries are not available on macOS
exclude:
- os: macOS-latest
julia-arch: x86
steps:
- uses: actions/checkout@v1.0.0
- name: "Install dependencies"
run: |
npm install
npm run build
npm run pack
- name: "Set up Julia (nightly)"
uses: ./
with:
version: nightly
arch: ${{ matrix.julia-arch }}
- run: julia --version

33
.github/workflows/example-builds.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: Example builds
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
julia-version: ['1.0.5', '1', '^1.5.0-beta1']
julia-arch: [x64, x86]
os: [ubuntu-latest, macOS-latest, windows-latest]
# 32-bit Julia binaries are not available on macOS
exclude:
- os: macOS-latest
julia-arch: x86
steps:
- uses: actions/checkout@v1.0.0
- name: "Install dependencies"
run: |
npm install
npm run build
npm run pack
- name: "Set up Julia"
uses: ./
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
- run: julia --version

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
node_modules/
__tests__/runner/*
dist/

134
README.md
View File

@@ -1,25 +1,60 @@
# setup-julia Action
This action sets up a Julia environment for use in actions by download a specified version of Julia and adding it to PATH.
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=julia-actions/setup-julia)](https://dependabot.com)
This action sets up a Julia environment for use in actions by downloading a specified version of Julia and adding it to PATH.
## Table of Contents
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Basic](#basic)
- [Julia Versions](#julia-versions)
- [Matrix Testing](#matrix-testing)
- [Versioning](#versioning)
- [Licence info](#licence-info)
## Usage
See [action.yml](action.yml).
Take a look at [github.com/exercism/julia](https://github.com/exercism/julia/pull/153) for an example, non-package Julia project making use of this action.
You can find a list of example workflows making use of this action here: [julia-actions/example-workflows](https://github.com/julia-actions/example-workflows).
### Basic:
### Basic
```yaml
steps:
- uses: actions/checkout@v1.0.0
- uses: julia-actions/setup-julia@v0.1.0
- uses: julia-actions/setup-julia@v1
with:
version: 1.0.4
- run: julia -e 'println("Hello, World!")'
```
### Matrix Testing:
### Julia Versions
You can either specify specific Julia versions or version ranges. If you specify a version range, the **highest** available Julia version that matches the range will be selected.
**Warning:** It is strongly recommended to wrap versions in quotes. Otherwise, the YAML parser used by GitHub Actions parses certain versions as numbers which causes the wrong version to be selected. For example, `1.0` is parsed as `1`.
#### Examples
- `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 pre-releases starting at `rc1`. It matches all versions `≥ 1.3.0-rc1` and `< 1.4.0`.
- `^1.3-0` is a caret version range that includes _all_ pre-releases. It matches all versions `≥ 1.3.0-` 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. You can test what version will be selected for a given input in this JavaScript [REPL](https://repl.it/@SaschaMann/setup-julia-version-logic).
#### WARNING: Version ranges are experimental and potentially out of date
Currently the list of available versions is hardcoded. You have to use the latest version of the action to be able to install the latest Julia versions. Once available we will use a list of versions provided on julialang.org.
### Matrix Testing
`bash` is chosen as shell to enforce consistent behaviour across operating systems. [Other shells](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell) are available but you may have to escape quotation marks or otherwise adjust the syntax.
#### 64-bit Julia only
```yaml
jobs:
@@ -27,47 +62,90 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.0.4, 1.1.1, 1.2.0-rc3, 1.3.0-alpha]
julia-version: ['1.0', '1.2.0', '^1.3.0-rc1']
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v1.0.0
- name: "Set up Julia"
uses: julia-actions/setup-julia@v0.1.0
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
- run: julia -e 'println("Hello, World!")'
shell: bash
```
## Future plans & ideas
#### 32-bit Julia
In no particular order:
```yaml
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: ['1.0', '1.2.0', '^1.3.0-rc1']
julia-arch: [x64, x86]
os: [ubuntu-latest, windows-latest, macOS-latest]
# 32-bit Julia binaries are not available on macOS
exclude:
- os: macOS-latest
julia-arch: x86
steps:
- uses: actions/checkout@v1.0.0
- name: "Set up Julia"
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
- run: julia -e 'println("Hello, World!")'
shell: bash
```
### `setup-julia`:
* Check if a cached version of Julia is available instead of installing it everytime CI runs.
* Add version shortcuts like `1.x`, `1.1.x`, `latest` and `lts`.
* Add support for nightly Julia builds.
* Support 32-bit Julia on 64-bit windows.
* Write some unit tests for the action.
* Figure out the best way to handle versioning.
* Hash and signature checks.
Alternatively, you can include specific version and OS combinations that will use 32-bit Julia:
### Other Julia-related actions:
```yaml
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: ['1.0', '1.2.0', '^1.3.0-rc1']
os: [ubuntu-latest, windows-latest, macOS-latest]
# Additionally create a job using 32-bit Julia 1.0.4 on windows-latest
include:
- os: windows-latest
julia-version: ['1.0.4']
julia-arch: x86
steps:
- uses: actions/checkout@v1.0.0
- name: "Set up Julia"
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
- run: julia -e 'println("Hello, World!")'
shell: bash
```
These would be nice to have but I make no promises of ever creating them myself.
## Versioning
* Default build script for packages, similar to how Travis CI works if you don't specify a script.
* Find out if it's possible to cache packages using [`@actions/tool-cache`](https://github.com/actions/toolkit/tree/master/packages/tool-cache).
* Actions for standard tools like Documenter, Coverage reporting and so on
* Actions for registering and tagging package releases instead of relying on external apps.
This action follows [GitHub's advice](https://help.github.com/en/articles/about-actions#versioning-your-action) on versioning actions, with an additional `latest` tag.
## Words of caution
If you don't want to deal with updating the version of the action, similiarly to how Travis CI handles it, use `latest` or major version branches. [Dependabot](https://dependabot.com/) can also be used to automatically create Pull Requests to update actions used in your workflows.
This action will likely be updated quite frequently in the near future. I'm sharing it now so that others who want to try out Julia on GitHub actions can do so without relying on Docker.
It's unlikely, but not impossible, that there will be breaking changes post-v1.0.0 unless a new major version of Julia is introduced.
**DO NOT USE THIS AS YOUR ONLY FORM OF CI** (yet).
You can specify commits, branches or tags in your workflows as follows:
Unfortunately, because non-container actions must use JavaScript/TypeScript as scripting language, `npm` is involved. The dependencies are vendored but this action relies 100% on GitHub to audit the dependencies they add to their action toolkit.
```yaml
steps:
- uses: julia-actions/setup-julia@6ae948d # commit SHA
- uses: julia-actions/setup-julia@master # branch
- uses: julia-actions/setup-julia@latest # latest version tag (may break existing workflows)
- uses: julia-actions/setup-julia@v1 # major version tag
- uses: julia-actions/setup-julia@v0.1.0 # specific version tag
```
## Licence info
Parts of this software have been derived from the `setup-go` [action](https://github.com/actions/setup-go) and the [JavaScript Action Template](https://github.com/actions/javascript-template), both released by GitHub under the MIT licence.
Parts of this software have been derived from the `setup-go` [action](https://github.com/actions/setup-go) and the [TypeScript Action Template](https://github.com/actions/typescript-action), both released by GitHub under the MIT licence.

View File

@@ -1,3 +1,43 @@
describe('TODO - Add a test suite', () => {
it('TODO - Add a test', async () => {})
import * as installer from '../src/installer'
import * as semver from 'semver'
const testVersions = ['v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0']
describe('installer tests', () => {
describe('version matching', () => {
describe('specific versions', () => {
it('Doesn\'t change the version when given a valid semver version', async () => {
expect(await installer.getJuliaVersion([], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(['v1.0.5', 'v1.0.6'], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(['v1.0.4', 'v1.0.5'], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(['v1.0.4'], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion([], '1.3.0-alpha')).toEqual('1.3.0-alpha')
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 () => {
expect(await installer.getJuliaVersion(testVersions, '1')).toEqual('1.2.0')
expect(await installer.getJuliaVersion(testVersions, '1.0')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(testVersions, '^1.3.0-rc1')).toEqual('1.3.0-rc4')
expect(await installer.getJuliaVersion(testVersions, '^1.2.0-rc1')).toEqual('1.2.0')
})
})
})
describe('node-semver behaviour', () => {
describe('Windows installer change', () => {
it('Correctly understands >1.4.0', () => {
expect(semver.gtr('1.4.0-rc1', '1.3', {includePrerelease: true})).toBeTruthy()
expect(semver.gtr('1.4.0-DEV', '1.3', {includePrerelease: true})).toBeTruthy()
expect(semver.gtr('1.3.1', '1.3', {includePrerelease: true})).toBeFalsy()
expect(semver.gtr('1.3.2-rc1', '1.3', {includePrerelease: true})).toBeFalsy()
})
})
})
})

View File

@@ -4,10 +4,25 @@ author: 'Sascha Mann'
inputs:
version:
description: 'The Julia version to download (if necessary) and use. Example: 1.0.4'
default: '1.0.4'
default: '1'
arch:
description: 'Architecture of the Julia binaries. Defaults to x64.'
required: false
default: 'x64'
show-versioninfo:
description: 'Display InteractiveUtils.versioninfo() after installing'
required: false
default: 'false'
cache-artifacts:
description: 'Cache ~/.julia/artifacts. Will fail if no file matches **/Project.toml.'
required: false
default: 'true'
outputs:
artifacts-cache-id:
description: 'The cache id of the artifacts cache.'
runs:
using: 'node12'
main: 'lib/setup-julia.js'
main: 'dist/index.js'
branding:
icon: 'download'
color: 'green'

44
bin/build-release Normal file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
branch_name="$(git symbolic-ref --short -q HEAD)"
version="v$(jq -r .version package.json)"
repo="$1"
if [ -z "$repo" ]; then
echo "ERROR: must specify repository"
exit 1
fi
echo "=== debug info ==="
echo "branch: $branch_name"
echo "version: $version"
echo "repo: $repo"
echo "=================="
echo ""
# Check that the version doesn't exist yet
version_exists="$(curl -s https://api.github.com/repos/"$repo"/tags -H "Accept: application/vnd.github.v3.full+json" | jq -r '.[] | select(.name == "'"$version"'") | .name')"
if [ -n "$version_exists" ]; then
echo "ERROR: version $version already exists"
exit 1
fi
git checkout -b releases/"$version"
npm install
npm run build
npm test
npm run pack
sed -i 's/dist/!dist/g' .gitignore
git add dist
git commit -a -m "Add production dependencies & build"
# Tags
major_minor="$(sed 's/\.[^.]*$//' <<< "$version")"
major="$(sed 's/\.[^.]*$//' <<< "$major_minor")"
git tag "$version"
git tag -f "$major_minor"
git tag -f "$major"
git tag -f "latest"

36
bin/build-test-release Normal file
View File

@@ -0,0 +1,36 @@
#!/bin/sh
branch_name="$(git symbolic-ref --short -q HEAD)"
version="v$(jq -r .version package.json)"
repo="$1"
if [ -z "$repo" ]; then
echo "ERROR: must specify repository"
exit 1
fi
echo "=== debug info ==="
echo "branch: $branch_name"
echo "version: $version"
echo "repo: $repo"
echo "=================="
echo ""
# Check that the version doesn't exist yet
version_exists="$(curl -s https://api.github.com/repos/"$repo"/tags -H "Accept: application/vnd.github.v3.full+json" | jq -r '.[] | select(.name == "'"$version"'") | .name')"
if [ -n "$version_exists" ]; then
echo "ERROR: version $version already exists"
exit 1
fi
git checkout -B test/"$branch_name"/releases/"$version"
npm install
npm run build
npm test
npm run pack
# Add dist/ to git and commit it
sed -i 's/dist/!dist/g' .gitignore
git add dist
git commit -a -m "Add production dependencies & build"

40
lib/caching.js generated Normal file
View File

@@ -0,0 +1,40 @@
"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 cache = __importStar(require("@actions/cache"));
const glob = __importStar(require("@actions/glob"));
const path = __importStar(require("path"));
// TODO: Change to hashFiles once https://github.com/actions/toolkit/issues/472 has been resolved
const md5File = __importStar(require("md5-file"));
const JULIA_HOME = path.join(`${process.env.HOME}`, '.julia');
/**
* Cache the ~/.julia/artifacts directory.
*/
function cacheArtifacts() {
return __awaiter(this, void 0, void 0, function* () {
// TODO: Add error handling in case no Project.toml files are present
const projectFiles = yield (yield glob.create('**/Project.toml')).glob();
let projectsHash = '';
projectFiles.forEach((f) => {
projectsHash.concat('-', md5File.sync(f));
});
const paths = [path.join(JULIA_HOME, 'artifacts')];
const key = `artifacts-${process.env.RUNNER_OS}-${projectsHash}`;
return cache.saveCache(paths, key);
});
}
exports.cacheArtifacts = cacheArtifacts;

140
lib/installer.js generated Normal file
View File

@@ -0,0 +1,140 @@
"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 os = __importStar(require("os"));
const path = __importStar(require("path"));
const semver = __importStar(require("semver"));
// Store information about the environment
const osPlat = os.platform(); // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`);
// This is temporary until we have a better way of fetching releases (see #1, #4 for details)
exports.juliaVersions = ['v1.5.0-beta1', 'v1.4.2', 'v1.4.1', 'v1.4.0', 'v1.4.0-rc2', 'v1.4.0-rc1', 'v1.3.1', 'v1.3.0', 'v1.3.0-rc5', 'v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2'];
function getJuliaVersion(availableReleases, versionInput) {
return __awaiter(this, void 0, void 0, function* () {
if (semver.valid(versionInput) == 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) {
throw `Could not find a Julia version that matches ${versionInput}`;
}
// GitHub tags start with v, remove it
version = version.replace(/^v/, '');
return version;
});
}
exports.getJuliaVersion = getJuliaVersion;
function getMajorMinorVersion(version) {
return version.split('.').slice(0, 2).join('.');
}
function getDownloadURL(version, arch) {
let platform;
if (osPlat === 'win32') { // Windows
platform = 'winnt';
}
else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS';
}
platform = 'mac';
}
else if (osPlat === 'linux') { // Linux
platform = 'linux';
}
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) {
let versionExt, ext;
if (osPlat === 'win32') { // Windows
versionExt = arch == 'x64' ? '-win64' : '-win32';
ext = 'exe';
}
else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS';
}
versionExt = '-mac64';
ext = 'dmg';
}
else if (osPlat === 'linux') { // Linux
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`;
}
return `julia-${version}${versionExt}.${ext}`;
}
function installJulia(version, arch) {
return __awaiter(this, void 0, void 0, function* () {
// Download Julia
const downloadURL = getDownloadURL(version, arch);
core.debug(`downloading Julia from ${downloadURL}`);
const juliaDownloadPath = yield tc.downloadTool(downloadURL);
// 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`;
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`]);
}
else {
yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`]);
}
return juliaInstallationPath;
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`;
default:
throw `Platform ${osPlat} is not supported`;
}
});
}
exports.installJulia = installJulia;

102
lib/setup-julia.js generated
View File

@@ -18,84 +18,44 @@ 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 os = __importStar(require("os"));
const path = __importStar(require("path"));
// Store information about the environment
const osPlat = os.platform(); // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`);
function getMajorMinorVersion(version) {
return version.split('.').slice(0, 2).join('.');
}
function getDownloadURL(version) {
const baseURL = 'https://julialang-s3.julialang.org/bin';
let platform, arch;
const versionDir = getMajorMinorVersion(version);
if (osPlat === 'win32') { // Windows
platform = 'winnt';
arch = 'x64';
}
else if (osPlat === 'darwin') { // macOS
platform = 'mac';
arch = 'x64';
}
else if (osPlat === 'linux') { // Linux
platform = 'linux';
arch = 'x64';
}
else {
throw `Platform ${osPlat} is not supported`;
}
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version)}`;
}
function getFileName(version) {
let versionExt, ext;
if (osPlat === 'win32') { // Windows
versionExt = '-win64';
ext = 'exe';
}
else if (osPlat === 'darwin') { // macOS
versionExt = '-mac64';
ext = 'dmg';
}
else if (osPlat === 'linux') { // Linux
versionExt = '-linux-x86_64';
ext = 'tar.gz';
}
else {
throw `Platform ${osPlat} is not supported`;
}
return `julia-${version}${versionExt}.${ext}`;
}
const installer = __importStar(require("./installer"));
const jlcache = __importStar(require("./caching"));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const version = core.getInput('version');
core.debug(`selected Julia version: ${version}`);
// Download Julia
const downloadURL = getDownloadURL(version);
core.debug(`download Julia from ${downloadURL}`);
const juliaDownloadPath = yield tc.downloadTool(downloadURL);
// Install Julia
if (osPlat === 'linux') { // Linux
const juliaExtractedFolder = yield tc.extractTar(juliaDownloadPath);
const juliaCachedPath = yield tc.cacheDir(juliaExtractedFolder, 'julia', version);
const juliaPath = path.join(juliaCachedPath, `julia-${version}`);
core.addPath(path.join(juliaPath, 'bin'));
const versionInput = core.getInput('version');
const arch = core.getInput('arch');
const availableReleases = installer.juliaVersions;
const version = yield installer.getJuliaVersion(availableReleases, versionInput);
core.debug(`selected Julia version: ${arch}/${version}`);
// Search in cache
let juliaPath;
juliaPath = tc.find('julia', version, arch);
if (!juliaPath) {
core.debug(`could not find Julia ${version} in cache`);
const juliaInstallationPath = yield installer.installJulia(version, arch);
// Add it to cache
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch);
core.debug(`added Julia to cache: ${juliaPath}`);
}
else if (osPlat === 'win32') { // Windows
// Install Julia in C:\Julia
const juliaInstallationPath = path.join('C:', 'Julia');
yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`]);
const juliaCachedPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version);
core.addPath(path.join(juliaCachedPath, 'bin'));
else {
core.debug(`using cached version of Julia: ${juliaPath}`);
}
else if (osPlat === 'darwin') { // macOS
yield exec.exec('hdiutil', ['attach', juliaDownloadPath]);
const juliaCachedPath = yield tc.cacheDir(`/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`, 'julia', version);
core.addPath(path.join(juliaCachedPath, 'bin'));
// Add it to PATH
core.addPath(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()']);
}
// Create caches
if (core.getInput('cache-artifacts') == 'true') {
core.debug('caching artifacts directory...');
const cacheId = yield jlcache.cacheArtifacts();
core.setOutput('artifacts-cache-id', cacheId.toString());
}
// Test if Julia has been installed by showing versioninfo()
yield exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']);
}
catch (error) {
core.setFailed(error.message);

3723
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,12 @@
{
"name": "setup-julia",
"version": "0.1.0",
"version": "1.1.6",
"private": true,
"description": "setup Julia action",
"main": "lib/setup-julia.js",
"scripts": {
"build": "tsc",
"format": "prettier --single-quote --print-width 120 --tab-width 4 --no-semi --write **/*.ts",
"format-check": "prettier --single-quote --print-width 120 --tab-width 4 --no-semi --check **/*.ts",
"pack": "ncc build",
"test": "jest"
},
"repository": {
@@ -22,21 +21,24 @@
"author": "Sascha Mann <git@mail.saschamann.eu>",
"license": "MIT",
"dependencies": {
"@actions/cache": "^0.2.1",
"@actions/core": "^1.0.0",
"@actions/io": "^1.0.0",
"@actions/exec": "^1.0.0",
"@actions/github": "^1.0.0",
"@actions/glob": "^0.1.0",
"@actions/io": "^1.0.0",
"@actions/tool-cache": "^1.0.0",
"semver": "^6.1.1"
"md5-file": "^5.0.0",
"semver": "^6.3.0"
},
"devDependencies": {
"@types/jest": "^24.0.13",
"@types/node": "^12.0.4",
"@types/node": "^12.12.7",
"@types/semver": "^6.0.0",
"@zeit/ncc": "^0.22.0",
"jest": "^24.8.0",
"jest-circus": "^24.7.1",
"prettier": "^1.17.1",
"ts-jest": "^24.0.2",
"ts-jest": "^26.0.0",
"typescript": "^3.5.1"
}
}

26
src/caching.ts Normal file
View File

@@ -0,0 +1,26 @@
import * as cache from '@actions/cache'
import * as glob from '@actions/glob'
import * as path from 'path'
// TODO: Change to hashFiles once https://github.com/actions/toolkit/issues/472 has been resolved
import * as md5File from 'md5-file'
const JULIA_HOME = path.join(`${process.env.HOME}`, '.julia')
/**
* Cache the ~/.julia/artifacts directory.
*/
export async function cacheArtifacts(): Promise<number> {
// TODO: Add error handling in case no Project.toml files are present
const projectFiles = await (await glob.create('**/Project.toml')).glob()
let projectsHash = ''
projectFiles.forEach((f) => {
projectsHash.concat('-', md5File.sync(f))
})
const paths = [path.join(JULIA_HOME, 'artifacts')]
const key = `artifacts-${process.env.RUNNER_OS}-${projectsHash}`
return cache.saveCache(paths, key)
}

129
src/installer.ts Normal file
View File

@@ -0,0 +1,129 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as tc from '@actions/tool-cache'
import * as os from 'os'
import * as path from 'path'
import * as semver from 'semver'
// Store information about the environment
const osPlat = os.platform() // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`)
// This is temporary until we have a better way of fetching releases (see #1, #4 for details)
export const juliaVersions = ['v1.5.0-beta1', 'v1.4.2', 'v1.4.1', 'v1.4.0', 'v1.4.0-rc2', 'v1.4.0-rc1', 'v1.3.1', 'v1.3.0', 'v1.3.0-rc5', 'v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2']
export async function getJuliaVersion(availableReleases: string[], versionInput: string): Promise<string> {
if (semver.valid(versionInput) == 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) {
throw `Could not find a Julia version that matches ${versionInput}`
}
// GitHub tags start with v, remove it
version = version.replace(/^v/, '')
return version
}
function getMajorMinorVersion(version: string): string {
return version.split('.').slice(0, 2).join('.')
}
function getDownloadURL(version: string, arch: string): string {
let platform: string
if (osPlat === 'win32') { // Windows
platform = 'winnt'
} else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS'
}
platform = 'mac'
} else if (osPlat === 'linux') { // Linux
platform = 'linux'
} 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: string, arch: string): string {
let versionExt: string, ext: string
if (osPlat === 'win32') { // Windows
versionExt = arch == 'x64' ? '-win64' : '-win32'
ext = 'exe'
} else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS'
}
versionExt = '-mac64'
ext = 'dmg'
} else if (osPlat === 'linux') { // Linux
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`
}
return `julia-${version}${versionExt}.${ext}`
}
export async function installJulia(version: string, arch: string): Promise<string> {
// Download Julia
const downloadURL = getDownloadURL(version, arch)
core.debug(`downloading Julia from ${downloadURL}`)
const juliaDownloadPath = await tc.downloadTool(downloadURL)
// Install it
switch (osPlat) {
case 'linux':
// tc.extractTar doesn't support stripping components, so we have to call tar manually
await exec.exec('mkdir', [`${process.env.HOME}/julia`])
await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', `${process.env.HOME}/julia`])
return `${process.env.HOME}/julia`
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
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${juliaInstallationPath}" -NoNewWindow -Wait`])
} else {
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`])
}
return juliaInstallationPath
case 'darwin':
await exec.exec('hdiutil', ['attach', juliaDownloadPath])
await exec.exec('mkdir', [`${process.env.HOME}/julia`])
await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${process.env.HOME}`])
return `${process.env.HOME}/julia`
default:
throw `Platform ${osPlat} is not supported`
}
}

View File

@@ -2,89 +2,51 @@ import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as tc from '@actions/tool-cache'
import * as os from 'os'
import * as path from 'path'
// Store information about the environment
const osPlat = os.platform() // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`)
function getMajorMinorVersion(version: string): string {
return version.split('.').slice(0, 2).join('.')
}
function getDownloadURL(version: string): string {
const baseURL = 'https://julialang-s3.julialang.org/bin'
let platform: string, arch: string
const versionDir = getMajorMinorVersion(version)
if (osPlat === 'win32') { // Windows
platform = 'winnt'
arch = 'x64'
} else if (osPlat === 'darwin') { // macOS
platform = 'mac'
arch = 'x64'
} else if (osPlat === 'linux') { // Linux
platform = 'linux'
arch = 'x64'
} else {
throw `Platform ${osPlat} is not supported`
}
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version)}`
}
function getFileName(version: string): string {
let versionExt: string, ext: string
if (osPlat === 'win32') { // Windows
versionExt = '-win64'
ext = 'exe'
} else if (osPlat === 'darwin') { // macOS
versionExt = '-mac64'
ext = 'dmg'
} else if (osPlat === 'linux') { // Linux
versionExt = '-linux-x86_64'
ext = 'tar.gz'
} else {
throw `Platform ${osPlat} is not supported`
}
return `julia-${version}${versionExt}.${ext}`
}
import * as installer from './installer'
import * as jlcache from './caching'
async function run() {
try {
const version = core.getInput('version')
core.debug(`selected Julia version: ${version}`)
const versionInput = core.getInput('version')
const arch = core.getInput('arch')
const availableReleases = installer.juliaVersions
const version = await installer.getJuliaVersion(availableReleases, versionInput)
core.debug(`selected Julia version: ${arch}/${version}`)
// Download Julia
const downloadURL = getDownloadURL(version)
core.debug(`download Julia from ${downloadURL}`)
const juliaDownloadPath = await tc.downloadTool(downloadURL)
// Search in cache
let juliaPath: string;
juliaPath = tc.find('julia', version, arch)
// Install Julia
if (osPlat === 'linux') { // Linux
const juliaExtractedFolder = await tc.extractTar(juliaDownloadPath)
const juliaCachedPath = await tc.cacheDir(juliaExtractedFolder, 'julia', version)
const juliaPath = path.join(juliaCachedPath, `julia-${version}`)
core.addPath(path.join(juliaPath, 'bin'))
} else if (osPlat === 'win32') { // Windows
// Install Julia in C:\Julia
const juliaInstallationPath = path.join('C:', 'Julia')
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`])
const juliaCachedPath = await tc.cacheDir(juliaInstallationPath, 'julia', version)
core.addPath(path.join(juliaCachedPath, 'bin'))
} else if (osPlat === 'darwin') { // macOS
await exec.exec('hdiutil', ['attach', juliaDownloadPath])
const juliaCachedPath = await tc.cacheDir(`/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`, 'julia', version)
core.addPath(path.join(juliaCachedPath, 'bin'))
if (!juliaPath) {
core.debug(`could not find Julia ${version} in cache`)
const juliaInstallationPath = await installer.installJulia(version, arch);
// Add it to cache
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch)
core.debug(`added Julia to cache: ${juliaPath}`)
} else {
core.debug(`using cached version of Julia: ${juliaPath}`)
}
// Test if Julia has been installed by showing versioninfo()
await exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()'])
// Add it to PATH
core.addPath(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()'])
}
// Create caches
if (core.getInput('cache-artifacts') == 'true') {
core.debug('caching artifacts directory...')
const cacheId = await jlcache.cacheArtifacts()
core.setOutput('artifacts-cache-id', cacheId.toString())
}
} catch (error) {
core.setFailed(error.message)
}