mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 22:44:20 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4032b551d | ||
|
|
da846ef6db | ||
|
|
1fe99df431 | ||
|
|
c28669c4da | ||
|
|
9f60be7c73 | ||
|
|
29eefdda13 | ||
|
|
ec106b438a | ||
|
|
d7f9647ad8 | ||
|
|
f25e77d702 | ||
|
|
463c3a8161 | ||
|
|
63190648f4 | ||
|
|
aec70617e0 | ||
|
|
759c98774b | ||
|
|
24d7979773 | ||
|
|
56996937ab | ||
|
|
e9b0369f85 | ||
|
|
045dd42354 | ||
|
|
152ff008a3 | ||
|
|
d4f9058279 | ||
|
|
c40ce85201 | ||
|
|
c68e25cb8c | ||
|
|
95135e9903 | ||
|
|
9f0a9acc35 | ||
|
|
211f6c78ad | ||
|
|
47bbcca04c |
@@ -0,0 +1,12 @@
|
|||||||
|
name: Update the v1 branch when a release is published
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- run: git push origin HEAD:v1
|
||||||
+21
-68
@@ -3,38 +3,42 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
branches-ignore:
|
branches-ignore:
|
||||||
- master
|
|
||||||
- v1
|
- v1
|
||||||
tags-ignore:
|
tags-ignore:
|
||||||
- '*'
|
- '*'
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- README.md
|
- README.md
|
||||||
jobs:
|
jobs:
|
||||||
common:
|
test:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
os: [ ubuntu, macos, windows ]
|
||||||
# Use various version syntaxes here for testing
|
# Use various version syntax here for testing
|
||||||
ruby: [ 2.2, 2.3, 2.4, 2.5, 2.6.5, 2.7, ruby-head, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
|
ruby: [ 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, ruby-head, 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: ./
|
||||||
with:
|
with:
|
||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
- run: ruby -v
|
- run: ruby -v
|
||||||
|
|
||||||
- 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: gcc and ridk version (mingw)
|
- name: gcc and ridk version (mingw)
|
||||||
if: startsWith(matrix.os, 'windows')
|
if: 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 ($plat.Contains('mingw')) {
|
if ($plat.Contains('mingw')) {
|
||||||
@@ -45,76 +49,25 @@ jobs:
|
|||||||
echo 'ridk is unavailable'
|
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
|
|
||||||
run: which -a ruby rake
|
|
||||||
- name: where ruby, rake
|
|
||||||
if: startsWith(matrix.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 ''
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
- name: Subprocess test
|
||||||
run: ruby test_subprocess.rb
|
run: ruby test_subprocess.rb
|
||||||
- name: OpenSSL version
|
- name: OpenSSL version
|
||||||
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
|
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
|
||||||
- name: OpenSSL test
|
- name: OpenSSL test
|
||||||
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
|
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
|
||||||
|
|
||||||
- name: C extension test
|
- name: C extension test
|
||||||
run: gem install json:2.2.0 --no-document
|
run: gem install json:2.2.0 --no-document
|
||||||
- run: bundle --version
|
- run: bundle --version
|
||||||
- run: bundle install
|
- run: bundle install
|
||||||
- run: bundle exec rake --version
|
- run: bundle exec rake --version
|
||||||
|
|
||||||
|
- name: which ruby, rake
|
||||||
|
if: matrix.os != 'windows'
|
||||||
|
run: which -a ruby rake
|
||||||
- name: where ruby, rake
|
- name: where ruby, rake
|
||||||
if: startsWith(matrix.cfg.os, 'windows')
|
if: matrix.os == 'windows'
|
||||||
run: |
|
run: |
|
||||||
$ErrorActionPreference = 'Continue'
|
$ErrorActionPreference = 'Continue'
|
||||||
$where = 'ruby', 'rake'
|
$where = 'ruby', 'rake'
|
||||||
|
|||||||
@@ -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`.
|
||||||
@@ -137,6 +134,11 @@ This uses the [cache action](https://github.com/actions/cache).
|
|||||||
The code above is a more complete version of the [Ruby - Bundler example](https://github.com/actions/cache/blob/master/examples.md#ruby---bundler).
|
The code above is a more complete version of the [Ruby - Bundler example](https://github.com/actions/cache/blob/master/examples.md#ruby---bundler).
|
||||||
Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches.
|
Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches.
|
||||||
|
|
||||||
|
### Working Directory
|
||||||
|
|
||||||
|
The `working-directory` input can be set to resolve `.ruby-version`, `.tool-versions` and `Gemfile.lock`
|
||||||
|
if they are not at the root of the repository, see [action.yml](action.yml) for details.
|
||||||
|
|
||||||
## Windows
|
## Windows
|
||||||
|
|
||||||
Note that running CI on Windows can be quite challenging if you are not very familiar with Windows.
|
Note that running CI on Windows can be quite challenging if you are not very familiar with Windows.
|
||||||
@@ -149,17 +151,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`.
|
* 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
|
|
||||||
|
|
||||||
* This action currently only works with GitHub-hosted runners, not private runners.
|
|
||||||
|
|
||||||
## Versioning
|
## 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 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.
|
||||||
|
|
||||||
|
## 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
|
## 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.
|
||||||
|
|||||||
+5
-1
@@ -6,13 +6,17 @@ branding:
|
|||||||
icon: download
|
icon: download
|
||||||
inputs:
|
inputs:
|
||||||
ruby-version:
|
ruby-version:
|
||||||
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 or .tool-versions if unset.'
|
||||||
required: false
|
required: false
|
||||||
default: 'default'
|
default: 'default'
|
||||||
bundler:
|
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.'
|
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
|
required: false
|
||||||
default: 'default'
|
default: 'default'
|
||||||
|
working-directory:
|
||||||
|
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions and Gemfile.lock.'
|
||||||
|
required: false
|
||||||
|
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')
|
||||||
|
}
|
||||||
|
}
|
||||||
+146
-76
@@ -961,36 +961,46 @@ 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 exec = __webpack_require__(986)
|
||||||
|
const common = __webpack_require__(239)
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const platform = getVirtualEnvironmentName()
|
await main()
|
||||||
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
|
||||||
|
|
||||||
let installer
|
|
||||||
if (platform === 'windows-latest' && engine !== 'jruby') {
|
|
||||||
installer = __webpack_require__(826)
|
|
||||||
} else {
|
|
||||||
installer = __webpack_require__(489)
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
await installBundler(platform, rubyPrefix, engine, version)
|
|
||||||
|
|
||||||
core.setOutput('ruby-prefix', rubyPrefix)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
process.chdir(core.getInput('working-directory'))
|
||||||
|
|
||||||
|
const platform = common.getVirtualEnvironmentName()
|
||||||
|
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
||||||
|
|
||||||
|
let installer
|
||||||
|
if (platform === 'windows-latest' && engine !== 'jruby') {
|
||||||
|
installer = __webpack_require__(826)
|
||||||
|
} else {
|
||||||
|
installer = __webpack_require__(489)
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
function parseRubyEngineAndVersion(rubyVersion) {
|
function parseRubyEngineAndVersion(rubyVersion) {
|
||||||
if (rubyVersion === 'default') {
|
if (rubyVersion === 'default') {
|
||||||
if (fs.existsSync('.ruby-version')) {
|
if (fs.existsSync('.ruby-version')) {
|
||||||
@@ -1054,19 +1064,21 @@ function createGemRC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 readBundledWithFromGemfileLock() {
|
function readBundledWithFromGemfileLock() {
|
||||||
@@ -1089,9 +1101,6 @@ function readBundledWithFromGemfileLock() {
|
|||||||
|
|
||||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||||
var bundlerVersion = core.getInput('bundler')
|
var bundlerVersion = core.getInput('bundler')
|
||||||
if (bundlerVersion === 'none') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||||
bundlerVersion = readBundledWithFromGemfileLock()
|
bundlerVersion = readBundledWithFromGemfileLock()
|
||||||
@@ -1100,48 +1109,33 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let versionArray
|
if (bundlerVersion === 'latest') {
|
||||||
|
bundlerVersion = '2'
|
||||||
|
}
|
||||||
|
|
||||||
if (rubyVersion.startsWith('2.2')) {
|
if (rubyVersion.startsWith('2.2')) {
|
||||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
||||||
versionArray = ['-v', '~> 1']
|
bundlerVersion = '1'
|
||||||
} else if (/^\d+/.test(bundlerVersion)) {
|
} else if (/^\d+/.test(bundlerVersion)) {
|
||||||
versionArray = ['-v', `~> ${bundlerVersion}`]
|
// OK
|
||||||
} else if (bundlerVersion === 'latest') {
|
|
||||||
versionArray = []
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (engine === 'rubinius') {
|
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`)
|
console.log(`Rubinius only supports the version of Bundler shipped with it`)
|
||||||
} else if (bundlerVersion === '1' && engine === 'truffleruby') {
|
|
||||||
console.log(`Using the Bundler version shipped with ${engine}`)
|
|
||||||
} else {
|
} else {
|
||||||
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', ...versionArray, '--no-document'])
|
const gem = path.join(rubyPrefix, 'bin', 'gem')
|
||||||
|
await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVirtualEnvironmentName() {
|
function isHeadVersion(rubyVersion) {
|
||||||
const platform = os.platform()
|
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||||
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')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__filename.endsWith('index.js')) { run() }
|
if (__filename.endsWith('index.js')) { run() }
|
||||||
@@ -1489,6 +1483,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:
|
||||||
@@ -3436,19 +3481,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"
|
||||||
@@ -3469,6 +3518,7 @@ 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 = 'enable-shared'
|
const builderReleaseTag = 'enable-shared'
|
||||||
@@ -3493,12 +3543,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)
|
||||||
}
|
}
|
||||||
@@ -4591,6 +4644,13 @@ module.exports = require("path");
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 630:
|
||||||
|
/***/ (function(module) {
|
||||||
|
|
||||||
|
module.exports = require("perf_hooks");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 631:
|
/***/ 631:
|
||||||
/***/ (function(module) {
|
/***/ (function(module) {
|
||||||
|
|
||||||
@@ -4871,6 +4931,7 @@ 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
|
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
||||||
@@ -4899,15 +4960,19 @@ 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)
|
||||||
|
|
||||||
const downloadPath = await tc.downloadTool(url)
|
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||||
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
console.log(url)
|
||||||
|
return await tc.downloadTool(url)
|
||||||
|
})
|
||||||
|
|
||||||
|
await common.measure('Extracting Ruby', async () =>
|
||||||
|
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') ?
|
||||||
@@ -4926,7 +4991,8 @@ 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) {
|
||||||
@@ -4934,7 +5000,8 @@ async function setupMingw(version) {
|
|||||||
|
|
||||||
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 installMSYS(version)
|
await common.measure('Installing MSYS1', async () =>
|
||||||
|
installMSYS(version))
|
||||||
|
|
||||||
return msysPathEntries
|
return msysPathEntries
|
||||||
} else {
|
} else {
|
||||||
@@ -4981,7 +5048,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
|
||||||
|
|||||||
@@ -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|
|
||||||
|
|||||||
@@ -3,36 +3,46 @@ 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 exec = require('@actions/exec')
|
||||||
|
const common = require('./common')
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
const platform = getVirtualEnvironmentName()
|
await main()
|
||||||
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
|
||||||
|
|
||||||
let installer
|
|
||||||
if (platform === 'windows-latest' && engine !== 'jruby') {
|
|
||||||
installer = require('./windows')
|
|
||||||
} else {
|
|
||||||
installer = require('./ruby-builder')
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
await installBundler(platform, rubyPrefix, engine, version)
|
|
||||||
|
|
||||||
core.setOutput('ruby-prefix', rubyPrefix)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
process.chdir(core.getInput('working-directory'))
|
||||||
|
|
||||||
|
const platform = common.getVirtualEnvironmentName()
|
||||||
|
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
|
||||||
|
|
||||||
|
let installer
|
||||||
|
if (platform === 'windows-latest' && engine !== 'jruby') {
|
||||||
|
installer = require('./windows')
|
||||||
|
} else {
|
||||||
|
installer = require('./ruby-builder')
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
function parseRubyEngineAndVersion(rubyVersion) {
|
function parseRubyEngineAndVersion(rubyVersion) {
|
||||||
if (rubyVersion === 'default') {
|
if (rubyVersion === 'default') {
|
||||||
if (fs.existsSync('.ruby-version')) {
|
if (fs.existsSync('.ruby-version')) {
|
||||||
@@ -96,19 +106,21 @@ function createGemRC() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 readBundledWithFromGemfileLock() {
|
function readBundledWithFromGemfileLock() {
|
||||||
@@ -131,9 +143,6 @@ function readBundledWithFromGemfileLock() {
|
|||||||
|
|
||||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||||
var bundlerVersion = core.getInput('bundler')
|
var bundlerVersion = core.getInput('bundler')
|
||||||
if (bundlerVersion === 'none') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||||
bundlerVersion = readBundledWithFromGemfileLock()
|
bundlerVersion = readBundledWithFromGemfileLock()
|
||||||
@@ -142,48 +151,33 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let versionArray
|
if (bundlerVersion === 'latest') {
|
||||||
|
bundlerVersion = '2'
|
||||||
|
}
|
||||||
|
|
||||||
if (rubyVersion.startsWith('2.2')) {
|
if (rubyVersion.startsWith('2.2')) {
|
||||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
||||||
versionArray = ['-v', '~> 1']
|
bundlerVersion = '1'
|
||||||
} else if (/^\d+/.test(bundlerVersion)) {
|
} else if (/^\d+/.test(bundlerVersion)) {
|
||||||
versionArray = ['-v', `~> ${bundlerVersion}`]
|
// OK
|
||||||
} else if (bundlerVersion === 'latest') {
|
|
||||||
versionArray = []
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (engine === 'rubinius') {
|
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`)
|
console.log(`Rubinius only supports the version of Bundler shipped with it`)
|
||||||
} else if (bundlerVersion === '1' && engine === 'truffleruby') {
|
|
||||||
console.log(`Using the Bundler version shipped with ${engine}`)
|
|
||||||
} else {
|
} else {
|
||||||
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', ...versionArray, '--no-document'])
|
const gem = path.join(rubyPrefix, 'bin', 'gem')
|
||||||
|
await exec.exec(gem, ['install', 'bundler', '-v', `~> ${bundlerVersion}`, '--no-document'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVirtualEnvironmentName() {
|
function isHeadVersion(rubyVersion) {
|
||||||
const platform = os.platform()
|
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||||
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')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__filename.endsWith('index.js')) { run() }
|
if (__filename.endsWith('index.js')) { run() }
|
||||||
|
|||||||
+8
-4
@@ -3,6 +3,7 @@ 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 = 'enable-shared'
|
const builderReleaseTag = 'enable-shared'
|
||||||
@@ -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"
|
||||||
|
|||||||
+17
-7
@@ -7,6 +7,7 @@ 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
|
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
||||||
@@ -35,15 +36,19 @@ 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)
|
||||||
|
|
||||||
const downloadPath = await tc.downloadTool(url)
|
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||||
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
console.log(url)
|
||||||
|
return await tc.downloadTool(url)
|
||||||
|
})
|
||||||
|
|
||||||
|
await common.measure('Extracting Ruby', async () =>
|
||||||
|
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') ?
|
||||||
@@ -62,7 +67,8 @@ 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) {
|
||||||
@@ -70,7 +76,8 @@ async function setupMingw(version) {
|
|||||||
|
|
||||||
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 installMSYS(version)
|
await common.measure('Installing MSYS1', async () =>
|
||||||
|
installMSYS(version))
|
||||||
|
|
||||||
return msysPathEntries
|
return msysPathEntries
|
||||||
} else {
|
} else {
|
||||||
@@ -117,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
|
||||||
|
|||||||
Reference in New Issue
Block a user