mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 22:44:20 +02:00
* That way it's always perfectly synchronized with the action. In practice querying another repository sometimes returned a stale copy. * Avoids an extra HTTPS request. * The axios dependency is no longer needed. * Makes it possible to tweak the versions available according to the platform.
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
const os = require('os')
|
|
const path = require('path')
|
|
const core = require('@actions/core')
|
|
const io = require('@actions/io')
|
|
const tc = require('@actions/tool-cache')
|
|
const rubyBuilderVersions = require('./ruby-install-builder-versions')
|
|
|
|
const builderReleaseTag = 'builds-newer-openssl'
|
|
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
|
|
|
|
export function getAvailableVersions(platform, engine) {
|
|
return rubyBuilderVersions.getVersions(platform)[engine]
|
|
}
|
|
|
|
export async function install(platform, ruby) {
|
|
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
|
|
|
core.addPath(path.join(rubyPrefix, 'bin'))
|
|
if (ruby.startsWith('rubinius')) {
|
|
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
|
|
}
|
|
|
|
return rubyPrefix
|
|
}
|
|
|
|
async function downloadAndExtract(platform, ruby) {
|
|
const rubiesDir = path.join(os.homedir(), '.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 path.join(rubiesDir, ruby)
|
|
}
|