Compare commits

...
12 Commits
Author SHA1 Message Date
Benoit Daloze ba5b846810 Add TruffleRuby 20.1.0 2020-06-06 17:04:00 +02:00
Benoit Daloze 81be0938f7 Add an exported setupRuby() function which can be called from other actions
* Inputs are passed as simple object properties.
* It is recommended to expose the same inputs for other actions.
* See #58 and #33.
2020-06-06 13:52:42 +02:00
Benoit Daloze b04e5b8846 Use Bundler 1 on Ruby 2.3
* At least until there is a new Bundler 2 release fixing this.
* Fixes https://github.com/ruby/setup-ruby/issues/51
2020-06-06 13:16:46 +02:00
Benoit Daloze a7df86edc6 A separate bundle config path vendor/bundle is needed for older Bundler
* See https://github.com/ruby/setup-ruby/pull/53#issuecomment-624827273
2020-05-16 18:55:34 +02:00
Scott Jacobsen 8137829321 Use the new deployment true config setting 2020-05-16 18:52:00 +02:00
Scott Jacobsen a1d280134e Use the --deployment flag for bundle install
`bundle install --deployment` should be used on CI environments - it sets additional options beyond the install path (ensures the Gemfile.lock is checked in, up to date, etc). https://bundler.io/v2.0/man/bundle-install.1.html#DEPLOYMENT-MODE
2020-05-16 18:52:00 +02:00
Benoit Daloze d01e942f09 Link to condition and expression syntax docs too 2020-05-15 13:48:07 +02:00
Benoit Daloze e74945bcae Update README example workflows
* Show how to continue-on-error for head builds.
* Use the typical `bundle install` + `bundle exec rake` commands.
2020-05-15 13:29:19 +02:00
Benoit Daloze 8bff4379b9 Ruby 2.4 is EOL 2020-05-15 13:22:42 +02:00
Benoit Daloze 23b9735206 Fix checks for head versions
* Always use common.isHeadVersion().
2020-05-15 13:01:01 +02:00
Benoit Daloze 002b15eeca Add support for ruby master debug builds 2020-05-13 23:48:52 +02:00
Benoit Daloze e5857dbffe Pass the validated engine and version to install() 2020-05-13 23:36:33 +02:00
8 changed files with 144 additions and 100 deletions
+2 -1
View File
@@ -15,12 +15,13 @@ jobs:
matrix:
os: [ ubuntu, macos, windows ]
# Use various version syntax here for testing
ruby: [ 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, ruby-head, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
ruby: [ 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, ruby-head, debug, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
include:
- { os: ubuntu, ruby: rubinius }
- { os: windows, ruby: mingw }
- { os: windows, ruby: mswin }
exclude:
- { os: windows, ruby: debug }
- { os: windows, ruby: truffleruby }
- { os: windows, ruby: truffleruby-head }
+20 -11
View File
@@ -14,11 +14,12 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
| Interpreter | Versions |
| ----------- | -------- |
| Ruby | 2.2, 2.3.0 - 2.3.8, 2.4.0 - 2.4.10, 2.5.0 - 2.5.8, 2.6.0 - 2.6.6, 2.7.1, head, mingw, mswin |
| Ruby | 2.2, 2.3.0 - 2.3.8, 2.4.0 - 2.4.10, 2.5.0 - 2.5.8, 2.6.0 - 2.6.6, 2.7.1, head, debug, mingw, mswin |
| JRuby | 9.1.17.0, 9.2.9.0 - 9.2.11.1, head |
| TruffleRuby | 19.3.0 - 20.0.0, head |
| TruffleRuby | 19.3.0 - 20.1.0, head |
| Rubinius | 4.14 |
`ruby-debug` is the same as `ruby-head` but with assertions enabled (`-DRUBY_DEBUG=1`).
On Windows, `mingw` and `mswin` are `ruby-head` builds using the MSYS2/MinGW and the MSVC toolchains respectively.
Ruby 2.2 resolves to 2.2.6 on Windows (last build from RubyInstaller) and 2.2.10 otherwise.
@@ -63,13 +64,14 @@ jobs:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: ruby -v
ruby-version: 2.6 # Not needed with a .ruby-version file
- run: bundle install
- run: bundle exec rake
```
### Matrix
This matrix tests all stable releases of MRI, JRuby and TruffleRuby on Ubuntu and macOS.
This matrix tests all stable releases and `head` versions of MRI, JRuby and TruffleRuby on Ubuntu and macOS.
```yaml
name: My workflow
@@ -79,17 +81,23 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
ruby: [ 2.4, 2.5, 2.6, 2.7, jruby, truffleruby ]
runs-on: ${{ matrix.os }}
os: [ubuntu, macos]
ruby: [2.5, 2.6, 2.7, head, debug, jruby, jruby-head, truffleruby, truffleruby-head]
runs-on: ${{ matrix.os }}-latest
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: ruby -v
- run: bundle install
- run: bundle exec rake
```
See the GitHub Actions documentation for more details about the
[workflow syntax](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions)
and the [condition and expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions).
### Supported Version Syntax
* engine-version like `ruby-2.6.5` and `truffleruby-19.3.0`
@@ -104,7 +112,7 @@ jobs:
By default, if there is a `Gemfile.lock` file with a `BUNDLED WITH` section,
the latest version of Bundler with the same major version will be installed.
Otherwise, the latest Bundler version is installed (except for Ruby 2.2 where only Bundler 1 is supported).
Otherwise, the latest Bundler version is installed (except for Ruby 2.2 and 2.3 where only Bundler 1 is supported).
This behavior can be customized, see [action.yml](action.yml) for details about the `bundler` input.
@@ -121,8 +129,9 @@ You can cache the installed gems with these two steps:
bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-
- name: bundle install
run: |
bundle config deployment true
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
bundle install --jobs 4
```
When using a single OS, replace `${{ matrix.os }}` with the OS.
+4
View File
@@ -16,6 +16,10 @@ export async function measure(name, block) {
})
}
export function isHeadVersion(rubyVersion) {
return rubyVersion === 'head' || rubyVersion === 'debug' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
}
export function getVirtualEnvironmentName() {
const platform = os.platform()
if (platform === 'linux') {
Generated Vendored
+62 -44
View File
@@ -969,6 +969,7 @@ module.exports = require("os");
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "run", function() { return run; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setupRuby", function() { return setupRuby; });
const os = __webpack_require__(87)
const fs = __webpack_require__(747)
const path = __webpack_require__(622)
@@ -976,19 +977,31 @@ const core = __webpack_require__(470)
const exec = __webpack_require__(986)
const common = __webpack_require__(239)
const inputDefaults = {
'ruby-version': 'default',
'bundler': 'default',
'working-directory': '.',
}
async function run() {
try {
await main()
const options = {}
for (const key in inputDefaults) {
options[key] = core.getInput(key)
}
await setupRuby(options)
} catch (error) {
core.setFailed(error.message)
}
}
async function main() {
process.chdir(core.getInput('working-directory'))
async function setupRuby(options) {
const inputs = { ...inputDefaults, ...options }
process.chdir(inputs['working-directory'])
const platform = common.getVirtualEnvironmentName()
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])
let installer
if (platform === 'windows-latest' && engine !== 'jruby') {
@@ -998,17 +1011,17 @@ async function main() {
}
const engineVersions = installer.getAvailableVersions(platform, engine)
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
const version = validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion)
createGemRC()
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
const [rubyPrefix, newPathEntries] = await installer.install(platform, engine, version)
setupPath(ruby, newPathEntries)
setupPath(newPathEntries)
if (core.getInput('bundler') !== 'none') {
if (inputs['bundler'] !== 'none') {
await common.measure('Installing Bundler', async () =>
installBundler(platform, rubyPrefix, engine, version))
installBundler(inputs['bundler'], platform, rubyPrefix, engine, version))
}
core.setOutput('ruby-prefix', rubyPrefix)
@@ -1036,7 +1049,7 @@ function parseRubyEngineAndVersion(rubyVersion) {
}
let engine, version
if (rubyVersion.match(/^(\d+|head|mingw|mswin)/)) { // X.Y.Z => ruby-X.Y.Z
if (rubyVersion.match(/^(\d+)/) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z
engine = 'ruby'
version = rubyVersion
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
@@ -1049,24 +1062,25 @@ function parseRubyEngineAndVersion(rubyVersion) {
return [engine, version]
}
function validateRubyEngineAndVersion(platform, engineVersions, engine, version) {
function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion) {
if (!engineVersions) {
throw new Error(`Unknown engine ${engine} on ${platform}`)
}
if (!engineVersions.includes(version)) {
let version = parsedVersion
if (!engineVersions.includes(parsedVersion)) {
const latestToFirstVersion = engineVersions.slice().reverse()
const found = latestToFirstVersion.find(v => v !== 'head' && v.startsWith(version))
const found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion))
if (found) {
version = found
} else {
throw new Error(`Unknown version ${version} for ${engine} on ${platform}
throw new Error(`Unknown version ${parsedVersion} for ${engine} on ${platform}
available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}
File an issue at https://github.com/ruby/setup-ruby/issues if would like support for a new version`)
}
}
return engine + '-' + version
return version
}
function createGemRC() {
@@ -1076,7 +1090,7 @@ function createGemRC() {
}
}
function setupPath(ruby, newPathEntries) {
function setupPath(newPathEntries) {
const originalPath = process.env['PATH'].split(path.delimiter)
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
@@ -1112,8 +1126,8 @@ function readBundledWithFromGemfileLock() {
return null
}
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
var bundlerVersion = core.getInput('bundler')
async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine, rubyVersion) {
var bundlerVersion = bundlerVersionInput
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
bundlerVersion = readBundledWithFromGemfileLock()
@@ -1126,16 +1140,21 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
bundlerVersion = '2'
}
if (rubyVersion.startsWith('2.2')) {
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
bundlerVersion = '1'
} else if (/^\d+/.test(bundlerVersion)) {
if (/^\d+/.test(bundlerVersion)) {
// OK
} else {
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
}
if (engine === 'ruby' && isHeadVersion(rubyVersion) && bundlerVersion === '2') {
if (rubyVersion.startsWith('2.2')) {
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
bundlerVersion = '1'
} else if (rubyVersion.startsWith('2.3')) {
console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3')
bundlerVersion = '1'
}
if (engine === 'ruby' && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
} else if (engine === 'truffleruby' && bundlerVersion === '1') {
console.log(`Using Bundler 1 shipped with ${engine}`)
@@ -1147,10 +1166,6 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
}
}
function isHeadVersion(rubyVersion) {
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
}
if (__filename.endsWith('index.js')) { run() }
@@ -1465,7 +1480,7 @@ function getVersions(platform) {
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8",
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
"2.7.0", "2.7.1",
"head"
"head", "debug",
],
"jruby": [
"9.1.17.0",
@@ -1474,7 +1489,7 @@ function getVersions(platform) {
],
"truffleruby": [
"19.3.0", "19.3.1",
"20.0.0",
"20.0.0", "20.1.0",
"head"
]
}
@@ -1504,6 +1519,7 @@ module.exports = require("https");
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "measure", function() { return measure; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHeadVersion", function() { return isHeadVersion; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; });
const os = __webpack_require__(87)
const fs = __webpack_require__(747)
@@ -1523,6 +1539,10 @@ async function measure(name, block) {
})
}
function isHeadVersion(rubyVersion) {
return rubyVersion === 'head' || rubyVersion === 'debug' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
}
function getVirtualEnvironmentName() {
const platform = os.platform()
if (platform === 'linux') {
@@ -3541,10 +3561,10 @@ function getAvailableVersions(platform, engine) {
return rubyBuilderVersions.getVersions(platform)[engine]
}
async function install(platform, ruby) {
const rubyPrefix = await downloadAndExtract(platform, ruby)
async function install(platform, engine, version) {
const rubyPrefix = await downloadAndExtract(platform, engine, version)
let newPathEntries
if (ruby.startsWith('rubinius')) {
if (engine === 'rubinius') {
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
} else {
newPathEntries = [path.join(rubyPrefix, 'bin')]
@@ -3552,12 +3572,12 @@ async function install(platform, ruby) {
return [rubyPrefix, newPathEntries]
}
async function downloadAndExtract(platform, ruby) {
async function downloadAndExtract(platform, engine, version) {
const rubiesDir = path.join(os.homedir(), '.rubies')
await io.mkdirP(rubiesDir)
const downloadPath = await common.measure('Downloading Ruby', async () => {
const url = getDownloadURL(platform, ruby)
const url = getDownloadURL(platform, engine, version)
console.log(url)
return await tc.downloadTool(url)
})
@@ -3566,20 +3586,19 @@ async function downloadAndExtract(platform, ruby) {
await common.measure('Extracting Ruby', async () =>
exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ]))
return path.join(rubiesDir, ruby)
return path.join(rubiesDir, `${engine}-${version}`)
}
function getDownloadURL(platform, ruby) {
if (ruby.endsWith('-head')) {
return getLatestHeadBuildURL(platform, ruby)
function getDownloadURL(platform, engine, version) {
if (common.isHeadVersion(version)) {
return getLatestHeadBuildURL(platform, engine, version)
} else {
return `${releasesURL}/download/${builderReleaseTag}/${ruby}-${platform}.tar.gz`
return `${releasesURL}/download/${builderReleaseTag}/${engine}-${version}-${platform}.tar.gz`
}
}
function getLatestHeadBuildURL(platform, ruby) {
const engine = ruby.split('-')[0]
return `https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-head-${platform}.tar.gz`
function getLatestHeadBuildURL(platform, engine, version) {
return `https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-${version}-${platform}.tar.gz`
}
@@ -5001,8 +5020,7 @@ function getAvailableVersions(platform, engine) {
}
}
async function install(platform, ruby) {
const version = ruby.split('-', 2)[1]
async function install(platform, engine, version) {
const url = rubyInstallerVersions[version]
if (!url.endsWith('.7z')) {
+41 -27
View File
@@ -5,19 +5,31 @@ const core = require('@actions/core')
const exec = require('@actions/exec')
const common = require('./common')
const inputDefaults = {
'ruby-version': 'default',
'bundler': 'default',
'working-directory': '.',
}
export async function run() {
try {
await main()
const options = {}
for (const key in inputDefaults) {
options[key] = core.getInput(key)
}
await setupRuby(options)
} catch (error) {
core.setFailed(error.message)
}
}
async function main() {
process.chdir(core.getInput('working-directory'))
export async function setupRuby(options) {
const inputs = { ...inputDefaults, ...options }
process.chdir(inputs['working-directory'])
const platform = common.getVirtualEnvironmentName()
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])
let installer
if (platform === 'windows-latest' && engine !== 'jruby') {
@@ -27,17 +39,17 @@ async function main() {
}
const engineVersions = installer.getAvailableVersions(platform, engine)
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
const version = validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion)
createGemRC()
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
const [rubyPrefix, newPathEntries] = await installer.install(platform, engine, version)
setupPath(ruby, newPathEntries)
setupPath(newPathEntries)
if (core.getInput('bundler') !== 'none') {
if (inputs['bundler'] !== 'none') {
await common.measure('Installing Bundler', async () =>
installBundler(platform, rubyPrefix, engine, version))
installBundler(inputs['bundler'], platform, rubyPrefix, engine, version))
}
core.setOutput('ruby-prefix', rubyPrefix)
@@ -65,7 +77,7 @@ function parseRubyEngineAndVersion(rubyVersion) {
}
let engine, version
if (rubyVersion.match(/^(\d+|head|mingw|mswin)/)) { // X.Y.Z => ruby-X.Y.Z
if (rubyVersion.match(/^(\d+)/) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z
engine = 'ruby'
version = rubyVersion
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
@@ -78,24 +90,25 @@ function parseRubyEngineAndVersion(rubyVersion) {
return [engine, version]
}
function validateRubyEngineAndVersion(platform, engineVersions, engine, version) {
function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion) {
if (!engineVersions) {
throw new Error(`Unknown engine ${engine} on ${platform}`)
}
if (!engineVersions.includes(version)) {
let version = parsedVersion
if (!engineVersions.includes(parsedVersion)) {
const latestToFirstVersion = engineVersions.slice().reverse()
const found = latestToFirstVersion.find(v => v !== 'head' && v.startsWith(version))
const found = latestToFirstVersion.find(v => !common.isHeadVersion(v) && v.startsWith(parsedVersion))
if (found) {
version = found
} else {
throw new Error(`Unknown version ${version} for ${engine} on ${platform}
throw new Error(`Unknown version ${parsedVersion} for ${engine} on ${platform}
available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}
File an issue at https://github.com/ruby/setup-ruby/issues if would like support for a new version`)
}
}
return engine + '-' + version
return version
}
function createGemRC() {
@@ -105,7 +118,7 @@ function createGemRC() {
}
}
function setupPath(ruby, newPathEntries) {
function setupPath(newPathEntries) {
const originalPath = process.env['PATH'].split(path.delimiter)
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
@@ -141,8 +154,8 @@ function readBundledWithFromGemfileLock() {
return null
}
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
var bundlerVersion = core.getInput('bundler')
async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine, rubyVersion) {
var bundlerVersion = bundlerVersionInput
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
bundlerVersion = readBundledWithFromGemfileLock()
@@ -155,16 +168,21 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
bundlerVersion = '2'
}
if (rubyVersion.startsWith('2.2')) {
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
bundlerVersion = '1'
} else if (/^\d+/.test(bundlerVersion)) {
if (/^\d+/.test(bundlerVersion)) {
// OK
} else {
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
}
if (engine === 'ruby' && isHeadVersion(rubyVersion) && bundlerVersion === '2') {
if (rubyVersion.startsWith('2.2')) {
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
bundlerVersion = '1'
} else if (rubyVersion.startsWith('2.3')) {
console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3')
bundlerVersion = '1'
}
if (engine === 'ruby' && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
} else if (engine === 'truffleruby' && bundlerVersion === '1') {
console.log(`Using Bundler 1 shipped with ${engine}`)
@@ -176,8 +194,4 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
}
}
function isHeadVersion(rubyVersion) {
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
}
if (__filename.endsWith('index.js')) { run() }
+2 -2
View File
@@ -7,7 +7,7 @@ export function getVersions(platform) {
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8",
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
"2.7.0", "2.7.1",
"head"
"head", "debug",
],
"jruby": [
"9.1.17.0",
@@ -16,7 +16,7 @@ export function getVersions(platform) {
],
"truffleruby": [
"19.3.0", "19.3.1",
"20.0.0",
"20.0.0", "20.1.0",
"head"
]
}
+12 -13
View File
@@ -13,10 +13,10 @@ export function getAvailableVersions(platform, engine) {
return rubyBuilderVersions.getVersions(platform)[engine]
}
export async function install(platform, ruby) {
const rubyPrefix = await downloadAndExtract(platform, ruby)
export async function install(platform, engine, version) {
const rubyPrefix = await downloadAndExtract(platform, engine, version)
let newPathEntries
if (ruby.startsWith('rubinius')) {
if (engine === 'rubinius') {
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
} else {
newPathEntries = [path.join(rubyPrefix, 'bin')]
@@ -24,12 +24,12 @@ export async function install(platform, ruby) {
return [rubyPrefix, newPathEntries]
}
async function downloadAndExtract(platform, ruby) {
async function downloadAndExtract(platform, engine, version) {
const rubiesDir = path.join(os.homedir(), '.rubies')
await io.mkdirP(rubiesDir)
const downloadPath = await common.measure('Downloading Ruby', async () => {
const url = getDownloadURL(platform, ruby)
const url = getDownloadURL(platform, engine, version)
console.log(url)
return await tc.downloadTool(url)
})
@@ -38,18 +38,17 @@ async function downloadAndExtract(platform, ruby) {
await common.measure('Extracting Ruby', async () =>
exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ]))
return path.join(rubiesDir, ruby)
return path.join(rubiesDir, `${engine}-${version}`)
}
function getDownloadURL(platform, ruby) {
if (ruby.endsWith('-head')) {
return getLatestHeadBuildURL(platform, ruby)
function getDownloadURL(platform, engine, version) {
if (common.isHeadVersion(version)) {
return getLatestHeadBuildURL(platform, engine, version)
} else {
return `${releasesURL}/download/${builderReleaseTag}/${ruby}-${platform}.tar.gz`
return `${releasesURL}/download/${builderReleaseTag}/${engine}-${version}-${platform}.tar.gz`
}
}
function getLatestHeadBuildURL(platform, ruby) {
const engine = ruby.split('-')[0]
return `https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-head-${platform}.tar.gz`
function getLatestHeadBuildURL(platform, engine, version) {
return `https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-${version}-${platform}.tar.gz`
}
+1 -2
View File
@@ -33,8 +33,7 @@ export function getAvailableVersions(platform, engine) {
}
}
export async function install(platform, ruby) {
const version = ruby.split('-', 2)[1]
export async function install(platform, engine, version) {
const url = rubyInstallerVersions[version]
if (!url.endsWith('.7z')) {