mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec106b438a | ||
|
|
d7f9647ad8 | ||
|
|
f25e77d702 | ||
|
|
463c3a8161 | ||
|
|
63190648f4 | ||
|
|
aec70617e0 | ||
|
|
759c98774b | ||
|
|
24d7979773 | ||
|
|
56996937ab | ||
|
|
e9b0369f85 | ||
|
|
045dd42354 | ||
|
|
152ff008a3 | ||
|
|
d4f9058279 | ||
|
|
c40ce85201 | ||
|
|
c68e25cb8c | ||
|
|
95135e9903 | ||
|
|
9f0a9acc35 | ||
|
|
211f6c78ad | ||
|
|
47bbcca04c | ||
|
|
f964e8aa48 | ||
|
|
e16528e678 | ||
|
|
11238a2c00 | ||
|
|
1e2e6e19e3 | ||
|
|
a1c5b2a66c | ||
|
|
e648fd85b4 | ||
|
|
fb9d6fbc69 | ||
|
|
9c77d1b41f | ||
|
|
2641afc25c |
+19
-65
@@ -3,7 +3,6 @@ on:
|
||||
pull_request:
|
||||
push:
|
||||
branches-ignore:
|
||||
- master
|
||||
- v1
|
||||
tags-ignore:
|
||||
- '*'
|
||||
@@ -14,27 +13,32 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
|
||||
# Use various version syntaxes here for testing
|
||||
ruby: [ 2.2, 2.3, .ruby-version, .tool-versions, ruby-head, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
|
||||
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 ]
|
||||
include:
|
||||
- { os: ubuntu, ruby: rubinius }
|
||||
- { os: windows, ruby: mingw }
|
||||
- { os: windows, ruby: mswin }
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
ruby: truffleruby
|
||||
- os: windows-latest
|
||||
ruby: truffleruby-head
|
||||
- { os: windows, ruby: truffleruby }
|
||||
- { os: windows, ruby: truffleruby-head }
|
||||
|
||||
name: ${{ matrix.os }} ${{ matrix.ruby }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: ./
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby }}
|
||||
- run: ruby -v
|
||||
|
||||
- name: build compiler
|
||||
run: |
|
||||
ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first"
|
||||
- name: gcc and ridk version (mingw)
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
if: matrix.os == 'windows'
|
||||
run: |
|
||||
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
|
||||
if ($plat.Contains('mingw')) {
|
||||
@@ -45,22 +49,25 @@ jobs:
|
||||
echo 'ridk is unavailable'
|
||||
}
|
||||
}
|
||||
|
||||
- name: Subprocess test
|
||||
run: ruby test_subprocess.rb
|
||||
- name: OpenSSL version
|
||||
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
|
||||
- name: OpenSSL test
|
||||
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
|
||||
|
||||
- name: C extension test
|
||||
run: gem install json:2.2.0 --no-document
|
||||
- run: bundle --version
|
||||
- run: bundle install
|
||||
- run: bundle exec rake --version
|
||||
|
||||
- name: which ruby, rake
|
||||
if: startsWith(matrix.os, 'windows') == false
|
||||
if: matrix.os != 'windows'
|
||||
run: which -a ruby rake
|
||||
- name: where ruby, rake
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
if: matrix.os == 'windows'
|
||||
run: |
|
||||
$ErrorActionPreference = 'Continue'
|
||||
$where = 'ruby', 'rake'
|
||||
@@ -71,59 +78,6 @@ jobs:
|
||||
echo ''
|
||||
}
|
||||
|
||||
specials:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
cfg:
|
||||
- { ruby: rubinius, os: ubuntu-18.04 }
|
||||
- { ruby: mingw , os: windows-latest }
|
||||
- { ruby: mswin , os: windows-latest }
|
||||
name: ${{ matrix.cfg.os }} ${{ matrix.cfg.ruby }}
|
||||
runs-on: ${{ matrix.cfg.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
with:
|
||||
ruby-version: ${{ matrix.cfg.ruby }}
|
||||
- run: ruby -v
|
||||
- name: build compiler
|
||||
run: |
|
||||
ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first"
|
||||
- name: gcc and ridk version (mingw)
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
run: |
|
||||
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
|
||||
if ($plat.Contains('mingw')) {
|
||||
gcc --version
|
||||
if ($abi -ge '2.4') {
|
||||
ridk version
|
||||
} else {
|
||||
echo 'ridk is unavailable'
|
||||
}
|
||||
}
|
||||
- name: Subprocess test
|
||||
run: ruby test_subprocess.rb
|
||||
- name: OpenSSL version
|
||||
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
|
||||
- name: OpenSSL test
|
||||
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
|
||||
- name: C extension test
|
||||
run: gem install json:2.2.0 --no-document
|
||||
- run: bundle --version
|
||||
- run: bundle install
|
||||
- run: bundle exec rake --version
|
||||
- name: where ruby, rake
|
||||
if: startsWith(matrix.cfg.os, 'windows')
|
||||
run: |
|
||||
$ErrorActionPreference = 'Continue'
|
||||
$where = 'ruby', 'rake'
|
||||
foreach ($e in $where) {
|
||||
$rslt = where.exe $e 2>&1 | Out-String
|
||||
if ($rslt.contains($e)) { echo $rslt.Trim() }
|
||||
else { echo "Can't find $e" }
|
||||
echo ''
|
||||
}
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
# setup-ruby
|
||||
|
||||
Note: this action used to be at `eregon/use-ruby-action` and was moved to the `ruby` organization.
|
||||
Please [update](https://github.com/ruby/setup-ruby/releases/tag/v1.13.0) if you are using `eregon/use-ruby-action`.
|
||||
|
||||
This action downloads a prebuilt ruby and adds it to the `PATH`.
|
||||
|
||||
It is very efficient and takes about 5 seconds to download, extract and add the given Ruby to the `PATH`.
|
||||
@@ -17,7 +14,7 @@ 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.9, 2.5.0 - 2.5.7, 2.6.0 - 2.6.5, 2.7.0, 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, mingw, mswin |
|
||||
| JRuby | 9.1.17.0, 9.2.9.0 - 9.2.11.1, head |
|
||||
| TruffleRuby | 19.3.0 - 20.0.0, head |
|
||||
| Rubinius | 4.14 |
|
||||
@@ -105,9 +102,11 @@ jobs:
|
||||
|
||||
### Bundler
|
||||
|
||||
Currently, Bundler is guaranteed to be installed for all versions.
|
||||
If the Ruby ships with Bundler (Ruby >= 2.6), that version is used.
|
||||
Otherwise (Ruby < 2.6), Bundler 1 is installed when that Ruby was built.
|
||||
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).
|
||||
|
||||
This behavior can be customized, see [action.yml](action.yml) for details about the `bundler` input.
|
||||
|
||||
### Caching `bundle install`
|
||||
|
||||
@@ -147,17 +146,29 @@ It is recommended to first get your build working on Ubuntu and macOS before try
|
||||
* For Ruby < 2.4, the DevKit MSYS tools are installed and prepended to the `Path`.
|
||||
* JRuby on Windows has a known bug that `bundle exec rake` [fails](https://github.com/ruby/setup-ruby/issues/18).
|
||||
|
||||
## Limitations
|
||||
|
||||
* This action currently only works with GitHub-hosted runners, not private runners.
|
||||
|
||||
## Versioning
|
||||
|
||||
It is highly recommended to use `ruby/setup-ruby@v1` for the version of this action.
|
||||
This will provide the best experience by automatically getting bug fixes, new Ruby versions and new features.
|
||||
|
||||
If you instead choose a specific version (v1.2.3) or a commit sha, there will be no automatic bug fixes and
|
||||
it will be your responsibility to update every time the action no longer works.
|
||||
Make sure to always use the latest release before reporting an issue on GitHub.
|
||||
|
||||
This action follows semantic versioning with a moving `v1` branch.
|
||||
This follows the [recommendations](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) of GitHub Actions.
|
||||
|
||||
## Limitations
|
||||
|
||||
* This action currently only works with GitHub-hosted runners, not private runners.
|
||||
|
||||
## History
|
||||
|
||||
This action used to be at `eregon/use-ruby-action` and was moved to the `ruby` organization.
|
||||
Please [update](https://github.com/ruby/setup-ruby/releases/tag/v1.13.0) if you are using `eregon/use-ruby-action`.
|
||||
|
||||
## Credits
|
||||
|
||||
The current maintainer of this action is @eregon.
|
||||
Most of the Windows logic is from https://github.com/MSP-Greg/actions-ruby by MSP-Greg.
|
||||
Most of the Windows logic is based on work by MSP-Greg.
|
||||
Many thanks to MSP-Greg and Lars Kanis for the help with Ruby Installer.
|
||||
|
||||
@@ -9,6 +9,10 @@ inputs:
|
||||
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version if unset.'
|
||||
required: false
|
||||
default: 'default'
|
||||
bundler:
|
||||
description: 'The version of Bundler to install. Either none, 1, 2, latest or Gemfile.lock. The default tries Gemfile.lock and otherwise uses latest.'
|
||||
required: false
|
||||
default: 'default'
|
||||
outputs:
|
||||
ruby-prefix:
|
||||
description: 'The prefix of the installed ruby'
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
const os = require('os')
|
||||
const fs = require('fs')
|
||||
const core = require('@actions/core')
|
||||
const { performance } = require('perf_hooks')
|
||||
|
||||
export async function measure(name, block) {
|
||||
return await core.group(name, async () => {
|
||||
const start = performance.now()
|
||||
try {
|
||||
return await block()
|
||||
} finally {
|
||||
const end = performance.now()
|
||||
const duration = (end - start) / 1000.0
|
||||
console.log(`Took ${duration.toFixed(2).padStart(6)} seconds`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function getVirtualEnvironmentName() {
|
||||
const platform = os.platform()
|
||||
if (platform === 'linux') {
|
||||
return `ubuntu-${findUbuntuVersion()}`
|
||||
} else if (platform === 'darwin') {
|
||||
return 'macos-latest'
|
||||
} else if (platform === 'win32') {
|
||||
return 'windows-latest'
|
||||
} else {
|
||||
throw new Error(`Unknown platform ${platform}`)
|
||||
}
|
||||
}
|
||||
|
||||
function findUbuntuVersion() {
|
||||
const lsb_release = fs.readFileSync('/etc/lsb-release', 'utf8')
|
||||
const match = lsb_release.match(/^DISTRIB_RELEASE=(\d+\.\d+)$/m)
|
||||
if (match) {
|
||||
return match[1]
|
||||
} else {
|
||||
throw new Error('Could not find Ubuntu version')
|
||||
}
|
||||
}
|
||||
+183
-54
@@ -960,10 +960,12 @@ const os = __webpack_require__(87)
|
||||
const fs = __webpack_require__(747)
|
||||
const path = __webpack_require__(622)
|
||||
const core = __webpack_require__(470)
|
||||
const exec = __webpack_require__(986)
|
||||
const common = __webpack_require__(239)
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const platform = getVirtualEnvironmentName()
|
||||
const platform = common.getVirtualEnvironmentName()
|
||||
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
||||
|
||||
let installer
|
||||
@@ -976,9 +978,17 @@ async function run() {
|
||||
const engineVersions = installer.getAvailableVersions(platform, engine)
|
||||
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
||||
|
||||
createGemRC()
|
||||
|
||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
||||
|
||||
setupPath(ruby, newPathEntries)
|
||||
|
||||
if (core.getInput('bundler') !== 'none') {
|
||||
await common.measure('Installing Bundler', async () =>
|
||||
installBundler(platform, rubyPrefix, engine, version))
|
||||
}
|
||||
|
||||
core.setOutput('ruby-prefix', rubyPrefix)
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
@@ -1040,43 +1050,86 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
||||
return engine + '-' + version
|
||||
}
|
||||
|
||||
function createGemRC() {
|
||||
const gemrc = path.join(os.homedir(), '.gemrc')
|
||||
if (!fs.existsSync(gemrc)) {
|
||||
fs.writeFileSync(gemrc, `gem: --no-document${os.EOL}`)
|
||||
}
|
||||
}
|
||||
|
||||
function setupPath(ruby, newPathEntries) {
|
||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||
|
||||
if (cleanPath.length !== originalPath.length) {
|
||||
console.log("Entries removed from PATH to avoid conflicts with Ruby:")
|
||||
for (const entry of originalPath) {
|
||||
if (!cleanPath.includes(entry)) {
|
||||
console.log(` ${entry}`)
|
||||
}
|
||||
}
|
||||
if (cleanPath.length !== originalPath.length) {
|
||||
core.startGroup('Cleaning PATH')
|
||||
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
|
||||
for (const entry of originalPath) {
|
||||
if (!cleanPath.includes(entry)) {
|
||||
console.log(` ${entry}`)
|
||||
}
|
||||
}
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
}
|
||||
|
||||
function getVirtualEnvironmentName() {
|
||||
const platform = os.platform()
|
||||
if (platform === 'linux') {
|
||||
return `ubuntu-${findUbuntuVersion()}`
|
||||
} else if (platform === 'darwin') {
|
||||
return 'macos-latest'
|
||||
} else if (platform === 'win32') {
|
||||
return 'windows-latest'
|
||||
function readBundledWithFromGemfileLock() {
|
||||
if (fs.existsSync('Gemfile.lock')) {
|
||||
const contents = fs.readFileSync('Gemfile.lock', 'utf8')
|
||||
const lines = contents.split(/\r?\n/)
|
||||
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
||||
if (bundledWithLine !== -1) {
|
||||
const nextLine = lines[bundledWithLine+1]
|
||||
if (nextLine && /^\d+/.test(nextLine.trim())) {
|
||||
const bundlerVersion = nextLine.trim()
|
||||
const majorVersion = bundlerVersion.match(/^\d+/)[0]
|
||||
console.log(`Using Bundler ${majorVersion} from Gemfile.lock BUNDLED WITH ${bundlerVersion}`)
|
||||
return majorVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = core.getInput('bundler')
|
||||
|
||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||
bundlerVersion = readBundledWithFromGemfileLock()
|
||||
if (!bundlerVersion) {
|
||||
bundlerVersion = 'latest'
|
||||
}
|
||||
}
|
||||
|
||||
if (bundlerVersion === 'latest') {
|
||||
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)) {
|
||||
// OK
|
||||
} else {
|
||||
throw new Error(`Unknown platform ${platform}`)
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
}
|
||||
|
||||
if (engine === 'ruby' && 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}`)
|
||||
} else if (engine === 'rubinius') {
|
||||
console.log(`Rubinius only supports the version of Bundler shipped with it`)
|
||||
} else {
|
||||
const gem = path.join(rubyPrefix, 'bin', 'gem')
|
||||
await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document'])
|
||||
}
|
||||
}
|
||||
|
||||
function findUbuntuVersion() {
|
||||
const lsb_release = fs.readFileSync('/etc/lsb-release', 'utf8')
|
||||
const match = lsb_release.match(/^DISTRIB_RELEASE=(\d+\.\d+)$/m)
|
||||
if (match) {
|
||||
return match[1]
|
||||
} else {
|
||||
throw new Error('Could not find Ubuntu version')
|
||||
}
|
||||
function isHeadVersion(rubyVersion) {
|
||||
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||
}
|
||||
|
||||
if (__filename.endsWith('index.js')) { run() }
|
||||
@@ -1389,10 +1442,10 @@ function getVersions(platform) {
|
||||
"ruby": [
|
||||
"2.2.10",
|
||||
"2.3.0", "2.3.1", "2.3.2", "2.3.3", "2.3.4", "2.3.5", "2.3.6", "2.3.7", "2.3.8",
|
||||
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9",
|
||||
"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.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5",
|
||||
"2.7.0",
|
||||
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9", "2.4.10",
|
||||
"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"
|
||||
],
|
||||
"jruby": [
|
||||
@@ -1424,6 +1477,57 @@ function getVersions(platform) {
|
||||
|
||||
module.exports = require("https");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 239:
|
||||
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"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__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; });
|
||||
const os = __webpack_require__(87)
|
||||
const fs = __webpack_require__(747)
|
||||
const core = __webpack_require__(470)
|
||||
const { performance } = __webpack_require__(630)
|
||||
|
||||
async function measure(name, block) {
|
||||
return await core.group(name, async () => {
|
||||
const start = performance.now()
|
||||
try {
|
||||
return await block()
|
||||
} finally {
|
||||
const end = performance.now()
|
||||
const duration = (end - start) / 1000.0
|
||||
console.log(`Took ${duration.toFixed(2).padStart(6)} seconds`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getVirtualEnvironmentName() {
|
||||
const platform = os.platform()
|
||||
if (platform === 'linux') {
|
||||
return `ubuntu-${findUbuntuVersion()}`
|
||||
} else if (platform === 'darwin') {
|
||||
return 'macos-latest'
|
||||
} else if (platform === 'win32') {
|
||||
return 'windows-latest'
|
||||
} else {
|
||||
throw new Error(`Unknown platform ${platform}`)
|
||||
}
|
||||
}
|
||||
|
||||
function findUbuntuVersion() {
|
||||
const lsb_release = fs.readFileSync('/etc/lsb-release', 'utf8')
|
||||
const match = lsb_release.match(/^DISTRIB_RELEASE=(\d+\.\d+)$/m)
|
||||
if (match) {
|
||||
return match[1]
|
||||
} else {
|
||||
throw new Error('Could not find Ubuntu version')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 280:
|
||||
@@ -3371,19 +3475,23 @@ const versions = {
|
||||
"2.4.6": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.6-1/rubyinstaller-2.4.6-1-x64.7z",
|
||||
"2.4.7": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.7-1/rubyinstaller-2.4.7-1-x64.7z",
|
||||
"2.4.9": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.9-1/rubyinstaller-2.4.9-1-x64.7z",
|
||||
"2.4.10": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.10-1/rubyinstaller-2.4.10-1-x64.7z",
|
||||
"2.5.0": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.0-2/rubyinstaller-2.5.0-2-x64.7z",
|
||||
"2.5.1": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.1-2/rubyinstaller-2.5.1-2-x64.7z",
|
||||
"2.5.3": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.3-1/rubyinstaller-2.5.3-1-x64.7z",
|
||||
"2.5.5": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.5-1/rubyinstaller-2.5.5-1-x64.7z",
|
||||
"2.5.6": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.6-1/rubyinstaller-2.5.6-1-x64.7z",
|
||||
"2.5.7": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.7-1/rubyinstaller-2.5.7-1-x64.7z",
|
||||
"2.5.8": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.8-1/rubyinstaller-2.5.8-1-x64.7z",
|
||||
"2.6.0": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.0-1/rubyinstaller-2.6.0-1-x64.7z",
|
||||
"2.6.1": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.1-1/rubyinstaller-2.6.1-1-x64.7z",
|
||||
"2.6.2": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.2-1/rubyinstaller-2.6.2-1-x64.7z",
|
||||
"2.6.3": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.3-1/rubyinstaller-2.6.3-1-x64.7z",
|
||||
"2.6.4": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.4-1/rubyinstaller-2.6.4-1-x64.7z",
|
||||
"2.6.5": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-2.6.5-1-x64.7z",
|
||||
"2.6.6": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.6-1/rubyinstaller-2.6.6-1-x64.7z",
|
||||
"2.7.0": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.0-1/rubyinstaller-2.7.0-1-x64.7z",
|
||||
"2.7.1": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.1-1/rubyinstaller-2.7.1-1-x64.7z",
|
||||
"head": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-head-x64.7z",
|
||||
"mingw": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z",
|
||||
"mswin": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z"
|
||||
@@ -3404,9 +3512,10 @@ const path = __webpack_require__(622)
|
||||
const exec = __webpack_require__(986)
|
||||
const io = __webpack_require__(1)
|
||||
const tc = __webpack_require__(533)
|
||||
const common = __webpack_require__(239)
|
||||
const rubyBuilderVersions = __webpack_require__(156)
|
||||
|
||||
const builderReleaseTag = 'builds-no-warn'
|
||||
const builderReleaseTag = 'enable-shared'
|
||||
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
|
||||
|
||||
function getAvailableVersions(platform, engine) {
|
||||
@@ -3415,7 +3524,7 @@ function getAvailableVersions(platform, engine) {
|
||||
|
||||
async function install(platform, ruby) {
|
||||
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||
let newPathEntries;
|
||||
let newPathEntries
|
||||
if (ruby.startsWith('rubinius')) {
|
||||
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
|
||||
} else {
|
||||
@@ -3428,12 +3537,15 @@ async function downloadAndExtract(platform, ruby) {
|
||||
const rubiesDir = path.join(os.homedir(), '.rubies')
|
||||
await io.mkdirP(rubiesDir)
|
||||
|
||||
const url = await getDownloadURL(platform, ruby)
|
||||
console.log(url)
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
const url = getDownloadURL(platform, ruby)
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
})
|
||||
|
||||
const downloadPath = await tc.downloadTool(url)
|
||||
const tar = platform.startsWith('windows') ? 'C:\\Windows\\system32\\tar.exe' : 'tar'
|
||||
await exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
|
||||
await common.measure('Extracting Ruby', async () =>
|
||||
exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ]))
|
||||
|
||||
return path.join(rubiesDir, ruby)
|
||||
}
|
||||
@@ -4526,6 +4638,13 @@ module.exports = require("path");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 630:
|
||||
/***/ (function(module) {
|
||||
|
||||
module.exports = require("perf_hooks");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 631:
|
||||
/***/ (function(module) {
|
||||
|
||||
@@ -4801,12 +4920,17 @@ __webpack_require__.r(__webpack_exports__);
|
||||
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
||||
|
||||
const fs = __webpack_require__(747)
|
||||
const path = __webpack_require__(622)
|
||||
const cp = __webpack_require__(129)
|
||||
const core = __webpack_require__(470)
|
||||
const exec = __webpack_require__(986)
|
||||
const tc = __webpack_require__(533)
|
||||
const common = __webpack_require__(239)
|
||||
const rubyInstallerVersions = __webpack_require__(471).versions
|
||||
|
||||
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
||||
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
||||
|
||||
// needed for 2.2, 2.3, and mswin, cert file used by Git for Windows
|
||||
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
|
||||
|
||||
@@ -4815,7 +4939,7 @@ const msys2 = 'C:\\msys64'
|
||||
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
|
||||
|
||||
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.2 and 2.3
|
||||
const msys = 'C:\\DevKit64'
|
||||
const msys = `${drive}:\\DevKit64`
|
||||
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`,
|
||||
`${msys}\\mingw\\bin`, `${msys}\\bin`]
|
||||
|
||||
@@ -4830,29 +4954,25 @@ function getAvailableVersions(platform, engine) {
|
||||
async function install(platform, ruby) {
|
||||
const version = ruby.split('-', 2)[1]
|
||||
const url = rubyInstallerVersions[version]
|
||||
console.log(url)
|
||||
|
||||
if (!url.endsWith('.7z')) {
|
||||
throw new Error('URL should end in .7z')
|
||||
throw new Error(`URL should end in .7z: ${url}`)
|
||||
}
|
||||
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
|
||||
|
||||
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
||||
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
})
|
||||
|
||||
const downloadPath = await tc.downloadTool(url)
|
||||
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
||||
await common.measure('Extracting Ruby', async () =>
|
||||
exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true }))
|
||||
const rubyPrefix = `${drive}:\\${base}`
|
||||
|
||||
let toolchainPaths = (version === 'mswin') ?
|
||||
await setupMSWin() : await setupMingw(version)
|
||||
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
|
||||
|
||||
// Install Bundler if needed
|
||||
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
|
||||
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
|
||||
}
|
||||
|
||||
return [rubyPrefix, newPathEntries]
|
||||
}
|
||||
|
||||
@@ -4865,13 +4985,17 @@ async function symLinkToEmbeddedMSYS2() {
|
||||
}
|
||||
const latestVersion = toolCacheVersions.slice(-1)[0]
|
||||
const hostedRuby = tc.find('Ruby', latestVersion)
|
||||
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`)
|
||||
await common.measure('Linking MSYS2', async () =>
|
||||
exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`))
|
||||
}
|
||||
|
||||
async function setupMingw(version) {
|
||||
core.exportVariable('MAKE', 'make.exe')
|
||||
|
||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||
core.exportVariable('SSL_CERT_FILE', certFile)
|
||||
await installMSYS(version)
|
||||
await common.measure('Installing MSYS1', async () =>
|
||||
installMSYS(version))
|
||||
|
||||
return msysPathEntries
|
||||
} else {
|
||||
@@ -4899,6 +5023,8 @@ async function installMSYS(version) {
|
||||
}
|
||||
|
||||
async function setupMSWin() {
|
||||
core.exportVariable('MAKE', 'nmake.exe')
|
||||
|
||||
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
|
||||
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
|
||||
if (!fs.existsSync(certsDir)) {
|
||||
@@ -4916,7 +5042,10 @@ async function setupMSWin() {
|
||||
await symLinkToEmbeddedMSYS2()
|
||||
}
|
||||
|
||||
return [...addVCVARSEnv(), ...msys2PathEntries]
|
||||
const VCPathEntries = await common.measure('Setting up MSVC environment', async () =>
|
||||
addVCVARSEnv())
|
||||
|
||||
return [...VCPathEntries, ...msys2PathEntries]
|
||||
}
|
||||
|
||||
/* Sets MSVC environment for use in Actions
|
||||
@@ -4940,7 +5069,7 @@ function addVCVARSEnv() {
|
||||
for (let [k, v] of newEnv) {
|
||||
if (process.env[k] !== v) {
|
||||
if (k === 'Path') {
|
||||
newPathEntries = v.replace(process.env['Path'], '').split(';')
|
||||
newPathEntries = v.replace(process.env['Path'], '').split(path.delimiter)
|
||||
} else {
|
||||
core.exportVariable(k, v)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ versions = entries.select { |entry|
|
||||
end
|
||||
[version, builds.first]
|
||||
}.sort_by { |version, entry|
|
||||
version
|
||||
Gem::Version.new(version)
|
||||
}.select { |version, entry|
|
||||
Gem::Version.new(version) >= Gem::Version.new(min_version)
|
||||
}.map { |version, entry|
|
||||
|
||||
@@ -2,10 +2,12 @@ const os = require('os')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const core = require('@actions/core')
|
||||
const exec = require('@actions/exec')
|
||||
const common = require('./common')
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
const platform = getVirtualEnvironmentName()
|
||||
const platform = common.getVirtualEnvironmentName()
|
||||
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
||||
|
||||
let installer
|
||||
@@ -18,9 +20,17 @@ export async function run() {
|
||||
const engineVersions = installer.getAvailableVersions(platform, engine)
|
||||
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
||||
|
||||
createGemRC()
|
||||
|
||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
||||
|
||||
setupPath(ruby, newPathEntries)
|
||||
|
||||
if (core.getInput('bundler') !== 'none') {
|
||||
await common.measure('Installing Bundler', async () =>
|
||||
installBundler(platform, rubyPrefix, engine, version))
|
||||
}
|
||||
|
||||
core.setOutput('ruby-prefix', rubyPrefix)
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
@@ -82,43 +92,86 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
||||
return engine + '-' + version
|
||||
}
|
||||
|
||||
function createGemRC() {
|
||||
const gemrc = path.join(os.homedir(), '.gemrc')
|
||||
if (!fs.existsSync(gemrc)) {
|
||||
fs.writeFileSync(gemrc, `gem: --no-document${os.EOL}`)
|
||||
}
|
||||
}
|
||||
|
||||
function setupPath(ruby, newPathEntries) {
|
||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||
|
||||
if (cleanPath.length !== originalPath.length) {
|
||||
console.log("Entries removed from PATH to avoid conflicts with Ruby:")
|
||||
for (const entry of originalPath) {
|
||||
if (!cleanPath.includes(entry)) {
|
||||
console.log(` ${entry}`)
|
||||
}
|
||||
}
|
||||
if (cleanPath.length !== originalPath.length) {
|
||||
core.startGroup('Cleaning PATH')
|
||||
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
|
||||
for (const entry of originalPath) {
|
||||
if (!cleanPath.includes(entry)) {
|
||||
console.log(` ${entry}`)
|
||||
}
|
||||
}
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
}
|
||||
|
||||
function getVirtualEnvironmentName() {
|
||||
const platform = os.platform()
|
||||
if (platform === 'linux') {
|
||||
return `ubuntu-${findUbuntuVersion()}`
|
||||
} else if (platform === 'darwin') {
|
||||
return 'macos-latest'
|
||||
} else if (platform === 'win32') {
|
||||
return 'windows-latest'
|
||||
function readBundledWithFromGemfileLock() {
|
||||
if (fs.existsSync('Gemfile.lock')) {
|
||||
const contents = fs.readFileSync('Gemfile.lock', 'utf8')
|
||||
const lines = contents.split(/\r?\n/)
|
||||
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
||||
if (bundledWithLine !== -1) {
|
||||
const nextLine = lines[bundledWithLine+1]
|
||||
if (nextLine && /^\d+/.test(nextLine.trim())) {
|
||||
const bundlerVersion = nextLine.trim()
|
||||
const majorVersion = bundlerVersion.match(/^\d+/)[0]
|
||||
console.log(`Using Bundler ${majorVersion} from Gemfile.lock BUNDLED WITH ${bundlerVersion}`)
|
||||
return majorVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = core.getInput('bundler')
|
||||
|
||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||
bundlerVersion = readBundledWithFromGemfileLock()
|
||||
if (!bundlerVersion) {
|
||||
bundlerVersion = 'latest'
|
||||
}
|
||||
}
|
||||
|
||||
if (bundlerVersion === 'latest') {
|
||||
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)) {
|
||||
// OK
|
||||
} else {
|
||||
throw new Error(`Unknown platform ${platform}`)
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
}
|
||||
|
||||
if (engine === 'ruby' && 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}`)
|
||||
} else if (engine === 'rubinius') {
|
||||
console.log(`Rubinius only supports the version of Bundler shipped with it`)
|
||||
} else {
|
||||
const gem = path.join(rubyPrefix, 'bin', 'gem')
|
||||
await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document'])
|
||||
}
|
||||
}
|
||||
|
||||
function findUbuntuVersion() {
|
||||
const lsb_release = fs.readFileSync('/etc/lsb-release', 'utf8')
|
||||
const match = lsb_release.match(/^DISTRIB_RELEASE=(\d+\.\d+)$/m)
|
||||
if (match) {
|
||||
return match[1]
|
||||
} else {
|
||||
throw new Error('Could not find Ubuntu version')
|
||||
}
|
||||
function isHeadVersion(rubyVersion) {
|
||||
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||
}
|
||||
|
||||
if (__filename.endsWith('index.js')) { run() }
|
||||
|
||||
@@ -3,10 +3,10 @@ export function getVersions(platform) {
|
||||
"ruby": [
|
||||
"2.2.10",
|
||||
"2.3.0", "2.3.1", "2.3.2", "2.3.3", "2.3.4", "2.3.5", "2.3.6", "2.3.7", "2.3.8",
|
||||
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9",
|
||||
"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.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5",
|
||||
"2.7.0",
|
||||
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9", "2.4.10",
|
||||
"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"
|
||||
],
|
||||
"jruby": [
|
||||
|
||||
+10
-6
@@ -3,9 +3,10 @@ const path = require('path')
|
||||
const exec = require('@actions/exec')
|
||||
const io = require('@actions/io')
|
||||
const tc = require('@actions/tool-cache')
|
||||
const common = require('./common')
|
||||
const rubyBuilderVersions = require('./ruby-builder-versions')
|
||||
|
||||
const builderReleaseTag = 'builds-no-warn'
|
||||
const builderReleaseTag = 'enable-shared'
|
||||
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
|
||||
|
||||
export function getAvailableVersions(platform, engine) {
|
||||
@@ -14,7 +15,7 @@ export function getAvailableVersions(platform, engine) {
|
||||
|
||||
export async function install(platform, ruby) {
|
||||
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||
let newPathEntries;
|
||||
let newPathEntries
|
||||
if (ruby.startsWith('rubinius')) {
|
||||
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
|
||||
} else {
|
||||
@@ -27,12 +28,15 @@ async function downloadAndExtract(platform, ruby) {
|
||||
const rubiesDir = path.join(os.homedir(), '.rubies')
|
||||
await io.mkdirP(rubiesDir)
|
||||
|
||||
const url = await getDownloadURL(platform, ruby)
|
||||
console.log(url)
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
const url = getDownloadURL(platform, ruby)
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
})
|
||||
|
||||
const downloadPath = await tc.downloadTool(url)
|
||||
const tar = platform.startsWith('windows') ? 'C:\\Windows\\system32\\tar.exe' : 'tar'
|
||||
await exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
|
||||
await common.measure('Extracting Ruby', async () =>
|
||||
exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ]))
|
||||
|
||||
return path.join(rubiesDir, ruby)
|
||||
}
|
||||
|
||||
@@ -11,19 +11,23 @@ export const versions = {
|
||||
"2.4.6": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.6-1/rubyinstaller-2.4.6-1-x64.7z",
|
||||
"2.4.7": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.7-1/rubyinstaller-2.4.7-1-x64.7z",
|
||||
"2.4.9": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.9-1/rubyinstaller-2.4.9-1-x64.7z",
|
||||
"2.4.10": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.10-1/rubyinstaller-2.4.10-1-x64.7z",
|
||||
"2.5.0": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.0-2/rubyinstaller-2.5.0-2-x64.7z",
|
||||
"2.5.1": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.1-2/rubyinstaller-2.5.1-2-x64.7z",
|
||||
"2.5.3": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.3-1/rubyinstaller-2.5.3-1-x64.7z",
|
||||
"2.5.5": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.5-1/rubyinstaller-2.5.5-1-x64.7z",
|
||||
"2.5.6": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.6-1/rubyinstaller-2.5.6-1-x64.7z",
|
||||
"2.5.7": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.7-1/rubyinstaller-2.5.7-1-x64.7z",
|
||||
"2.5.8": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.8-1/rubyinstaller-2.5.8-1-x64.7z",
|
||||
"2.6.0": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.0-1/rubyinstaller-2.6.0-1-x64.7z",
|
||||
"2.6.1": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.1-1/rubyinstaller-2.6.1-1-x64.7z",
|
||||
"2.6.2": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.2-1/rubyinstaller-2.6.2-1-x64.7z",
|
||||
"2.6.3": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.3-1/rubyinstaller-2.6.3-1-x64.7z",
|
||||
"2.6.4": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.4-1/rubyinstaller-2.6.4-1-x64.7z",
|
||||
"2.6.5": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-2.6.5-1-x64.7z",
|
||||
"2.6.6": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.6-1/rubyinstaller-2.6.6-1-x64.7z",
|
||||
"2.7.0": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.0-1/rubyinstaller-2.7.0-1-x64.7z",
|
||||
"2.7.1": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.1-1/rubyinstaller-2.7.1-1-x64.7z",
|
||||
"head": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-head/rubyinstaller-head-x64.7z",
|
||||
"mingw": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z",
|
||||
"mswin": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z"
|
||||
|
||||
+26
-16
@@ -2,12 +2,17 @@
|
||||
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const cp = require('child_process')
|
||||
const core = require('@actions/core')
|
||||
const exec = require('@actions/exec')
|
||||
const tc = require('@actions/tool-cache')
|
||||
const common = require('./common')
|
||||
const rubyInstallerVersions = require('./windows-versions').versions
|
||||
|
||||
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
||||
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
||||
|
||||
// needed for 2.2, 2.3, and mswin, cert file used by Git for Windows
|
||||
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
|
||||
|
||||
@@ -16,7 +21,7 @@ const msys2 = 'C:\\msys64'
|
||||
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
|
||||
|
||||
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.2 and 2.3
|
||||
const msys = 'C:\\DevKit64'
|
||||
const msys = `${drive}:\\DevKit64`
|
||||
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`,
|
||||
`${msys}\\mingw\\bin`, `${msys}\\bin`]
|
||||
|
||||
@@ -31,29 +36,25 @@ export function getAvailableVersions(platform, engine) {
|
||||
export async function install(platform, ruby) {
|
||||
const version = ruby.split('-', 2)[1]
|
||||
const url = rubyInstallerVersions[version]
|
||||
console.log(url)
|
||||
|
||||
if (!url.endsWith('.7z')) {
|
||||
throw new Error('URL should end in .7z')
|
||||
throw new Error(`URL should end in .7z: ${url}`)
|
||||
}
|
||||
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
|
||||
|
||||
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
||||
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
})
|
||||
|
||||
const downloadPath = await tc.downloadTool(url)
|
||||
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
||||
await common.measure('Extracting Ruby', async () =>
|
||||
exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true }))
|
||||
const rubyPrefix = `${drive}:\\${base}`
|
||||
|
||||
let toolchainPaths = (version === 'mswin') ?
|
||||
await setupMSWin() : await setupMingw(version)
|
||||
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
|
||||
|
||||
// Install Bundler if needed
|
||||
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
|
||||
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
|
||||
}
|
||||
|
||||
return [rubyPrefix, newPathEntries]
|
||||
}
|
||||
|
||||
@@ -66,13 +67,17 @@ async function symLinkToEmbeddedMSYS2() {
|
||||
}
|
||||
const latestVersion = toolCacheVersions.slice(-1)[0]
|
||||
const hostedRuby = tc.find('Ruby', latestVersion)
|
||||
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`)
|
||||
await common.measure('Linking MSYS2', async () =>
|
||||
exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`))
|
||||
}
|
||||
|
||||
async function setupMingw(version) {
|
||||
core.exportVariable('MAKE', 'make.exe')
|
||||
|
||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||
core.exportVariable('SSL_CERT_FILE', certFile)
|
||||
await installMSYS(version)
|
||||
await common.measure('Installing MSYS1', async () =>
|
||||
installMSYS(version))
|
||||
|
||||
return msysPathEntries
|
||||
} else {
|
||||
@@ -100,6 +105,8 @@ async function installMSYS(version) {
|
||||
}
|
||||
|
||||
async function setupMSWin() {
|
||||
core.exportVariable('MAKE', 'nmake.exe')
|
||||
|
||||
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
|
||||
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
|
||||
if (!fs.existsSync(certsDir)) {
|
||||
@@ -117,7 +124,10 @@ async function setupMSWin() {
|
||||
await symLinkToEmbeddedMSYS2()
|
||||
}
|
||||
|
||||
return [...addVCVARSEnv(), ...msys2PathEntries]
|
||||
const VCPathEntries = await common.measure('Setting up MSVC environment', async () =>
|
||||
addVCVARSEnv())
|
||||
|
||||
return [...VCPathEntries, ...msys2PathEntries]
|
||||
}
|
||||
|
||||
/* Sets MSVC environment for use in Actions
|
||||
@@ -141,7 +151,7 @@ export function addVCVARSEnv() {
|
||||
for (let [k, v] of newEnv) {
|
||||
if (process.env[k] !== v) {
|
||||
if (k === 'Path') {
|
||||
newPathEntries = v.replace(process.env['Path'], '').split(';')
|
||||
newPathEntries = v.replace(process.env['Path'], '').split(path.delimiter)
|
||||
} else {
|
||||
core.exportVariable(k, v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user