mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
759c98774b | ||
|
|
24d7979773 | ||
|
|
56996937ab | ||
|
|
e9b0369f85 | ||
|
|
045dd42354 | ||
|
|
152ff008a3 | ||
|
|
d4f9058279 | ||
|
|
c40ce85201 | ||
|
|
c68e25cb8c | ||
|
|
95135e9903 | ||
|
|
9f0a9acc35 | ||
|
|
211f6c78ad | ||
|
|
47bbcca04c | ||
|
|
f964e8aa48 | ||
|
|
e16528e678 | ||
|
|
11238a2c00 | ||
|
|
1e2e6e19e3 | ||
|
|
a1c5b2a66c | ||
|
|
e648fd85b4 | ||
|
|
fb9d6fbc69 | ||
|
|
9c77d1b41f | ||
|
|
2641afc25c | ||
|
|
d785726c7f | ||
|
|
c33236e6da | ||
|
|
e0c562b83f | ||
|
|
04510c677e | ||
|
|
c4665148cf | ||
|
|
0a45f18d44 | ||
|
|
2e60bdd7e4 | ||
|
|
0925a3eb86 |
+18
-63
@@ -14,16 +14,19 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
|
os: [ ubuntu, macos, windows ]
|
||||||
# Use various version syntaxes here for testing
|
# 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 ]
|
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:
|
exclude:
|
||||||
- os: windows-latest
|
- { os: windows, ruby: truffleruby }
|
||||||
ruby: truffleruby
|
- { os: windows, ruby: truffleruby-head }
|
||||||
- os: windows-latest
|
|
||||||
ruby: truffleruby-head
|
|
||||||
name: ${{ matrix.os }} ${{ matrix.ruby }}
|
name: ${{ matrix.os }} ${{ matrix.ruby }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: ./
|
- uses: ./
|
||||||
@@ -33,14 +36,17 @@ jobs:
|
|||||||
- name: build compiler
|
- name: build compiler
|
||||||
run: |
|
run: |
|
||||||
ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first"
|
ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first"
|
||||||
- name: ridk version (mingw)
|
- name: gcc and ridk version (mingw)
|
||||||
if: startsWith(matrix.os, 'windows')
|
if: startsWith(matrix.os, 'windows')
|
||||||
run: |
|
run: |
|
||||||
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
|
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
|
||||||
if (($abi -ge '2.4') -and $plat.Contains('mingw')) {
|
if ($plat.Contains('mingw')) {
|
||||||
ridk version
|
gcc --version
|
||||||
} else {
|
if ($abi -ge '2.4') {
|
||||||
echo 'ridk is unavailable'
|
ridk version
|
||||||
|
} else {
|
||||||
|
echo 'ridk is unavailable'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
- name: Subprocess test
|
- name: Subprocess test
|
||||||
run: ruby test_subprocess.rb
|
run: ruby test_subprocess.rb
|
||||||
@@ -68,57 +74,6 @@ jobs:
|
|||||||
echo ''
|
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: ridk version (mingw)
|
|
||||||
if: startsWith(matrix.cfg.os, 'windows')
|
|
||||||
run: |
|
|
||||||
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
|
|
||||||
if (($abi -ge '2.4') -and $plat.Contains('mingw')) {
|
|
||||||
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:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
# setup-ruby
|
# 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`.
|
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`.
|
It is very efficient and takes about 5 seconds to download, extract and add the given Ruby to the `PATH`.
|
||||||
@@ -17,16 +14,19 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
|
|||||||
|
|
||||||
| Interpreter | Versions |
|
| 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.0, head |
|
| 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.0.0, head |
|
||||||
| Rubinius | 4.14 |
|
| Rubinius | 4.14 |
|
||||||
|
|
||||||
On Windows, `mingw` and `mswin` are `ruby-head` builds using the MSYS2/MinGW and the MSVC toolchains respectively.
|
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.
|
||||||
|
Ruby 2.3 on Windows only has builds for 2.3.0, 2.3.1 and 2.3.3 (same as RubyInstaller).
|
||||||
|
|
||||||
Note that Ruby ≤ 2.3 and the OpenSSL version it needs (1.0.2) are both end-of-life,
|
Note that Ruby ≤ 2.3 and the OpenSSL version it needs (1.0.2) are both end-of-life,
|
||||||
which means Ruby ≤ 2.3 is unmaintained and considered insecure.
|
which means Ruby ≤ 2.3 is unmaintained and considered insecure.
|
||||||
On Windows, Ruby 2.4 uses OpenSSL 1.0.2, which is no longer maintained.
|
On Windows, Ruby 2.4 uses OpenSSL 1.0.2, which is no longer maintained.
|
||||||
Ruby 2.2 resolves to 2.2.6 on Windows (last build from RubyInstaller) and 2.2.10 otherwise.
|
|
||||||
|
|
||||||
### Supported Platforms
|
### Supported Platforms
|
||||||
|
|
||||||
@@ -102,9 +102,11 @@ jobs:
|
|||||||
|
|
||||||
### Bundler
|
### Bundler
|
||||||
|
|
||||||
Currently, Bundler is guaranteed to be installed for all versions.
|
By default, if there is a `Gemfile.lock` file with a `BUNDLED WITH` section,
|
||||||
If the Ruby ships with Bundler (Ruby >= 2.6), that version is used.
|
the latest version of Bundler with the same major version will be installed.
|
||||||
Otherwise (Ruby < 2.6), Bundler 1 is installed when that Ruby was built.
|
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`
|
### Caching `bundle install`
|
||||||
|
|
||||||
@@ -140,7 +142,8 @@ It is recommended to first get your build working on Ubuntu and macOS before try
|
|||||||
* The default shell on Windows is not Bash but [PowerShell](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell).
|
* The default shell on Windows is not Bash but [PowerShell](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell).
|
||||||
This can lead issues such as multi-line scripts [not working as expected](https://github.com/ruby/setup-ruby/issues/13).
|
This can lead issues such as multi-line scripts [not working as expected](https://github.com/ruby/setup-ruby/issues/13).
|
||||||
* The `PATH` contains [multiple compiler toolchains](https://github.com/ruby/setup-ruby/issues/19). Use `where.exe` to debug which tool is used.
|
* The `PATH` contains [multiple compiler toolchains](https://github.com/ruby/setup-ruby/issues/19). Use `where.exe` to debug which tool is used.
|
||||||
* MSYS2 is prepended to the `PATH`, similar to what RubyInstaller2 does.
|
* For Ruby ≥ 2.4, MSYS2 is prepended to the `Path`, similar to what RubyInstaller2 does.
|
||||||
|
* 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).
|
* JRuby on Windows has a known bug that `bundle exec rake` [fails](https://github.com/ruby/setup-ruby/issues/18).
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
@@ -152,8 +155,13 @@ It is recommended to first get your build working on Ubuntu and macOS before try
|
|||||||
This action follows semantic versioning with a moving `v1` branch.
|
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.
|
This follows the [recommendations](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) of GitHub Actions.
|
||||||
|
|
||||||
|
## 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
|
## Credits
|
||||||
|
|
||||||
The current maintainer of this action is @eregon.
|
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.
|
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.'
|
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version if unset.'
|
||||||
required: false
|
required: false
|
||||||
default: 'default'
|
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:
|
outputs:
|
||||||
ruby-prefix:
|
ruby-prefix:
|
||||||
description: 'The prefix of the installed ruby'
|
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')
|
||||||
|
}
|
||||||
|
}
|
||||||
+217
-62
@@ -951,16 +951,21 @@ module.exports = require("os");
|
|||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 104:
|
/***/ 104:
|
||||||
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
|
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "run", function() { return run; });
|
||||||
const os = __webpack_require__(87)
|
const os = __webpack_require__(87)
|
||||||
const fs = __webpack_require__(747)
|
const fs = __webpack_require__(747)
|
||||||
const path = __webpack_require__(622)
|
const path = __webpack_require__(622)
|
||||||
const core = __webpack_require__(470)
|
const core = __webpack_require__(470)
|
||||||
|
const exec = __webpack_require__(986)
|
||||||
|
const common = __webpack_require__(239)
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const platform = getVirtualEnvironmentName()
|
const platform = common.getVirtualEnvironmentName()
|
||||||
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
||||||
|
|
||||||
let installer
|
let installer
|
||||||
@@ -973,9 +978,15 @@ async function run() {
|
|||||||
const engineVersions = installer.getAvailableVersions(platform, engine)
|
const engineVersions = installer.getAvailableVersions(platform, engine)
|
||||||
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
||||||
|
|
||||||
|
createGemRC()
|
||||||
|
|
||||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
||||||
|
|
||||||
setupPath(ruby, newPathEntries)
|
setupPath(ruby, newPathEntries)
|
||||||
|
|
||||||
|
await common.measure('Installing Bundler', async () =>
|
||||||
|
installBundler(platform, rubyPrefix, engine, version))
|
||||||
|
|
||||||
core.setOutput('ruby-prefix', rubyPrefix)
|
core.setOutput('ruby-prefix', rubyPrefix)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
@@ -1037,46 +1048,92 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
|||||||
return 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) {
|
function setupPath(ruby, newPathEntries) {
|
||||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||||
|
|
||||||
if (cleanPath.length !== originalPath.length) {
|
if (cleanPath.length !== originalPath.length) {
|
||||||
console.log("Entries removed from PATH to avoid conflicts with Ruby:")
|
core.startGroup('Cleaning PATH')
|
||||||
for (const entry of originalPath) {
|
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
|
||||||
if (!cleanPath.includes(entry)) {
|
for (const entry of originalPath) {
|
||||||
console.log(` ${entry}`)
|
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() {
|
function readBundledWithFromGemfileLock() {
|
||||||
const platform = os.platform()
|
if (fs.existsSync('Gemfile.lock')) {
|
||||||
if (platform === 'linux') {
|
const contents = fs.readFileSync('Gemfile.lock', 'utf8')
|
||||||
return `ubuntu-${findUbuntuVersion()}`
|
const lines = contents.split(/\r?\n/)
|
||||||
} else if (platform === 'darwin') {
|
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
||||||
return 'macos-latest'
|
if (bundledWithLine !== -1) {
|
||||||
} else if (platform === 'win32') {
|
const nextLine = lines[bundledWithLine+1]
|
||||||
return 'windows-latest'
|
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 === 'none') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
} 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() {
|
function isHeadVersion(rubyVersion) {
|
||||||
const lsb_release = fs.readFileSync('/etc/lsb-release', 'utf8')
|
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||||
const match = lsb_release.match(/^DISTRIB_RELEASE=(\d+\.\d+)$/m)
|
|
||||||
if (match) {
|
|
||||||
return match[1]
|
|
||||||
} else {
|
|
||||||
throw new Error('Could not find Ubuntu version')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run()
|
if (__filename.endsWith('index.js')) { run() }
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -1386,15 +1443,15 @@ function getVersions(platform) {
|
|||||||
"ruby": [
|
"ruby": [
|
||||||
"2.2.10",
|
"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.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.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.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.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
|
||||||
"2.7.0",
|
"2.7.0", "2.7.1",
|
||||||
"head"
|
"head"
|
||||||
],
|
],
|
||||||
"jruby": [
|
"jruby": [
|
||||||
"9.1.17.0",
|
"9.1.17.0",
|
||||||
"9.2.9.0", "9.2.10.0", "9.2.11.0",
|
"9.2.9.0", "9.2.10.0", "9.2.11.0", "9.2.11.1",
|
||||||
"head"
|
"head"
|
||||||
],
|
],
|
||||||
"truffleruby": [
|
"truffleruby": [
|
||||||
@@ -1421,6 +1478,57 @@ function getVersions(platform) {
|
|||||||
|
|
||||||
module.exports = require("https");
|
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:
|
/***/ 280:
|
||||||
@@ -3368,19 +3476,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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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",
|
"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",
|
"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"
|
"mswin": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z"
|
||||||
@@ -3401,9 +3513,10 @@ const path = __webpack_require__(622)
|
|||||||
const exec = __webpack_require__(986)
|
const exec = __webpack_require__(986)
|
||||||
const io = __webpack_require__(1)
|
const io = __webpack_require__(1)
|
||||||
const tc = __webpack_require__(533)
|
const tc = __webpack_require__(533)
|
||||||
|
const common = __webpack_require__(239)
|
||||||
const rubyBuilderVersions = __webpack_require__(156)
|
const rubyBuilderVersions = __webpack_require__(156)
|
||||||
|
|
||||||
const builderReleaseTag = 'builds-no-warn'
|
const builderReleaseTag = 'enable-shared'
|
||||||
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
|
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
|
||||||
|
|
||||||
function getAvailableVersions(platform, engine) {
|
function getAvailableVersions(platform, engine) {
|
||||||
@@ -3412,7 +3525,7 @@ function getAvailableVersions(platform, engine) {
|
|||||||
|
|
||||||
async function install(platform, ruby) {
|
async function install(platform, ruby) {
|
||||||
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||||
let newPathEntries;
|
let newPathEntries
|
||||||
if (ruby.startsWith('rubinius')) {
|
if (ruby.startsWith('rubinius')) {
|
||||||
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
|
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
|
||||||
} else {
|
} else {
|
||||||
@@ -3425,12 +3538,15 @@ async function downloadAndExtract(platform, ruby) {
|
|||||||
const rubiesDir = path.join(os.homedir(), '.rubies')
|
const rubiesDir = path.join(os.homedir(), '.rubies')
|
||||||
await io.mkdirP(rubiesDir)
|
await io.mkdirP(rubiesDir)
|
||||||
|
|
||||||
const url = await getDownloadURL(platform, ruby)
|
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||||
console.log(url)
|
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'
|
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)
|
return path.join(rubiesDir, ruby)
|
||||||
}
|
}
|
||||||
@@ -4523,6 +4639,13 @@ module.exports = require("path");
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 630:
|
||||||
|
/***/ (function(module) {
|
||||||
|
|
||||||
|
module.exports = require("perf_hooks");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 631:
|
/***/ 631:
|
||||||
/***/ (function(module) {
|
/***/ (function(module) {
|
||||||
|
|
||||||
@@ -4798,19 +4921,29 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
||||||
|
|
||||||
const fs = __webpack_require__(747)
|
const fs = __webpack_require__(747)
|
||||||
|
const path = __webpack_require__(622)
|
||||||
const cp = __webpack_require__(129)
|
const cp = __webpack_require__(129)
|
||||||
const core = __webpack_require__(470)
|
const core = __webpack_require__(470)
|
||||||
const exec = __webpack_require__(986)
|
const exec = __webpack_require__(986)
|
||||||
const tc = __webpack_require__(533)
|
const tc = __webpack_require__(533)
|
||||||
|
const common = __webpack_require__(239)
|
||||||
const rubyInstallerVersions = __webpack_require__(471).versions
|
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
|
// 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'
|
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
|
||||||
|
|
||||||
// standard MSYS2 location, found by 'devkit'
|
// standard MSYS2 location, found by 'devkit.rb'
|
||||||
const msys2 = 'C:\\msys64'
|
const msys2 = 'C:\\msys64'
|
||||||
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
|
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
|
||||||
|
|
||||||
|
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.2 and 2.3
|
||||||
|
const msys = `${drive}:\\DevKit64`
|
||||||
|
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`,
|
||||||
|
`${msys}\\mingw\\bin`, `${msys}\\bin`]
|
||||||
|
|
||||||
function getAvailableVersions(platform, engine) {
|
function getAvailableVersions(platform, engine) {
|
||||||
if (engine === 'ruby') {
|
if (engine === 'ruby') {
|
||||||
return Object.keys(rubyInstallerVersions)
|
return Object.keys(rubyInstallerVersions)
|
||||||
@@ -4822,29 +4955,25 @@ function getAvailableVersions(platform, engine) {
|
|||||||
async function install(platform, ruby) {
|
async function install(platform, ruby) {
|
||||||
const version = ruby.split('-', 2)[1]
|
const version = ruby.split('-', 2)[1]
|
||||||
const url = rubyInstallerVersions[version]
|
const url = rubyInstallerVersions[version]
|
||||||
console.log(url)
|
|
||||||
|
|
||||||
if (!url.endsWith('.7z')) {
|
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)
|
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
|
||||||
|
|
||||||
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||||
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
console.log(url)
|
||||||
|
return await tc.downloadTool(url)
|
||||||
|
})
|
||||||
|
|
||||||
const downloadPath = await tc.downloadTool(url)
|
await common.measure('Extracting Ruby', async () =>
|
||||||
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true }))
|
||||||
const rubyPrefix = `${drive}:\\${base}`
|
const rubyPrefix = `${drive}:\\${base}`
|
||||||
|
|
||||||
let toolchainPaths = (version === 'mswin') ?
|
let toolchainPaths = (version === 'mswin') ?
|
||||||
await setupMSWin() : await setupMingw(version)
|
await setupMSWin() : await setupMingw(version)
|
||||||
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
|
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]
|
return [rubyPrefix, newPathEntries]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4857,23 +4986,46 @@ async function symLinkToEmbeddedMSYS2() {
|
|||||||
}
|
}
|
||||||
const latestVersion = toolCacheVersions.slice(-1)[0]
|
const latestVersion = toolCacheVersions.slice(-1)[0]
|
||||||
const hostedRuby = tc.find('Ruby', latestVersion)
|
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) {
|
async function setupMingw(version) {
|
||||||
|
core.exportVariable('MAKE', 'make.exe')
|
||||||
|
|
||||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||||
core.exportVariable('SSL_CERT_FILE', certFile)
|
core.exportVariable('SSL_CERT_FILE', certFile)
|
||||||
}
|
await common.measure('Installing MSYS1', async () =>
|
||||||
|
installMSYS(version))
|
||||||
|
|
||||||
// Remove when Actions Windows image contains MSYS2 install
|
return msysPathEntries
|
||||||
if (!fs.existsSync(msys2)) {
|
} else {
|
||||||
await symLinkToEmbeddedMSYS2()
|
// Remove when Actions Windows image contains MSYS2 install
|
||||||
}
|
if (!fs.existsSync(msys2)) {
|
||||||
|
await symLinkToEmbeddedMSYS2()
|
||||||
|
}
|
||||||
|
|
||||||
return msys2PathEntries
|
return msys2PathEntries
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ruby 2.2 and 2.3
|
||||||
|
async function installMSYS(version) {
|
||||||
|
const url = 'https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe'
|
||||||
|
const downloadPath = await tc.downloadTool(url)
|
||||||
|
await exec.exec('7z', ['x', downloadPath, `-o${msys}`], { silent: true })
|
||||||
|
|
||||||
|
// below are set in the old devkit.rb file ?
|
||||||
|
core.exportVariable('RI_DEVKIT', msys)
|
||||||
|
core.exportVariable('CC' , 'gcc')
|
||||||
|
core.exportVariable('CXX', 'g++')
|
||||||
|
core.exportVariable('CPP', 'cpp')
|
||||||
|
core.info(`Installed RubyInstaller DevKit for Ruby ${version}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupMSWin() {
|
async function setupMSWin() {
|
||||||
|
core.exportVariable('MAKE', 'nmake.exe')
|
||||||
|
|
||||||
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
|
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
|
||||||
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
|
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
|
||||||
if (!fs.existsSync(certsDir)) {
|
if (!fs.existsSync(certsDir)) {
|
||||||
@@ -4891,7 +5043,10 @@ async function setupMSWin() {
|
|||||||
await symLinkToEmbeddedMSYS2()
|
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
|
/* Sets MSVC environment for use in Actions
|
||||||
@@ -4915,7 +5070,7 @@ function addVCVARSEnv() {
|
|||||||
for (let [k, v] of newEnv) {
|
for (let [k, v] of newEnv) {
|
||||||
if (process.env[k] !== v) {
|
if (process.env[k] !== v) {
|
||||||
if (k === 'Path') {
|
if (k === 'Path') {
|
||||||
newPathEntries = v.replace(process.env['Path'], '').split(';')
|
newPathEntries = v.replace(process.env['Path'], '').split(path.delimiter)
|
||||||
} else {
|
} else {
|
||||||
core.exportVariable(k, v)
|
core.exportVariable(k, v)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ versions = entries.select { |entry|
|
|||||||
end
|
end
|
||||||
[version, builds.first]
|
[version, builds.first]
|
||||||
}.sort_by { |version, entry|
|
}.sort_by { |version, entry|
|
||||||
version
|
Gem::Version.new(version)
|
||||||
}.select { |version, entry|
|
}.select { |version, entry|
|
||||||
Gem::Version.new(version) >= Gem::Version.new(min_version)
|
Gem::Version.new(version) >= Gem::Version.new(min_version)
|
||||||
}.map { |version, entry|
|
}.map { |version, entry|
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ const os = require('os')
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
|
const exec = require('@actions/exec')
|
||||||
|
const common = require('./common')
|
||||||
|
|
||||||
async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
const platform = getVirtualEnvironmentName()
|
const platform = common.getVirtualEnvironmentName()
|
||||||
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
||||||
|
|
||||||
let installer
|
let installer
|
||||||
@@ -18,9 +20,15 @@ async function run() {
|
|||||||
const engineVersions = installer.getAvailableVersions(platform, engine)
|
const engineVersions = installer.getAvailableVersions(platform, engine)
|
||||||
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
||||||
|
|
||||||
|
createGemRC()
|
||||||
|
|
||||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
||||||
|
|
||||||
setupPath(ruby, newPathEntries)
|
setupPath(ruby, newPathEntries)
|
||||||
|
|
||||||
|
await common.measure('Installing Bundler', async () =>
|
||||||
|
installBundler(platform, rubyPrefix, engine, version))
|
||||||
|
|
||||||
core.setOutput('ruby-prefix', rubyPrefix)
|
core.setOutput('ruby-prefix', rubyPrefix)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
@@ -82,43 +90,89 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, version)
|
|||||||
return 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) {
|
function setupPath(ruby, newPathEntries) {
|
||||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||||
|
|
||||||
if (cleanPath.length !== originalPath.length) {
|
if (cleanPath.length !== originalPath.length) {
|
||||||
console.log("Entries removed from PATH to avoid conflicts with Ruby:")
|
core.startGroup('Cleaning PATH')
|
||||||
for (const entry of originalPath) {
|
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
|
||||||
if (!cleanPath.includes(entry)) {
|
for (const entry of originalPath) {
|
||||||
console.log(` ${entry}`)
|
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() {
|
function readBundledWithFromGemfileLock() {
|
||||||
const platform = os.platform()
|
if (fs.existsSync('Gemfile.lock')) {
|
||||||
if (platform === 'linux') {
|
const contents = fs.readFileSync('Gemfile.lock', 'utf8')
|
||||||
return `ubuntu-${findUbuntuVersion()}`
|
const lines = contents.split(/\r?\n/)
|
||||||
} else if (platform === 'darwin') {
|
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
||||||
return 'macos-latest'
|
if (bundledWithLine !== -1) {
|
||||||
} else if (platform === 'win32') {
|
const nextLine = lines[bundledWithLine+1]
|
||||||
return 'windows-latest'
|
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 === 'none') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
} 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() {
|
function isHeadVersion(rubyVersion) {
|
||||||
const lsb_release = fs.readFileSync('/etc/lsb-release', 'utf8')
|
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||||
const match = lsb_release.match(/^DISTRIB_RELEASE=(\d+\.\d+)$/m)
|
|
||||||
if (match) {
|
|
||||||
return match[1]
|
|
||||||
} else {
|
|
||||||
throw new Error('Could not find Ubuntu version')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run()
|
if (__filename.endsWith('index.js')) { run() }
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ export function getVersions(platform) {
|
|||||||
"ruby": [
|
"ruby": [
|
||||||
"2.2.10",
|
"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.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.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.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.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
|
||||||
"2.7.0",
|
"2.7.0", "2.7.1",
|
||||||
"head"
|
"head"
|
||||||
],
|
],
|
||||||
"jruby": [
|
"jruby": [
|
||||||
"9.1.17.0",
|
"9.1.17.0",
|
||||||
"9.2.9.0", "9.2.10.0", "9.2.11.0",
|
"9.2.9.0", "9.2.10.0", "9.2.11.0", "9.2.11.1",
|
||||||
"head"
|
"head"
|
||||||
],
|
],
|
||||||
"truffleruby": [
|
"truffleruby": [
|
||||||
|
|||||||
+10
-6
@@ -3,9 +3,10 @@ const path = require('path')
|
|||||||
const exec = require('@actions/exec')
|
const exec = require('@actions/exec')
|
||||||
const io = require('@actions/io')
|
const io = require('@actions/io')
|
||||||
const tc = require('@actions/tool-cache')
|
const tc = require('@actions/tool-cache')
|
||||||
|
const common = require('./common')
|
||||||
const rubyBuilderVersions = require('./ruby-builder-versions')
|
const rubyBuilderVersions = require('./ruby-builder-versions')
|
||||||
|
|
||||||
const builderReleaseTag = 'builds-no-warn'
|
const builderReleaseTag = 'enable-shared'
|
||||||
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
|
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
|
||||||
|
|
||||||
export function getAvailableVersions(platform, engine) {
|
export function getAvailableVersions(platform, engine) {
|
||||||
@@ -14,7 +15,7 @@ export function getAvailableVersions(platform, engine) {
|
|||||||
|
|
||||||
export async function install(platform, ruby) {
|
export async function install(platform, ruby) {
|
||||||
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||||
let newPathEntries;
|
let newPathEntries
|
||||||
if (ruby.startsWith('rubinius')) {
|
if (ruby.startsWith('rubinius')) {
|
||||||
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
|
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
|
||||||
} else {
|
} else {
|
||||||
@@ -27,12 +28,15 @@ async function downloadAndExtract(platform, ruby) {
|
|||||||
const rubiesDir = path.join(os.homedir(), '.rubies')
|
const rubiesDir = path.join(os.homedir(), '.rubies')
|
||||||
await io.mkdirP(rubiesDir)
|
await io.mkdirP(rubiesDir)
|
||||||
|
|
||||||
const url = await getDownloadURL(platform, ruby)
|
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||||
console.log(url)
|
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'
|
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)
|
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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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",
|
"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",
|
"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"
|
"mswin": "https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mswin.7z"
|
||||||
|
|||||||
+53
-21
@@ -2,19 +2,29 @@
|
|||||||
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
||||||
|
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
const cp = require('child_process')
|
const cp = require('child_process')
|
||||||
const core = require('@actions/core')
|
const core = require('@actions/core')
|
||||||
const exec = require('@actions/exec')
|
const exec = require('@actions/exec')
|
||||||
const tc = require('@actions/tool-cache')
|
const tc = require('@actions/tool-cache')
|
||||||
|
const common = require('./common')
|
||||||
const rubyInstallerVersions = require('./windows-versions').versions
|
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
|
// 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'
|
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
|
||||||
|
|
||||||
// standard MSYS2 location, found by 'devkit'
|
// standard MSYS2 location, found by 'devkit.rb'
|
||||||
const msys2 = 'C:\\msys64'
|
const msys2 = 'C:\\msys64'
|
||||||
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
|
const msys2PathEntries = [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
|
||||||
|
|
||||||
|
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.2 and 2.3
|
||||||
|
const msys = `${drive}:\\DevKit64`
|
||||||
|
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`,
|
||||||
|
`${msys}\\mingw\\bin`, `${msys}\\bin`]
|
||||||
|
|
||||||
export function getAvailableVersions(platform, engine) {
|
export function getAvailableVersions(platform, engine) {
|
||||||
if (engine === 'ruby') {
|
if (engine === 'ruby') {
|
||||||
return Object.keys(rubyInstallerVersions)
|
return Object.keys(rubyInstallerVersions)
|
||||||
@@ -26,29 +36,25 @@ export function getAvailableVersions(platform, engine) {
|
|||||||
export async function install(platform, ruby) {
|
export async function install(platform, ruby) {
|
||||||
const version = ruby.split('-', 2)[1]
|
const version = ruby.split('-', 2)[1]
|
||||||
const url = rubyInstallerVersions[version]
|
const url = rubyInstallerVersions[version]
|
||||||
console.log(url)
|
|
||||||
|
|
||||||
if (!url.endsWith('.7z')) {
|
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)
|
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
|
||||||
|
|
||||||
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||||
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
|
console.log(url)
|
||||||
|
return await tc.downloadTool(url)
|
||||||
|
})
|
||||||
|
|
||||||
const downloadPath = await tc.downloadTool(url)
|
await common.measure('Extracting Ruby', async () =>
|
||||||
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true }))
|
||||||
const rubyPrefix = `${drive}:\\${base}`
|
const rubyPrefix = `${drive}:\\${base}`
|
||||||
|
|
||||||
let toolchainPaths = (version === 'mswin') ?
|
let toolchainPaths = (version === 'mswin') ?
|
||||||
await setupMSWin() : await setupMingw(version)
|
await setupMSWin() : await setupMingw(version)
|
||||||
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
|
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]
|
return [rubyPrefix, newPathEntries]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,23 +67,46 @@ async function symLinkToEmbeddedMSYS2() {
|
|||||||
}
|
}
|
||||||
const latestVersion = toolCacheVersions.slice(-1)[0]
|
const latestVersion = toolCacheVersions.slice(-1)[0]
|
||||||
const hostedRuby = tc.find('Ruby', latestVersion)
|
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) {
|
async function setupMingw(version) {
|
||||||
|
core.exportVariable('MAKE', 'make.exe')
|
||||||
|
|
||||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||||
core.exportVariable('SSL_CERT_FILE', certFile)
|
core.exportVariable('SSL_CERT_FILE', certFile)
|
||||||
}
|
await common.measure('Installing MSYS1', async () =>
|
||||||
|
installMSYS(version))
|
||||||
|
|
||||||
// Remove when Actions Windows image contains MSYS2 install
|
return msysPathEntries
|
||||||
if (!fs.existsSync(msys2)) {
|
} else {
|
||||||
await symLinkToEmbeddedMSYS2()
|
// Remove when Actions Windows image contains MSYS2 install
|
||||||
}
|
if (!fs.existsSync(msys2)) {
|
||||||
|
await symLinkToEmbeddedMSYS2()
|
||||||
|
}
|
||||||
|
|
||||||
return msys2PathEntries
|
return msys2PathEntries
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ruby 2.2 and 2.3
|
||||||
|
async function installMSYS(version) {
|
||||||
|
const url = 'https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe'
|
||||||
|
const downloadPath = await tc.downloadTool(url)
|
||||||
|
await exec.exec('7z', ['x', downloadPath, `-o${msys}`], { silent: true })
|
||||||
|
|
||||||
|
// below are set in the old devkit.rb file ?
|
||||||
|
core.exportVariable('RI_DEVKIT', msys)
|
||||||
|
core.exportVariable('CC' , 'gcc')
|
||||||
|
core.exportVariable('CXX', 'g++')
|
||||||
|
core.exportVariable('CPP', 'cpp')
|
||||||
|
core.info(`Installed RubyInstaller DevKit for Ruby ${version}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupMSWin() {
|
async function setupMSWin() {
|
||||||
|
core.exportVariable('MAKE', 'nmake.exe')
|
||||||
|
|
||||||
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
|
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
|
||||||
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
|
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
|
||||||
if (!fs.existsSync(certsDir)) {
|
if (!fs.existsSync(certsDir)) {
|
||||||
@@ -95,7 +124,10 @@ async function setupMSWin() {
|
|||||||
await symLinkToEmbeddedMSYS2()
|
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
|
/* Sets MSVC environment for use in Actions
|
||||||
@@ -119,7 +151,7 @@ export function addVCVARSEnv() {
|
|||||||
for (let [k, v] of newEnv) {
|
for (let [k, v] of newEnv) {
|
||||||
if (process.env[k] !== v) {
|
if (process.env[k] !== v) {
|
||||||
if (k === 'Path') {
|
if (k === 'Path') {
|
||||||
newPathEntries = v.replace(process.env['Path'], '').split(';')
|
newPathEntries = v.replace(process.env['Path'], '').split(path.delimiter)
|
||||||
} else {
|
} else {
|
||||||
core.exportVariable(k, v)
|
core.exportVariable(k, v)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user