mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
* Make use of ruby-installer-versions.js to validate the version on Windows.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
const core = require('@actions/core')
|
|
const io = require('@actions/io')
|
|
const tc = require('@actions/tool-cache')
|
|
const axios = require('axios')
|
|
|
|
const builderReleaseTag = 'builds-newer-openssl'
|
|
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
|
|
const metadataURL = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata'
|
|
|
|
export async function getAvailableVersions(engine) {
|
|
const response = await axios.get(`${metadataURL}/versions.json`)
|
|
const versions = response.data
|
|
return versions[engine]
|
|
}
|
|
|
|
export async function install(platform, ruby) {
|
|
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
|
core.addPath(`${rubyPrefix}/bin`)
|
|
return rubyPrefix
|
|
}
|
|
|
|
async function downloadAndExtract(platform, ruby) {
|
|
const rubiesDir = `${process.env.HOME}/.rubies`
|
|
await io.mkdirP(rubiesDir)
|
|
|
|
const url = `${releasesURL}/download/${builderReleaseTag}/${ruby}-${platform}.tar.gz`
|
|
console.log(url)
|
|
|
|
const downloadPath = await tc.downloadTool(url)
|
|
await tc.extractTar(downloadPath, rubiesDir)
|
|
|
|
return `${rubiesDir}/${ruby}`
|
|
}
|