mirror of
https://github.com/erlef/setup-beam.git
synced 2026-08-01 03:26:08 +00:00
Support elixir branches
This commit is contained in:
@@ -18,6 +18,9 @@ jobs:
|
|||||||
# Semver ranges
|
# Semver ranges
|
||||||
- otp-version: 21.x
|
- otp-version: 21.x
|
||||||
elixir-version: <1.9.1
|
elixir-version: <1.9.1
|
||||||
|
# Branches
|
||||||
|
- otp-version: 22.0
|
||||||
|
elixir-version: master
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1.0.0
|
- uses: actions/checkout@v1.0.0
|
||||||
- name: Use actions/setup-elixir
|
- name: Use actions/setup-elixir
|
||||||
|
|||||||
+3
-3
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
wget -q https://repo.hex.pm/builds/elixir/v${1}-otp-${2}.zip
|
wget -q https://repo.hex.pm/builds/elixir/${1}${2}.zip
|
||||||
unzip -d .setup-elixir/elixir v${1}-otp-${2}.zip
|
unzip -d .setup-elixir/elixir ${1}${2}.zip
|
||||||
rm v${1}-otp-${2}.zip
|
rm ${1}${2}.zip
|
||||||
echo "::add-path::$(pwd)/.setup-elixir/elixir/bin"
|
echo "::add-path::$(pwd)/.setup-elixir/elixir/bin"
|
||||||
|
|||||||
+2
-1
@@ -12,7 +12,8 @@ module.exports = {installElixir, installOTP}
|
|||||||
*/
|
*/
|
||||||
async function installElixir(version, otpMajor) {
|
async function installElixir(version, otpMajor) {
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
await exec(path.join(__dirname, 'install-elixir'), [version, otpMajor])
|
const otpString = otpMajor ? `-otp-${otpMajor}` : ''
|
||||||
|
await exec(path.join(__dirname, 'install-elixir'), [version, otpString])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
-12
@@ -14,8 +14,8 @@ 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 = getVersionFromSpec(otpSpec, await getOtpVersions())
|
const otpVersion = await getOtpVersion(otpSpec)
|
||||||
const [elixirVersion, otpMajor] = getElixirVersion(elixirSpec, await getElixirVersions(), 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
|
||||||
@@ -42,23 +42,33 @@ function checkPlatform() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getElixirVersion(spec, versions, otpVersion) {
|
async function getOtpVersion(spec) {
|
||||||
const version = getVersionFromSpec(spec, Array.from(versions.keys()))
|
return getVersionFromSpec(spec, await getOtpVersions()) || spec
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getElixirVersion(spec, otpVersion) {
|
||||||
|
const versions = await getElixirVersions()
|
||||||
|
const semverRegex = /^v(\d+\.\d+\.\d+)/
|
||||||
|
|
||||||
|
const semverVersions =
|
||||||
|
Array.from(versions.keys())
|
||||||
|
.filter(str => str.match(semverRegex))
|
||||||
|
.map(str => str.match(semverRegex)[1])
|
||||||
|
|
||||||
|
const version = getVersionFromSpec(spec, semverVersions)
|
||||||
|
const gitRef = version ? `v${version}` : spec
|
||||||
const [otpMajor] = otpVersion.match(/^\d+/)
|
const [otpMajor] = otpVersion.match(/^\d+/)
|
||||||
|
|
||||||
if (versions.get(version).includes(otpMajor)) {
|
if (versions.get(gitRef).includes(otpMajor)) {
|
||||||
return [version, otpMajor]
|
return [gitRef, otpMajor]
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
return [gitRef, null]
|
||||||
`Elixir ${version} and OTP ${otpVersion} are incompatible`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVersionFromSpec(spec, versions) {
|
function getVersionFromSpec(spec, versions) {
|
||||||
const range = semver.validRange(spec)
|
const range = semver.validRange(spec)
|
||||||
const version = semver.maxSatisfying(versions, range)
|
return semver.maxSatisfying(versions, range)
|
||||||
return version || spec
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getOtpVersions() {
|
async function getOtpVersions() {
|
||||||
@@ -75,7 +85,7 @@ async function getElixirVersions() {
|
|||||||
const map = new Map()
|
const map = new Map()
|
||||||
|
|
||||||
result.trim().split('\n').forEach(line => {
|
result.trim().split('\n').forEach(line => {
|
||||||
const match = line.match(/^v(\d+\.\d+\.\d+)-otp-(\d+)/)
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user