Initial commit

This commit is contained in:
Jonathan Clem
2019-08-28 00:00:01 -04:00
commit 83d6ee76a6
210 changed files with 15020 additions and 0 deletions

21
src/elixir-versions.txt Normal file
View File

@@ -0,0 +1,21 @@
1.9.1
1.9.0
1.8.2
1.8.1
1.8.0
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
1.6.6
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.3
1.5.2
1.5.1
1.5.0

137
src/erlang-versions.txt Normal file
View File

@@ -0,0 +1,137 @@
22.0.7
22.0.6
22.0.5
22.0.4
22.0.3
22.0.2
22.0.1
22.0.0
21.3.8
21.3.7
21.3.6
21.3.5
21.3.4
21.3.3
21.3.2
21.3.1
21.3.0
21.2.7
21.2.6
21.2.5
21.2.4
21.2.3
21.2.2
21.2.1
21.2.0
21.1.4
21.1.3
21.1.2
21.1.1
21.1.0
21.0.9
21.0.8
21.0.7
21.0.6
21.0.5
21.0.4
21.0.3
21.0.2
21.0.1
21.0.0
20.3.8
20.3.7
20.3.6
20.3.5
20.3.4
20.3.3
20.3.2
20.3.1
20.3.0
20.2.4
20.2.3
20.2.2
20.2.1
20.2.0
20.1.7
20.1.6
20.1.5
20.1.4
20.1.3
20.1.2
20.1.1
20.1.0
20.0.5
20.0.4
20.0.3
20.0.2
20.0.1
20.0.0
19.3.6
19.3.5
19.3.4
19.3.3
19.3.2
19.3.1
19.3.0
19.2.3
19.2.2
19.2.1
19.2.0
19.1.6
19.1.5
19.1.4
19.1.3
19.1.2
19.1.1
19.1.0
19.0.7
19.0.6
19.0.5
19.0.4
19.0.3
19.0.2
19.0.1
19.0.0
18.3.4
18.3.3
18.3.2
18.3.1
18.3.0
18.2.4
18.2.3
18.2.2
18.2.1
18.2.0
18.1.5
18.1.4
18.1.3
18.1.2
18.1.1
18.1.0
18.0.3
18.0.2
18.0.1
18.0.0
17.5.6
17.5.5
17.5.4
17.5.3
17.5.2
17.5.1
17.5.0
17.4.1
17.4.0
17.3.4
17.3.3
17.3.2
17.3.1
17.3.0
17.2.2
17.2.1
17.2.0
17.1.2
17.1.1
17.1.0
17.0.2
17.0.1
17.0.0

13
src/install-elixir-ubuntu Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
set -eo pipefail
release=$(cat /etc/os-release | grep UBUNTU_CODENAME | cut -d= -f2)
version=$1
arch=$2
file=elixir_$version-1~ubuntu~$release\_$arch.deb
cd /tmp
wget https://packages.erlang-solutions.com/erlang/debian/pool/$file
sudo dpkg -i $file

16
src/install-otp-ubuntu Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -eo pipefail
release=$(lsb_release -cs)
version=$1
file=esl-erlang_$version-1~ubuntu~$release\_amd64.deb
sudo apt-get install -y libwxbase3.0-0v5
sudo apt-get install -y libwxgtk3.0-0v5
sudo apt-get install -y libsctp1
cd /tmp
wget https://packages.erlang-solutions.com/erlang/debian/pool/$file
sudo dpkg -i $file

36
src/installer.js Normal file
View File

@@ -0,0 +1,36 @@
const {exec} = require('@actions/exec')
const path = require('path')
const semver = require('semver')
module.exports = {installElixir, installOTP}
/**
* Install Elixir.
*
* @param {string} version
* @param {string} arch
*/
async function installElixir(version) {
let arch = 'all'
if (semver.gt('1.9.0', version)) arch = 'amd64'
if (process.platform === 'linux') {
await exec(path.join(__dirname, 'install-elixir-ubuntu'), [version, arch])
}
}
/**
* Install OTP.
*
* @param {string} version
*/
async function installOTP(version) {
if (process.platform === 'linux') {
await exec(path.join(__dirname, 'install-otp-ubuntu'), [version])
return
}
throw new Error(
'@actions/setup-elixir only supports Ubuntu Linux at this time'
)
}

55
src/setup-elixir.js Normal file
View File

@@ -0,0 +1,55 @@
const core = require('@actions/core')
const {exec} = require('@actions/exec')
const {installElixir, installOTP} = require('./installer')
const {readFile} = require('fs').promises
const path = require('path')
const semver = require('semver')
main().catch(err => {
core.setFailed(err.message)
})
async function main() {
checkPlatform()
const otpSpec = core.getInput('otp-version', {required: true})
const elixirSpec = core.getInput('elixir-version', {required: true})
const otpVersion = await getVersion(
otpSpec,
path.join(__dirname, 'erlang-versions.txt')
)
const elixirVersion = await getVersion(
elixirSpec,
path.join(__dirname, 'elixir-versions.txt')
)
let installHex = core.getInput('install-hex')
installHex = installHex == null ? true : installHex
let installRebar = core.getInput('install-rebar')
installRebar = installRebar == null ? true : installRebar
console.log(`##[group]Installing OTP ${otpVersion}`)
await installOTP(otpVersion)
console.log(`##[endgroup]`)
console.log(`##[group]Installing Elixir ${elixirVersion}`)
await installElixir(elixirVersion)
console.log(`##[endgroup]`)
if (installRebar) await exec('mix local.rebar --force')
if (installHex) await exec('mix local.hex --force')
}
function checkPlatform() {
if (process.platform !== 'linux')
throw new Error(
'@actions/setup-elixir only supports Ubuntu Linux at this time'
)
}
async function getVersion(spec, versionFile) {
const range = semver.validRange(spec)
const versions = (await readFile(versionFile)).toString().split('\n')
const version = semver.maxSatisfying(versions, range)
return version || spec
}