Extract CRuby releases under $RUNNER_TOOL_CACHE

This commit is contained in:
Benoit Daloze
2020-11-09 13:00:42 +01:00
parent 693cf1794d
commit 933dca770c
5 changed files with 86 additions and 22 deletions
+14 -6
View File
@@ -7,7 +7,7 @@ const tc = require('@actions/tool-cache')
const common = require('./common')
const rubyBuilderVersions = require('./ruby-builder-versions')
const builderReleaseTag = 'enable-shared'
const builderReleaseTag = 'toolcache'
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
const windows = common.windows
@@ -21,14 +21,22 @@ export async function install(platform, engine, version) {
}
async function downloadAndExtract(platform, engine, version) {
const rubiesDir = windows ? `${common.drive}:` : path.join(os.homedir(), '.rubies')
let rubyPrefix
if (common.shouldExtractInToolCache(engine, version)) {
rubyPrefix = common.getToolCacheRubyPrefix(version)
} else if (windows) {
rubyPrefix = path.join(`${common.drive}:`, `${engine}-${version}`)
} else {
rubyPrefix = path.join(os.homedir(), '.rubies', `${engine}-${version}`)
}
const rubyPrefix = path.join(rubiesDir, `${engine}-${version}`)
const parentDir = path.dirname(rubyPrefix)
// Set the PATH now, so the MSYS2 'tar' is in Path on Windows
common.setupPath([path.join(rubyPrefix, 'bin')])
await io.mkdirP(rubiesDir)
await io.rmRF(rubyPrefix)
await io.mkdirP(parentDir)
const downloadPath = await common.measure('Downloading Ruby', async () => {
const url = getDownloadURL(platform, engine, version)
@@ -39,9 +47,9 @@ async function downloadAndExtract(platform, engine, version) {
await common.measure('Extracting Ruby', async () => {
if (windows) {
// Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths
await exec.exec('tar', [ '-xz', '-C', common.win2nix(rubiesDir), '-f', common.win2nix(downloadPath) ])
await exec.exec('tar', [ '-xz', '-C', common.win2nix(parentDir), '-f', common.win2nix(downloadPath) ])
} else {
await exec.exec('tar', [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
await exec.exec('tar', [ '-xz', '-C', parentDir, '-f', downloadPath ])
}
})