Support elixir branches
This commit is contained in:
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@@ -18,6 +18,9 @@ jobs:
|
||||
# Semver ranges
|
||||
- otp-version: 21.x
|
||||
elixir-version: <1.9.1
|
||||
# Branches
|
||||
- otp-version: 22.0
|
||||
elixir-version: master
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- name: Use actions/setup-elixir
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
wget -q https://repo.hex.pm/builds/elixir/v${1}-otp-${2}.zip
|
||||
unzip -d .setup-elixir/elixir v${1}-otp-${2}.zip
|
||||
rm v${1}-otp-${2}.zip
|
||||
wget -q https://repo.hex.pm/builds/elixir/${1}${2}.zip
|
||||
unzip -d .setup-elixir/elixir ${1}${2}.zip
|
||||
rm ${1}${2}.zip
|
||||
echo "::add-path::$(pwd)/.setup-elixir/elixir/bin"
|
||||
|
||||
@@ -12,7 +12,8 @@ module.exports = {installElixir, installOTP}
|
||||
*/
|
||||
async function installElixir(version, otpMajor) {
|
||||
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])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ async function main() {
|
||||
|
||||
const otpSpec = core.getInput('otp-version', {required: true})
|
||||
const elixirSpec = core.getInput('elixir-version', {required: true})
|
||||
const otpVersion = getVersionFromSpec(otpSpec, await getOtpVersions())
|
||||
const [elixirVersion, otpMajor] = getElixirVersion(elixirSpec, await getElixirVersions(), otpVersion)
|
||||
const otpVersion = await getOtpVersion(otpSpec)
|
||||
const [elixirVersion, otpMajor] = await getElixirVersion(elixirSpec, otpVersion)
|
||||
|
||||
let installHex = core.getInput('install-hex')
|
||||
installHex = installHex == null ? true : installHex
|
||||
@@ -42,23 +42,33 @@ function checkPlatform() {
|
||||
)
|
||||
}
|
||||
|
||||
function getElixirVersion(spec, versions, otpVersion) {
|
||||
const version = getVersionFromSpec(spec, Array.from(versions.keys()))
|
||||
async function getOtpVersion(spec) {
|
||||
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+/)
|
||||
|
||||
if (versions.get(version).includes(otpMajor)) {
|
||||
return [version, otpMajor]
|
||||
if (versions.get(gitRef).includes(otpMajor)) {
|
||||
return [gitRef, otpMajor]
|
||||
} else {
|
||||
throw new Error(
|
||||
`Elixir ${version} and OTP ${otpVersion} are incompatible`
|
||||
)
|
||||
return [gitRef, null]
|
||||
}
|
||||
}
|
||||
|
||||
function getVersionFromSpec(spec, versions) {
|
||||
const range = semver.validRange(spec)
|
||||
const version = semver.maxSatisfying(versions, range)
|
||||
return version || spec
|
||||
return semver.maxSatisfying(versions, range)
|
||||
}
|
||||
|
||||
async function getOtpVersions() {
|
||||
@@ -75,7 +85,7 @@ async function getElixirVersions() {
|
||||
const map = new Map()
|
||||
|
||||
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) {
|
||||
const [_, version, otp] = match
|
||||
|
||||
Reference in New Issue
Block a user