mirror of
https://github.com/erlef/setup-beam.git
synced 2026-07-31 20:20:49 +00:00
Install Elixir/OTP in /tmp
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
|
||||||
wget -q https://repo.hex.pm/builds/elixir/${1}${2}.zip
|
wget -q https://repo.hex.pm/builds/elixir/${1}${2}.zip
|
||||||
unzip -d .setup-elixir/elixir ${1}${2}.zip
|
unzip -d .setup-elixir/elixir ${1}${2}.zip
|
||||||
rm ${1}${2}.zip
|
rm ${1}${2}.zip
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
|
||||||
wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz
|
wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/ubuntu-14.04/OTP-${1}.tar.gz
|
||||||
mkdir -p .setup-elixir/otp
|
mkdir -p .setup-elixir/otp
|
||||||
tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1
|
tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1
|
||||||
|
|||||||
+46
-27
@@ -15,7 +15,10 @@ async function main() {
|
|||||||
const otpSpec = core.getInput('otp-version', {required: true})
|
const otpSpec = core.getInput('otp-version', {required: true})
|
||||||
const elixirSpec = core.getInput('elixir-version', {required: true})
|
const elixirSpec = core.getInput('elixir-version', {required: true})
|
||||||
const otpVersion = await getOtpVersion(otpSpec)
|
const otpVersion = await getOtpVersion(otpSpec)
|
||||||
const [elixirVersion, otpMajor] = await getElixirVersion(elixirSpec, otpVersion)
|
const [elixirVersion, otpMajor] = await getElixirVersion(
|
||||||
|
elixirSpec,
|
||||||
|
otpVersion
|
||||||
|
)
|
||||||
|
|
||||||
let installHex = core.getInput('install-hex')
|
let installHex = core.getInput('install-hex')
|
||||||
installHex = installHex == null ? true : installHex
|
installHex = installHex == null ? true : installHex
|
||||||
@@ -30,12 +33,13 @@ async function main() {
|
|||||||
await installElixir(elixirVersion, otpMajor)
|
await installElixir(elixirVersion, otpMajor)
|
||||||
console.log(`##[endgroup]`)
|
console.log(`##[endgroup]`)
|
||||||
|
|
||||||
process.env.PATH = `${process.cwd()}/.setup-elixir/elixir/bin:${process.env.PATH}`
|
process.env.PATH = `/tmp/.setup-elixir/elixir/bin:${process.env.PATH}`
|
||||||
|
|
||||||
if (installRebar) await exec('mix local.rebar --force')
|
if (installRebar) await exec('mix local.rebar --force')
|
||||||
if (installHex) await exec('mix local.hex --force')
|
if (installHex) await exec('mix local.hex --force')
|
||||||
|
|
||||||
const matchersPath = path.join(__dirname, '..', '.github');
|
const matchersPath = path.join(__dirname, '..', '.github')
|
||||||
console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`);
|
console.log(`##[add-matcher]${path.join(matchersPath, 'elixir.json')}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkPlatform() {
|
function checkPlatform() {
|
||||||
@@ -53,10 +57,9 @@ async function getElixirVersion(spec, otpVersion) {
|
|||||||
const versions = await getElixirVersions()
|
const versions = await getElixirVersions()
|
||||||
const semverRegex = /^v(\d+\.\d+\.\d+)/
|
const semverRegex = /^v(\d+\.\d+\.\d+)/
|
||||||
|
|
||||||
const semverVersions =
|
const semverVersions = Array.from(versions.keys())
|
||||||
Array.from(versions.keys())
|
.filter(str => str.match(semverRegex))
|
||||||
.filter(str => str.match(semverRegex))
|
.map(str => str.match(semverRegex)[1])
|
||||||
.map(str => str.match(semverRegex)[1])
|
|
||||||
|
|
||||||
const version = getVersionFromSpec(spec, semverVersions)
|
const version = getVersionFromSpec(spec, semverVersions)
|
||||||
const gitRef = version ? `v${version}` : spec
|
const gitRef = version ? `v${version}` : spec
|
||||||
@@ -71,7 +74,7 @@ async function getElixirVersion(spec, otpVersion) {
|
|||||||
|
|
||||||
function getVersionFromSpec(spec, versions) {
|
function getVersionFromSpec(spec, versions) {
|
||||||
if (versions.includes(spec)) {
|
if (versions.includes(spec)) {
|
||||||
return spec;
|
return spec
|
||||||
} else {
|
} else {
|
||||||
const range = semver.validRange(spec)
|
const range = semver.validRange(spec)
|
||||||
return semver.maxSatisfying(versions, range)
|
return semver.maxSatisfying(versions, range)
|
||||||
@@ -79,28 +82,38 @@ function getVersionFromSpec(spec, versions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getOtpVersions() {
|
async function getOtpVersions() {
|
||||||
const result = await get("https://raw.githubusercontent.com/erlang/otp/master/otp_versions.table")
|
const result = await get(
|
||||||
|
'https://raw.githubusercontent.com/erlang/otp/master/otp_versions.table'
|
||||||
|
)
|
||||||
|
|
||||||
return result.trim().split('\n').map(line => {
|
return result
|
||||||
const [_, version] = line.match(/^OTP-([\.\d]+)/)
|
.trim()
|
||||||
return version
|
.split('\n')
|
||||||
})
|
.map(line => {
|
||||||
|
const [_, version] = line.match(/^OTP-([\.\d]+)/)
|
||||||
|
return version
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getElixirVersions() {
|
async function getElixirVersions() {
|
||||||
const result = await get("https://repo.hex.pm/builds/elixir/builds.txt")
|
const result = await get('https://repo.hex.pm/builds/elixir/builds.txt')
|
||||||
const map = new Map()
|
const map = new Map()
|
||||||
|
|
||||||
result.trim().split('\n').forEach(line => {
|
result
|
||||||
const match = line.match(/^(v\d+\.\d+\.\d+)-otp-(\d+)/) || line.match(/^([^-]+)-otp-(\d+)/)
|
.trim()
|
||||||
|
.split('\n')
|
||||||
|
.forEach(line => {
|
||||||
|
const match =
|
||||||
|
line.match(/^(v\d+\.\d+\.\d+)-otp-(\d+)/) ||
|
||||||
|
line.match(/^([^-]+)-otp-(\d+)/)
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
const [_, version, otp] = match
|
const [_, version, otp] = match
|
||||||
const array = (map.get(version) || [])
|
const array = map.get(version) || []
|
||||||
array.push(otp)
|
array.push(otp)
|
||||||
map.set(version, array)
|
map.set(version, array)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
@@ -111,10 +124,16 @@ function get(url) {
|
|||||||
|
|
||||||
req.on('response', res => {
|
req.on('response', res => {
|
||||||
let data = ''
|
let data = ''
|
||||||
res.on('data', (chunk) => { data += chunk })
|
res.on('data', chunk => {
|
||||||
res.on('end', () => { resolve(data) })
|
data += chunk
|
||||||
|
})
|
||||||
|
res.on('end', () => {
|
||||||
|
resolve(data)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
req.on('error', err => { reject(err) })
|
req.on('error', err => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user