mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-14 15:04:20 +02:00
Add envPreInstall, common.setupPath, use MSYS2 bash for Windows bash
envPreInstall - sets ENV values for runners common.setupPath - collects all Path operations into one function, runs before Ruby install Add MSYS2 paths to all Windows builds for MSYS2 Bash use
This commit is contained in:
+19
-14
@@ -9,23 +9,29 @@ const rubyBuilderVersions = require('./ruby-builder-versions')
|
||||
const builderReleaseTag = 'enable-shared'
|
||||
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
|
||||
|
||||
const isWin = (os.platform() === 'win32')
|
||||
|
||||
export function getAvailableVersions(platform, engine) {
|
||||
return rubyBuilderVersions.getVersions(platform)[engine]
|
||||
}
|
||||
|
||||
export async function install(platform, engine, version) {
|
||||
const rubyPrefix = await downloadAndExtract(platform, engine, version)
|
||||
let newPathEntries
|
||||
if (engine === 'rubinius') {
|
||||
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
|
||||
} else {
|
||||
newPathEntries = [path.join(rubyPrefix, 'bin')]
|
||||
}
|
||||
return [rubyPrefix, newPathEntries]
|
||||
return rubyPrefix
|
||||
}
|
||||
|
||||
async function downloadAndExtract(platform, engine, version) {
|
||||
const rubiesDir = path.join(os.homedir(), '.rubies')
|
||||
const rubiesDir = isWin ?
|
||||
`${(process.env.GITHUB_WORKSPACE || 'C')[0]}:` :
|
||||
path.join(os.homedir(), '.rubies')
|
||||
|
||||
const rubyPrefix = path.join(rubiesDir, `${engine}-${version}`)
|
||||
const newPathEntries = (engine === 'rubinius') ?
|
||||
[path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')] :
|
||||
[path.join(rubyPrefix, 'bin')]
|
||||
|
||||
common.setupPath(newPathEntries)
|
||||
|
||||
await io.mkdirP(rubiesDir)
|
||||
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
@@ -35,16 +41,15 @@ async function downloadAndExtract(platform, engine, version) {
|
||||
})
|
||||
|
||||
await common.measure('Extracting Ruby', async () => {
|
||||
if (process.env.ImageOS === 'win16') {
|
||||
const tar = '"C:\\Program Files\\Git\\usr\\bin\\tar.exe"'
|
||||
await exec.exec(tar, [ '-xz', '-C', common.win2nix(rubiesDir), '-f', common.win2nix(downloadPath) ])
|
||||
// Windows 2016 doesn't have system tar, use MSYS2's, it needs unix style paths
|
||||
if (isWin) {
|
||||
await exec.exec('tar', [ '-xz', '-C', common.win2nix(rubiesDir), '-f', common.win2nix(downloadPath) ])
|
||||
} else {
|
||||
const tar = platform.startsWith('windows') ? 'C:\\Windows\\system32\\tar.exe' : 'tar'
|
||||
await exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
|
||||
await exec.exec('tar', [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
|
||||
}
|
||||
})
|
||||
|
||||
return path.join(rubiesDir, `${engine}-${version}`)
|
||||
return rubyPrefix
|
||||
}
|
||||
|
||||
function getDownloadURL(platform, engine, version) {
|
||||
|
||||
Reference in New Issue
Block a user