mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
002b15eeca | ||
|
|
e5857dbffe | ||
|
|
381e2639aa | ||
|
|
d4032b551d | ||
|
|
da846ef6db | ||
|
|
1fe99df431 | ||
|
|
c28669c4da | ||
|
|
9f60be7c73 | ||
|
|
29eefdda13 | ||
|
|
ec106b438a | ||
|
|
d7f9647ad8 | ||
|
|
f25e77d702 | ||
|
|
463c3a8161 | ||
|
|
63190648f4 | ||
|
|
aec70617e0 | ||
|
|
759c98774b | ||
|
|
24d7979773 | ||
|
|
56996937ab | ||
|
|
e9b0369f85 | ||
|
|
045dd42354 | ||
|
|
152ff008a3 |
@@ -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
|
||||
+22
-68
@@ -3,38 +3,43 @@ on:
|
||||
pull_request:
|
||||
push:
|
||||
branches-ignore:
|
||||
- master
|
||||
- v1
|
||||
tags-ignore:
|
||||
- '*'
|
||||
paths-ignore:
|
||||
- README.md
|
||||
jobs:
|
||||
common:
|
||||
test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
||||
# Use various version syntaxes here for testing
|
||||
ruby: [ 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, ruby-head, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
|
||||
os: [ ubuntu, macos, windows ]
|
||||
# Use various version syntax here for testing
|
||||
ruby: [ 2.2, 2.3, 2.4, 2.5, 2.6.6, 2.7, ruby-head, ruby-debug, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
|
||||
include:
|
||||
- { os: ubuntu, ruby: rubinius }
|
||||
- { os: windows, ruby: mingw }
|
||||
- { os: windows, ruby: mswin }
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
ruby: truffleruby
|
||||
- os: windows-latest
|
||||
ruby: truffleruby-head
|
||||
- { os: windows, ruby: ruby-debug }
|
||||
- { os: windows, ruby: truffleruby }
|
||||
- { os: windows, ruby: truffleruby-head }
|
||||
|
||||
name: ${{ matrix.os }} ${{ matrix.ruby }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: ./
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby }}
|
||||
- run: ruby -v
|
||||
|
||||
- name: build compiler
|
||||
run: |
|
||||
ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first"
|
||||
- name: gcc and ridk version (mingw)
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
if: matrix.os == 'windows'
|
||||
run: |
|
||||
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
|
||||
if ($plat.Contains('mingw')) {
|
||||
@@ -45,76 +50,25 @@ jobs:
|
||||
echo 'ridk is unavailable'
|
||||
}
|
||||
}
|
||||
- name: Subprocess test
|
||||
run: ruby test_subprocess.rb
|
||||
- name: OpenSSL version
|
||||
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
|
||||
- name: OpenSSL test
|
||||
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
|
||||
- name: C extension test
|
||||
run: gem install json:2.2.0 --no-document
|
||||
- run: bundle --version
|
||||
- run: bundle install
|
||||
- run: bundle exec rake --version
|
||||
- name: which ruby, rake
|
||||
if: startsWith(matrix.os, 'windows') == false
|
||||
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
|
||||
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: matrix.os != 'windows'
|
||||
run: which -a ruby rake
|
||||
- name: where ruby, rake
|
||||
if: startsWith(matrix.cfg.os, 'windows')
|
||||
if: matrix.os == 'windows'
|
||||
run: |
|
||||
$ErrorActionPreference = 'Continue'
|
||||
$where = 'ruby', 'rake'
|
||||
|
||||
@@ -14,11 +14,12 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
|
||||
|
||||
| Interpreter | Versions |
|
||||
| ----------- | -------- |
|
||||
| Ruby | 2.2, 2.3.0 - 2.3.8, 2.4.0 - 2.4.10, 2.5.0 - 2.5.8, 2.6.0 - 2.6.6, 2.7.1, head, mingw, mswin |
|
||||
| Ruby | 2.2, 2.3.0 - 2.3.8, 2.4.0 - 2.4.10, 2.5.0 - 2.5.8, 2.6.0 - 2.6.6, 2.7.1, head, debug, mingw, mswin |
|
||||
| JRuby | 9.1.17.0, 9.2.9.0 - 9.2.11.1, head |
|
||||
| TruffleRuby | 19.3.0 - 20.0.0, head |
|
||||
| Rubinius | 4.14 |
|
||||
|
||||
`ruby-debug` is the same as `ruby-head` but with assertions enabled (`-DRUBY_DEBUG=1`).
|
||||
On Windows, `mingw` and `mswin` are `ruby-head` builds using the MSYS2/MinGW and the MSVC toolchains respectively.
|
||||
|
||||
Ruby 2.2 resolves to 2.2.6 on Windows (last build from RubyInstaller) and 2.2.10 otherwise.
|
||||
@@ -134,6 +135,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).
|
||||
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
|
||||
|
||||
Note that running CI on Windows can be quite challenging if you are not very familiar with Windows.
|
||||
@@ -146,15 +152,22 @@ It is recommended to first get your build working on Ubuntu and macOS before try
|
||||
* For Ruby < 2.4, the DevKit MSYS tools are installed and prepended to the `Path`.
|
||||
* JRuby on Windows has a known bug that `bundle exec rake` [fails](https://github.com/ruby/setup-ruby/issues/18).
|
||||
|
||||
## Limitations
|
||||
|
||||
* This action currently only works with GitHub-hosted runners, not private runners.
|
||||
|
||||
## Versioning
|
||||
|
||||
It is highly recommended to use `ruby/setup-ruby@v1` for the version of this action.
|
||||
This will provide the best experience by automatically getting bug fixes, new Ruby versions and new features.
|
||||
|
||||
If you instead choose a specific version (v1.2.3) or a commit sha, there will be no automatic bug fixes and
|
||||
it will be your responsibility to update every time the action no longer works.
|
||||
Make sure to always use the latest release before reporting an issue on GitHub.
|
||||
|
||||
This action follows semantic versioning with a moving `v1` branch.
|
||||
This follows the [recommendations](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) of GitHub Actions.
|
||||
|
||||
## Limitations
|
||||
|
||||
* This action currently only works with GitHub-hosted runners, not private runners.
|
||||
|
||||
## History
|
||||
|
||||
This action used to be at `eregon/use-ruby-action` and was moved to the `ruby` organization.
|
||||
|
||||
+5
-1
@@ -6,13 +6,17 @@ branding:
|
||||
icon: download
|
||||
inputs:
|
||||
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
|
||||
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'
|
||||
working-directory:
|
||||
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions and Gemfile.lock.'
|
||||
required: false
|
||||
default: '.'
|
||||
outputs:
|
||||
ruby-prefix:
|
||||
description: 'The prefix of the installed ruby'
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
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 isHeadVersion(rubyVersion) {
|
||||
return rubyVersion === 'head' || rubyVersion === 'debug' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||
}
|
||||
|
||||
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')
|
||||
}
|
||||
}
|
||||
+245
-135
@@ -356,13 +356,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const os = __webpack_require__(87);
|
||||
const events = __webpack_require__(614);
|
||||
const child = __webpack_require__(129);
|
||||
const path = __webpack_require__(622);
|
||||
const io = __webpack_require__(1);
|
||||
const ioUtil = __webpack_require__(672);
|
||||
const os = __importStar(__webpack_require__(87));
|
||||
const events = __importStar(__webpack_require__(614));
|
||||
const child = __importStar(__webpack_require__(129));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const io = __importStar(__webpack_require__(1));
|
||||
const ioUtil = __importStar(__webpack_require__(672));
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
/*
|
||||
@@ -806,6 +813,12 @@ class ToolRunner extends events.EventEmitter {
|
||||
resolve(exitCode);
|
||||
}
|
||||
});
|
||||
if (this.options.input) {
|
||||
if (!cp.stdin) {
|
||||
throw new Error('child process missing stdin');
|
||||
}
|
||||
cp.stdin.end(this.options.input);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -961,36 +974,46 @@ const fs = __webpack_require__(747)
|
||||
const path = __webpack_require__(622)
|
||||
const core = __webpack_require__(470)
|
||||
const exec = __webpack_require__(986)
|
||||
const common = __webpack_require__(239)
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const platform = getVirtualEnvironmentName()
|
||||
const [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)
|
||||
await main()
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
process.chdir(core.getInput('working-directory'))
|
||||
|
||||
const platform = common.getVirtualEnvironmentName()
|
||||
const [engine, parsedVersion] = 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 version = validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion)
|
||||
|
||||
createGemRC()
|
||||
|
||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, engine, version)
|
||||
|
||||
setupPath(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) {
|
||||
if (rubyVersion === 'default') {
|
||||
if (fs.existsSync('.ruby-version')) {
|
||||
@@ -1026,24 +1049,25 @@ function parseRubyEngineAndVersion(rubyVersion) {
|
||||
return [engine, version]
|
||||
}
|
||||
|
||||
function validateRubyEngineAndVersion(platform, engineVersions, engine, version) {
|
||||
function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion) {
|
||||
if (!engineVersions) {
|
||||
throw new Error(`Unknown engine ${engine} on ${platform}`)
|
||||
}
|
||||
|
||||
if (!engineVersions.includes(version)) {
|
||||
let version = parsedVersion
|
||||
if (!engineVersions.includes(parsedVersion)) {
|
||||
const latestToFirstVersion = engineVersions.slice().reverse()
|
||||
const found = latestToFirstVersion.find(v => v !== 'head' && v.startsWith(version))
|
||||
const found = latestToFirstVersion.find(v => v !== 'head' && v.startsWith(parsedVersion))
|
||||
if (found) {
|
||||
version = found
|
||||
} else {
|
||||
throw new Error(`Unknown version ${version} for ${engine} on ${platform}
|
||||
throw new Error(`Unknown version ${parsedVersion} for ${engine} on ${platform}
|
||||
available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}
|
||||
File an issue at https://github.com/ruby/setup-ruby/issues if would like support for a new version`)
|
||||
}
|
||||
}
|
||||
|
||||
return engine + '-' + version
|
||||
return version
|
||||
}
|
||||
|
||||
function createGemRC() {
|
||||
@@ -1053,20 +1077,22 @@ function createGemRC() {
|
||||
}
|
||||
}
|
||||
|
||||
function setupPath(ruby, newPathEntries) {
|
||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||
function setupPath(newPathEntries) {
|
||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||
|
||||
if (cleanPath.length !== originalPath.length) {
|
||||
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
|
||||
for (const entry of originalPath) {
|
||||
if (!cleanPath.includes(entry)) {
|
||||
console.log(` ${entry}`)
|
||||
}
|
||||
}
|
||||
if (cleanPath.length !== originalPath.length) {
|
||||
core.startGroup('Cleaning PATH')
|
||||
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
|
||||
for (const entry of originalPath) {
|
||||
if (!cleanPath.includes(entry)) {
|
||||
console.log(` ${entry}`)
|
||||
}
|
||||
}
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
}
|
||||
|
||||
function readBundledWithFromGemfileLock() {
|
||||
@@ -1089,9 +1115,6 @@ function readBundledWithFromGemfileLock() {
|
||||
|
||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = core.getInput('bundler')
|
||||
if (bundlerVersion === 'none') {
|
||||
return
|
||||
}
|
||||
|
||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||
bundlerVersion = readBundledWithFromGemfileLock()
|
||||
@@ -1113,10 +1136,10 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
}
|
||||
|
||||
if (engine === 'ruby' && isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
||||
console.log(`Using the Bundler version shipped with ${engine}-${rubyVersion}`)
|
||||
if (engine === 'ruby' && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
||||
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
|
||||
} else if (engine === 'truffleruby' && bundlerVersion === '1') {
|
||||
console.log(`Using the Bundler version shipped with ${engine}`)
|
||||
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 {
|
||||
@@ -1125,33 +1148,6 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
}
|
||||
}
|
||||
|
||||
function isHeadVersion(rubyVersion) {
|
||||
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||
}
|
||||
|
||||
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')
|
||||
}
|
||||
}
|
||||
|
||||
if (__filename.endsWith('index.js')) { run() }
|
||||
|
||||
|
||||
@@ -1466,7 +1462,7 @@ function getVersions(platform) {
|
||||
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8",
|
||||
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
|
||||
"2.7.0", "2.7.1",
|
||||
"head"
|
||||
"head", "debug",
|
||||
],
|
||||
"jruby": [
|
||||
"9.1.17.0",
|
||||
@@ -1497,6 +1493,62 @@ function getVersions(platform) {
|
||||
|
||||
module.exports = require("https");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 239:
|
||||
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "measure", function() { return measure; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHeadVersion", function() { return isHeadVersion; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVirtualEnvironmentName", function() { return getVirtualEnvironmentName; });
|
||||
const os = __webpack_require__(87)
|
||||
const fs = __webpack_require__(747)
|
||||
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 isHeadVersion(rubyVersion) {
|
||||
return rubyVersion === 'head' || rubyVersion === 'debug' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||
}
|
||||
|
||||
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:
|
||||
@@ -3481,6 +3533,7 @@ const path = __webpack_require__(622)
|
||||
const exec = __webpack_require__(986)
|
||||
const io = __webpack_require__(1)
|
||||
const tc = __webpack_require__(533)
|
||||
const common = __webpack_require__(239)
|
||||
const rubyBuilderVersions = __webpack_require__(156)
|
||||
|
||||
const builderReleaseTag = 'enable-shared'
|
||||
@@ -3490,10 +3543,10 @@ function getAvailableVersions(platform, engine) {
|
||||
return rubyBuilderVersions.getVersions(platform)[engine]
|
||||
}
|
||||
|
||||
async function install(platform, ruby) {
|
||||
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||
async function install(platform, engine, version) {
|
||||
const rubyPrefix = await downloadAndExtract(platform, engine, version)
|
||||
let newPathEntries
|
||||
if (ruby.startsWith('rubinius')) {
|
||||
if (engine === 'rubinius') {
|
||||
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
|
||||
} else {
|
||||
newPathEntries = [path.join(rubyPrefix, 'bin')]
|
||||
@@ -3501,31 +3554,33 @@ async function install(platform, ruby) {
|
||||
return [rubyPrefix, newPathEntries]
|
||||
}
|
||||
|
||||
async function downloadAndExtract(platform, ruby) {
|
||||
async function downloadAndExtract(platform, engine, version) {
|
||||
const rubiesDir = path.join(os.homedir(), '.rubies')
|
||||
await io.mkdirP(rubiesDir)
|
||||
|
||||
const url = await getDownloadURL(platform, ruby)
|
||||
console.log(url)
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
const url = getDownloadURL(platform, engine, version)
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
})
|
||||
|
||||
const downloadPath = await tc.downloadTool(url)
|
||||
const tar = platform.startsWith('windows') ? 'C:\\Windows\\system32\\tar.exe' : 'tar'
|
||||
await exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
|
||||
await common.measure('Extracting Ruby', async () =>
|
||||
exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ]))
|
||||
|
||||
return path.join(rubiesDir, ruby)
|
||||
return path.join(rubiesDir, `${engine}-${version}`)
|
||||
}
|
||||
|
||||
function getDownloadURL(platform, ruby) {
|
||||
if (ruby.endsWith('-head')) {
|
||||
return getLatestHeadBuildURL(platform, ruby)
|
||||
function getDownloadURL(platform, engine, version) {
|
||||
if (common.isHeadVersion(version)) {
|
||||
return getLatestHeadBuildURL(platform, engine, version)
|
||||
} else {
|
||||
return `${releasesURL}/download/${builderReleaseTag}/${ruby}-${platform}.tar.gz`
|
||||
return `${releasesURL}/download/${builderReleaseTag}/${engine}-${version}-${platform}.tar.gz`
|
||||
}
|
||||
}
|
||||
|
||||
function getLatestHeadBuildURL(platform, ruby) {
|
||||
const engine = ruby.split('-')[0]
|
||||
return `https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-head-${platform}.tar.gz`
|
||||
function getLatestHeadBuildURL(platform, engine, version) {
|
||||
return `https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-${version}-${platform}.tar.gz`
|
||||
}
|
||||
|
||||
|
||||
@@ -4108,6 +4163,7 @@ var HttpCodes;
|
||||
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
||||
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
||||
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
||||
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
||||
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
||||
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
||||
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
||||
@@ -4132,8 +4188,18 @@ function getProxyUrl(serverUrl) {
|
||||
return proxyUrl ? proxyUrl.href : '';
|
||||
}
|
||||
exports.getProxyUrl = getProxyUrl;
|
||||
const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
|
||||
const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout];
|
||||
const HttpRedirectCodes = [
|
||||
HttpCodes.MovedPermanently,
|
||||
HttpCodes.ResourceMoved,
|
||||
HttpCodes.SeeOther,
|
||||
HttpCodes.TemporaryRedirect,
|
||||
HttpCodes.PermanentRedirect
|
||||
];
|
||||
const HttpResponseRetryCodes = [
|
||||
HttpCodes.BadGateway,
|
||||
HttpCodes.ServiceUnavailable,
|
||||
HttpCodes.GatewayTimeout
|
||||
];
|
||||
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
||||
const ExponentialBackoffCeiling = 10;
|
||||
const ExponentialBackoffTimeSlice = 5;
|
||||
@@ -4258,18 +4324,22 @@ class HttpClient {
|
||||
*/
|
||||
async request(verb, requestUrl, data, headers) {
|
||||
if (this._disposed) {
|
||||
throw new Error("Client has already been disposed.");
|
||||
throw new Error('Client has already been disposed.');
|
||||
}
|
||||
let parsedUrl = url.parse(requestUrl);
|
||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||
// Only perform retries on reads since writes may not be idempotent.
|
||||
let maxTries = (this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1) ? this._maxRetries + 1 : 1;
|
||||
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
|
||||
? this._maxRetries + 1
|
||||
: 1;
|
||||
let numTries = 0;
|
||||
let response;
|
||||
while (numTries < maxTries) {
|
||||
response = await this.requestRaw(info, data);
|
||||
// Check if it's an authentication challenge
|
||||
if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
|
||||
if (response &&
|
||||
response.message &&
|
||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
||||
let authenticationHandler;
|
||||
for (let i = 0; i < this.handlers.length; i++) {
|
||||
if (this.handlers[i].canHandleAuthentication(response)) {
|
||||
@@ -4287,21 +4357,32 @@ class HttpClient {
|
||||
}
|
||||
}
|
||||
let redirectsRemaining = this._maxRedirects;
|
||||
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
|
||||
&& this._allowRedirects
|
||||
&& redirectsRemaining > 0) {
|
||||
const redirectUrl = response.message.headers["location"];
|
||||
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
|
||||
this._allowRedirects &&
|
||||
redirectsRemaining > 0) {
|
||||
const redirectUrl = response.message.headers['location'];
|
||||
if (!redirectUrl) {
|
||||
// if there's no location to redirect to, we won't
|
||||
break;
|
||||
}
|
||||
let parsedRedirectUrl = url.parse(redirectUrl);
|
||||
if (parsedUrl.protocol == 'https:' && parsedUrl.protocol != parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) {
|
||||
throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");
|
||||
if (parsedUrl.protocol == 'https:' &&
|
||||
parsedUrl.protocol != parsedRedirectUrl.protocol &&
|
||||
!this._allowRedirectDowngrade) {
|
||||
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
|
||||
}
|
||||
// we need to finish reading the response before reassigning response
|
||||
// which will leak the open socket.
|
||||
await response.readBody();
|
||||
// strip authorization header if redirected to a different hostname
|
||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
||||
for (let header in headers) {
|
||||
// header names are case insensitive
|
||||
if (header.toLowerCase() === 'authorization') {
|
||||
delete headers[header];
|
||||
}
|
||||
}
|
||||
}
|
||||
// let's make the request with the new redirectUrl
|
||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
||||
response = await this.requestRaw(info, data);
|
||||
@@ -4352,8 +4433,8 @@ class HttpClient {
|
||||
*/
|
||||
requestRawWithCallback(info, data, onResult) {
|
||||
let socket;
|
||||
if (typeof (data) === 'string') {
|
||||
info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
|
||||
if (typeof data === 'string') {
|
||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||||
}
|
||||
let callbackCalled = false;
|
||||
let handleResult = (err, res) => {
|
||||
@@ -4366,7 +4447,7 @@ class HttpClient {
|
||||
let res = new HttpClientResponse(msg);
|
||||
handleResult(null, res);
|
||||
});
|
||||
req.on('socket', (sock) => {
|
||||
req.on('socket', sock => {
|
||||
socket = sock;
|
||||
});
|
||||
// If we ever get disconnected, we want the socket to timeout eventually
|
||||
@@ -4381,10 +4462,10 @@ class HttpClient {
|
||||
// res should have headers
|
||||
handleResult(err, null);
|
||||
});
|
||||
if (data && typeof (data) === 'string') {
|
||||
if (data && typeof data === 'string') {
|
||||
req.write(data, 'utf8');
|
||||
}
|
||||
if (data && typeof (data) !== 'string') {
|
||||
if (data && typeof data !== 'string') {
|
||||
data.on('close', function () {
|
||||
req.end();
|
||||
});
|
||||
@@ -4411,31 +4492,34 @@ class HttpClient {
|
||||
const defaultPort = usingSsl ? 443 : 80;
|
||||
info.options = {};
|
||||
info.options.host = info.parsedUrl.hostname;
|
||||
info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
|
||||
info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
||||
info.options.port = info.parsedUrl.port
|
||||
? parseInt(info.parsedUrl.port)
|
||||
: defaultPort;
|
||||
info.options.path =
|
||||
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
||||
info.options.method = method;
|
||||
info.options.headers = this._mergeHeaders(headers);
|
||||
if (this.userAgent != null) {
|
||||
info.options.headers["user-agent"] = this.userAgent;
|
||||
info.options.headers['user-agent'] = this.userAgent;
|
||||
}
|
||||
info.options.agent = this._getAgent(info.parsedUrl);
|
||||
// gives handlers an opportunity to participate
|
||||
if (this.handlers) {
|
||||
this.handlers.forEach((handler) => {
|
||||
this.handlers.forEach(handler => {
|
||||
handler.prepareRequest(info.options);
|
||||
});
|
||||
}
|
||||
return info;
|
||||
}
|
||||
_mergeHeaders(headers) {
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
||||
}
|
||||
return lowercaseKeys(headers || {});
|
||||
}
|
||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||
let clientHeader;
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
||||
@@ -4473,7 +4557,7 @@ class HttpClient {
|
||||
proxyAuth: proxyUrl.auth,
|
||||
host: proxyUrl.hostname,
|
||||
port: proxyUrl.port
|
||||
},
|
||||
}
|
||||
};
|
||||
let tunnelAgent;
|
||||
const overHttps = proxyUrl.protocol === 'https:';
|
||||
@@ -4500,7 +4584,9 @@ class HttpClient {
|
||||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
||||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
||||
// we have to cast it to any and change it directly
|
||||
agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false });
|
||||
agent.options = Object.assign(agent.options || {}, {
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
}
|
||||
return agent;
|
||||
}
|
||||
@@ -4561,7 +4647,7 @@ class HttpClient {
|
||||
msg = contents;
|
||||
}
|
||||
else {
|
||||
msg = "Failed request: (" + statusCode + ")";
|
||||
msg = 'Failed request: (' + statusCode + ')';
|
||||
}
|
||||
let err = new Error(msg);
|
||||
// attach statusCode and body obj (if available) to the error object
|
||||
@@ -4603,6 +4689,13 @@ module.exports = require("path");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 630:
|
||||
/***/ (function(module) {
|
||||
|
||||
module.exports = require("perf_hooks");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 631:
|
||||
/***/ (function(module) {
|
||||
|
||||
@@ -4883,6 +4976,7 @@ const cp = __webpack_require__(129)
|
||||
const core = __webpack_require__(470)
|
||||
const exec = __webpack_require__(986)
|
||||
const tc = __webpack_require__(533)
|
||||
const common = __webpack_require__(239)
|
||||
const rubyInstallerVersions = __webpack_require__(471).versions
|
||||
|
||||
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
||||
@@ -4908,18 +5002,21 @@ function getAvailableVersions(platform, engine) {
|
||||
}
|
||||
}
|
||||
|
||||
async function install(platform, ruby) {
|
||||
const version = ruby.split('-', 2)[1]
|
||||
async function install(platform, engine, version) {
|
||||
const url = rubyInstallerVersions[version]
|
||||
console.log(url)
|
||||
|
||||
if (!url.endsWith('.7z')) {
|
||||
throw new Error('URL should end in .7z')
|
||||
throw new Error(`URL should end in .7z: ${url}`)
|
||||
}
|
||||
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
|
||||
|
||||
const downloadPath = await tc.downloadTool(url)
|
||||
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
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}`
|
||||
|
||||
let toolchainPaths = (version === 'mswin') ?
|
||||
@@ -4938,7 +5035,8 @@ async function symLinkToEmbeddedMSYS2() {
|
||||
}
|
||||
const latestVersion = toolCacheVersions.slice(-1)[0]
|
||||
const hostedRuby = tc.find('Ruby', latestVersion)
|
||||
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`)
|
||||
await common.measure('Linking MSYS2', async () =>
|
||||
exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`))
|
||||
}
|
||||
|
||||
async function setupMingw(version) {
|
||||
@@ -4946,7 +5044,8 @@ async function setupMingw(version) {
|
||||
|
||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||
core.exportVariable('SSL_CERT_FILE', certFile)
|
||||
await installMSYS(version)
|
||||
await common.measure('Installing MSYS1', async () =>
|
||||
installMSYS(version))
|
||||
|
||||
return msysPathEntries
|
||||
} else {
|
||||
@@ -4993,7 +5092,10 @@ async function setupMSWin() {
|
||||
await symLinkToEmbeddedMSYS2()
|
||||
}
|
||||
|
||||
return [...addVCVARSEnv(), ...msys2PathEntries]
|
||||
const VCPathEntries = await common.measure('Setting up MSVC environment', async () =>
|
||||
addVCVARSEnv())
|
||||
|
||||
return [...VCPathEntries, ...msys2PathEntries]
|
||||
}
|
||||
|
||||
/* Sets MSVC environment for use in Actions
|
||||
@@ -5051,12 +5153,10 @@ function getProxyUrl(reqUrl) {
|
||||
}
|
||||
let proxyVar;
|
||||
if (usingSsl) {
|
||||
proxyVar = process.env["https_proxy"] ||
|
||||
process.env["HTTPS_PROXY"];
|
||||
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||||
}
|
||||
else {
|
||||
proxyVar = process.env["http_proxy"] ||
|
||||
process.env["HTTP_PROXY"];
|
||||
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||
}
|
||||
if (proxyVar) {
|
||||
proxyUrl = url.parse(proxyVar);
|
||||
@@ -5068,7 +5168,7 @@ function checkBypass(reqUrl) {
|
||||
if (!reqUrl.hostname) {
|
||||
return false;
|
||||
}
|
||||
let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || '';
|
||||
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||||
if (!noProxy) {
|
||||
return false;
|
||||
}
|
||||
@@ -5089,7 +5189,10 @@ function checkBypass(reqUrl) {
|
||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||||
}
|
||||
// Compare request host against noproxy
|
||||
for (let upperNoProxyItem of noProxy.split(',').map(x => x.trim().toUpperCase()).filter(x => x)) {
|
||||
for (let upperNoProxyItem of noProxy
|
||||
.split(',')
|
||||
.map(x => x.trim().toUpperCase())
|
||||
.filter(x => x)) {
|
||||
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
||||
return true;
|
||||
}
|
||||
@@ -5192,8 +5295,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tr = __webpack_require__(9);
|
||||
const tr = __importStar(__webpack_require__(9));
|
||||
/**
|
||||
* Exec a command.
|
||||
* Output will be streamed to the live console.
|
||||
|
||||
@@ -3,36 +3,46 @@ const fs = require('fs')
|
||||
const path = require('path')
|
||||
const core = require('@actions/core')
|
||||
const exec = require('@actions/exec')
|
||||
const common = require('./common')
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
const platform = getVirtualEnvironmentName()
|
||||
const [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)
|
||||
await main()
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
process.chdir(core.getInput('working-directory'))
|
||||
|
||||
const platform = common.getVirtualEnvironmentName()
|
||||
const [engine, parsedVersion] = 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 version = validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion)
|
||||
|
||||
createGemRC()
|
||||
|
||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, engine, version)
|
||||
|
||||
setupPath(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) {
|
||||
if (rubyVersion === 'default') {
|
||||
if (fs.existsSync('.ruby-version')) {
|
||||
@@ -68,24 +78,25 @@ function parseRubyEngineAndVersion(rubyVersion) {
|
||||
return [engine, version]
|
||||
}
|
||||
|
||||
function validateRubyEngineAndVersion(platform, engineVersions, engine, version) {
|
||||
function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion) {
|
||||
if (!engineVersions) {
|
||||
throw new Error(`Unknown engine ${engine} on ${platform}`)
|
||||
}
|
||||
|
||||
if (!engineVersions.includes(version)) {
|
||||
let version = parsedVersion
|
||||
if (!engineVersions.includes(parsedVersion)) {
|
||||
const latestToFirstVersion = engineVersions.slice().reverse()
|
||||
const found = latestToFirstVersion.find(v => v !== 'head' && v.startsWith(version))
|
||||
const found = latestToFirstVersion.find(v => v !== 'head' && v.startsWith(parsedVersion))
|
||||
if (found) {
|
||||
version = found
|
||||
} else {
|
||||
throw new Error(`Unknown version ${version} for ${engine} on ${platform}
|
||||
throw new Error(`Unknown version ${parsedVersion} for ${engine} on ${platform}
|
||||
available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}
|
||||
File an issue at https://github.com/ruby/setup-ruby/issues if would like support for a new version`)
|
||||
}
|
||||
}
|
||||
|
||||
return engine + '-' + version
|
||||
return version
|
||||
}
|
||||
|
||||
function createGemRC() {
|
||||
@@ -95,20 +106,22 @@ function createGemRC() {
|
||||
}
|
||||
}
|
||||
|
||||
function setupPath(ruby, newPathEntries) {
|
||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||
function setupPath(newPathEntries) {
|
||||
const originalPath = process.env['PATH'].split(path.delimiter)
|
||||
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
|
||||
|
||||
if (cleanPath.length !== originalPath.length) {
|
||||
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
|
||||
for (const entry of originalPath) {
|
||||
if (!cleanPath.includes(entry)) {
|
||||
console.log(` ${entry}`)
|
||||
}
|
||||
}
|
||||
if (cleanPath.length !== originalPath.length) {
|
||||
core.startGroup('Cleaning PATH')
|
||||
console.log('Entries removed from PATH to avoid conflicts with Ruby:')
|
||||
for (const entry of originalPath) {
|
||||
if (!cleanPath.includes(entry)) {
|
||||
console.log(` ${entry}`)
|
||||
}
|
||||
}
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
}
|
||||
|
||||
function readBundledWithFromGemfileLock() {
|
||||
@@ -131,9 +144,6 @@ function readBundledWithFromGemfileLock() {
|
||||
|
||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = core.getInput('bundler')
|
||||
if (bundlerVersion === 'none') {
|
||||
return
|
||||
}
|
||||
|
||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||
bundlerVersion = readBundledWithFromGemfileLock()
|
||||
@@ -155,10 +165,10 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
}
|
||||
|
||||
if (engine === 'ruby' && isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
||||
console.log(`Using the Bundler version shipped with ${engine}-${rubyVersion}`)
|
||||
if (engine === 'ruby' && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
||||
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
|
||||
} else if (engine === 'truffleruby' && bundlerVersion === '1') {
|
||||
console.log(`Using the Bundler version shipped with ${engine}`)
|
||||
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 {
|
||||
@@ -167,31 +177,4 @@ async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
}
|
||||
}
|
||||
|
||||
function isHeadVersion(rubyVersion) {
|
||||
return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
|
||||
}
|
||||
|
||||
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')
|
||||
}
|
||||
}
|
||||
|
||||
if (__filename.endsWith('index.js')) { run() }
|
||||
|
||||
@@ -7,7 +7,7 @@ export function getVersions(platform) {
|
||||
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8",
|
||||
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
|
||||
"2.7.0", "2.7.1",
|
||||
"head"
|
||||
"head", "debug",
|
||||
],
|
||||
"jruby": [
|
||||
"9.1.17.0",
|
||||
|
||||
+19
-16
@@ -3,6 +3,7 @@ const path = require('path')
|
||||
const exec = require('@actions/exec')
|
||||
const io = require('@actions/io')
|
||||
const tc = require('@actions/tool-cache')
|
||||
const common = require('./common')
|
||||
const rubyBuilderVersions = require('./ruby-builder-versions')
|
||||
|
||||
const builderReleaseTag = 'enable-shared'
|
||||
@@ -12,10 +13,10 @@ export function getAvailableVersions(platform, engine) {
|
||||
return rubyBuilderVersions.getVersions(platform)[engine]
|
||||
}
|
||||
|
||||
export async function install(platform, ruby) {
|
||||
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||
export async function install(platform, engine, version) {
|
||||
const rubyPrefix = await downloadAndExtract(platform, engine, version)
|
||||
let newPathEntries
|
||||
if (ruby.startsWith('rubinius')) {
|
||||
if (engine === 'rubinius') {
|
||||
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
|
||||
} else {
|
||||
newPathEntries = [path.join(rubyPrefix, 'bin')]
|
||||
@@ -23,29 +24,31 @@ export async function install(platform, ruby) {
|
||||
return [rubyPrefix, newPathEntries]
|
||||
}
|
||||
|
||||
async function downloadAndExtract(platform, ruby) {
|
||||
async function downloadAndExtract(platform, engine, version) {
|
||||
const rubiesDir = path.join(os.homedir(), '.rubies')
|
||||
await io.mkdirP(rubiesDir)
|
||||
|
||||
const url = await getDownloadURL(platform, ruby)
|
||||
console.log(url)
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
const url = getDownloadURL(platform, engine, version)
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
})
|
||||
|
||||
const downloadPath = await tc.downloadTool(url)
|
||||
const tar = platform.startsWith('windows') ? 'C:\\Windows\\system32\\tar.exe' : 'tar'
|
||||
await exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ])
|
||||
await common.measure('Extracting Ruby', async () =>
|
||||
exec.exec(tar, [ '-xz', '-C', rubiesDir, '-f', downloadPath ]))
|
||||
|
||||
return path.join(rubiesDir, ruby)
|
||||
return path.join(rubiesDir, `${engine}-${version}`)
|
||||
}
|
||||
|
||||
function getDownloadURL(platform, ruby) {
|
||||
if (ruby.endsWith('-head')) {
|
||||
return getLatestHeadBuildURL(platform, ruby)
|
||||
function getDownloadURL(platform, engine, version) {
|
||||
if (common.isHeadVersion(version)) {
|
||||
return getLatestHeadBuildURL(platform, engine, version)
|
||||
} else {
|
||||
return `${releasesURL}/download/${builderReleaseTag}/${ruby}-${platform}.tar.gz`
|
||||
return `${releasesURL}/download/${builderReleaseTag}/${engine}-${version}-${platform}.tar.gz`
|
||||
}
|
||||
}
|
||||
|
||||
function getLatestHeadBuildURL(platform, ruby) {
|
||||
const engine = ruby.split('-')[0]
|
||||
return `https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-head-${platform}.tar.gz`
|
||||
function getLatestHeadBuildURL(platform, engine, version) {
|
||||
return `https://github.com/ruby/${engine}-dev-builder/releases/latest/download/${engine}-${version}-${platform}.tar.gz`
|
||||
}
|
||||
|
||||
+18
-9
@@ -7,6 +7,7 @@ const cp = require('child_process')
|
||||
const core = require('@actions/core')
|
||||
const exec = require('@actions/exec')
|
||||
const tc = require('@actions/tool-cache')
|
||||
const common = require('./common')
|
||||
const rubyInstallerVersions = require('./windows-versions').versions
|
||||
|
||||
// Extract to SSD, see https://github.com/ruby/setup-ruby/pull/14
|
||||
@@ -32,18 +33,21 @@ export function getAvailableVersions(platform, engine) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function install(platform, ruby) {
|
||||
const version = ruby.split('-', 2)[1]
|
||||
export async function install(platform, engine, version) {
|
||||
const url = rubyInstallerVersions[version]
|
||||
console.log(url)
|
||||
|
||||
if (!url.endsWith('.7z')) {
|
||||
throw new Error('URL should end in .7z')
|
||||
throw new Error(`URL should end in .7z: ${url}`)
|
||||
}
|
||||
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
|
||||
|
||||
const downloadPath = await tc.downloadTool(url)
|
||||
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
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}`
|
||||
|
||||
let toolchainPaths = (version === 'mswin') ?
|
||||
@@ -62,7 +66,8 @@ async function symLinkToEmbeddedMSYS2() {
|
||||
}
|
||||
const latestVersion = toolCacheVersions.slice(-1)[0]
|
||||
const hostedRuby = tc.find('Ruby', latestVersion)
|
||||
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`)
|
||||
await common.measure('Linking MSYS2', async () =>
|
||||
exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`))
|
||||
}
|
||||
|
||||
async function setupMingw(version) {
|
||||
@@ -70,7 +75,8 @@ async function setupMingw(version) {
|
||||
|
||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||
core.exportVariable('SSL_CERT_FILE', certFile)
|
||||
await installMSYS(version)
|
||||
await common.measure('Installing MSYS1', async () =>
|
||||
installMSYS(version))
|
||||
|
||||
return msysPathEntries
|
||||
} else {
|
||||
@@ -117,7 +123,10 @@ async function setupMSWin() {
|
||||
await symLinkToEmbeddedMSYS2()
|
||||
}
|
||||
|
||||
return [...addVCVARSEnv(), ...msys2PathEntries]
|
||||
const VCPathEntries = await common.measure('Setting up MSVC environment', async () =>
|
||||
addVCVARSEnv())
|
||||
|
||||
return [...VCPathEntries, ...msys2PathEntries]
|
||||
}
|
||||
|
||||
/* Sets MSVC environment for use in Actions
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
integrity sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w==
|
||||
|
||||
"@actions/exec@^1.0.0", "@actions/exec@^1.0.3":
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.0.3.tgz#b967f8700d6ff011dcc91243b58bafc1bb9ab95f"
|
||||
integrity sha512-TogJGnueOmM7ntCi0ASTUj4LapRRtDfj57Ja4IhPmg2fls28uVOPbAn8N+JifaOumN2UG3oEO/Ixek2A4NcYSA==
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.0.4.tgz#99d75310e62e59fc37d2ee6dcff6d4bffadd3a5d"
|
||||
integrity sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==
|
||||
dependencies:
|
||||
"@actions/io" "^1.0.1"
|
||||
|
||||
"@actions/http-client@^1.0.3":
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.6.tgz#6f9267ca50e1d74d8581f4a894a943cd4c97b49a"
|
||||
integrity sha512-LGmio4w98UyGX33b/W6V6Nx/sQHRXZ859YlMkn36wPsXPB82u8xTVlA/Dq2DXrm6lEq9RVmisRJa1c+HETAIJA==
|
||||
"@actions/http-client@^1.0.8":
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.8.tgz#8bd76e8eca89dc8bcf619aa128eba85f7a39af45"
|
||||
integrity sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==
|
||||
dependencies:
|
||||
tunnel "0.0.6"
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
integrity sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg==
|
||||
|
||||
"@actions/tool-cache@^1.3.1":
|
||||
version "1.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@actions/tool-cache/-/tool-cache-1.3.3.tgz#34cf87a0436a2178207a644932114a236194b0fd"
|
||||
integrity sha512-AFVyTLcIxusDVI1gMhbZW8m/On7YNJG+xYaxorV+qic+f7lO7h37aT2mfzxqAq7mwHxtP1YlVFNrXe9QDf/bPg==
|
||||
version "1.3.4"
|
||||
resolved "https://registry.yarnpkg.com/@actions/tool-cache/-/tool-cache-1.3.4.tgz#2d2e3d109696edc7c12b0bd47ab6f66446428246"
|
||||
integrity sha512-1Pfz4vDbKzqsWOi5CdNl377cwBNfsNrV3Wy8i94mw+49T+6JVqAH3gtFj/Woe93zyvlvzqM0rmQlPh5+jvKLag==
|
||||
dependencies:
|
||||
"@actions/core" "^1.2.0"
|
||||
"@actions/exec" "^1.0.0"
|
||||
"@actions/http-client" "^1.0.3"
|
||||
"@actions/http-client" "^1.0.8"
|
||||
"@actions/io" "^1.0.1"
|
||||
semver "^6.1.0"
|
||||
uuid "^3.3.2"
|
||||
|
||||
Reference in New Issue
Block a user