mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f964e8aa48 | ||
|
|
e16528e678 | ||
|
|
11238a2c00 | ||
|
|
1e2e6e19e3 | ||
|
|
a1c5b2a66c | ||
|
|
e648fd85b4 |
@@ -14,9 +14,9 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
|
||||
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
||||
# Use various version syntaxes here for testing
|
||||
ruby: [ 2.2, 2.3, .ruby-version, .tool-versions, ruby-head, jruby-9.1, jruby, jruby-head, truffleruby, truffleruby-head ]
|
||||
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 ]
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
ruby: truffleruby
|
||||
|
||||
@@ -17,7 +17,7 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
|
||||
|
||||
| Interpreter | Versions |
|
||||
| ----------- | -------- |
|
||||
| Ruby | 2.2, 2.3.0 - 2.3.8, 2.4.0 - 2.4.9, 2.5.0 - 2.5.7, 2.6.0 - 2.6.5, 2.7.0, head, mingw, mswin |
|
||||
| Ruby | 2.2, 2.3.0 - 2.3.8, 2.4.0 - 2.4.10, 2.5.0 - 2.5.8, 2.6.0 - 2.6.6, 2.7.1, head, mingw, mswin |
|
||||
| JRuby | 9.1.17.0, 9.2.9.0 - 9.2.11.1, head |
|
||||
| TruffleRuby | 19.3.0 - 20.0.0, head |
|
||||
| Rubinius | 4.14 |
|
||||
@@ -105,9 +105,11 @@ jobs:
|
||||
|
||||
### Bundler
|
||||
|
||||
Currently, Bundler is guaranteed to be installed for all versions.
|
||||
If the Ruby ships with Bundler (Ruby >= 2.6), that version is used.
|
||||
Otherwise (Ruby < 2.6), Bundler 1 is installed when that Ruby was built.
|
||||
By default, if there is a `Gemfile.lock` file with a `BUNDLED WITH` section,
|
||||
the latest version of Bundler with the same major version will be installed.
|
||||
Otherwise, the latest Bundler version is installed (except for Ruby 2.2 where only Bundler 1 is supported).
|
||||
|
||||
This behavior can be customized, see [action.yml](action.yml) for details about the `bundler` input.
|
||||
|
||||
### Caching `bundle install`
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ inputs:
|
||||
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version if unset.'
|
||||
required: false
|
||||
default: 'default'
|
||||
bundler:
|
||||
description: 'The version of Bundler to install. Either none, 1, 2, latest or Gemfile.lock. The default tries Gemfile.lock and otherwise uses latest.'
|
||||
required: false
|
||||
default: 'default'
|
||||
outputs:
|
||||
ruby-prefix:
|
||||
description: 'The prefix of the installed ruby'
|
||||
|
||||
+65
-10
@@ -960,6 +960,7 @@ const os = __webpack_require__(87)
|
||||
const fs = __webpack_require__(747)
|
||||
const path = __webpack_require__(622)
|
||||
const core = __webpack_require__(470)
|
||||
const exec = __webpack_require__(986)
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
@@ -981,6 +982,9 @@ async function run() {
|
||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
||||
|
||||
setupPath(ruby, newPathEntries)
|
||||
|
||||
await installBundler(platform, rubyPrefix, engine, version)
|
||||
|
||||
core.setOutput('ruby-prefix', rubyPrefix)
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
@@ -1065,6 +1069,58 @@ function setupPath(ruby, newPathEntries) {
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
}
|
||||
|
||||
function readBundledWithFromGemfileLock() {
|
||||
if (fs.existsSync('Gemfile.lock')) {
|
||||
const contents = fs.readFileSync('Gemfile.lock', 'utf8')
|
||||
const lines = contents.split(/\r?\n/)
|
||||
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
||||
if (bundledWithLine !== -1) {
|
||||
const nextLine = lines[bundledWithLine+1]
|
||||
if (nextLine && /^\d+/.test(nextLine.trim())) {
|
||||
const bundlerVersion = nextLine.trim()
|
||||
const majorVersion = bundlerVersion.match(/^\d+/)[0]
|
||||
console.log(`Using Bundler ${majorVersion} from Gemfile.lock BUNDLED WITH ${bundlerVersion}`)
|
||||
return majorVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = core.getInput('bundler')
|
||||
if (bundlerVersion === 'none') {
|
||||
return
|
||||
}
|
||||
|
||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||
bundlerVersion = readBundledWithFromGemfileLock()
|
||||
if (!bundlerVersion) {
|
||||
bundlerVersion = 'latest'
|
||||
}
|
||||
}
|
||||
|
||||
let versionArray
|
||||
if (rubyVersion.startsWith('2.2')) {
|
||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
||||
versionArray = ['-v', '~> 1']
|
||||
} else if (/^\d+/.test(bundlerVersion)) {
|
||||
versionArray = ['-v', `~> ${bundlerVersion}`]
|
||||
} else if (bundlerVersion === 'latest') {
|
||||
versionArray = []
|
||||
} else {
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
}
|
||||
|
||||
if (engine === 'rubinius') {
|
||||
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 {
|
||||
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', ...versionArray, '--no-document'])
|
||||
}
|
||||
}
|
||||
|
||||
function getVirtualEnvironmentName() {
|
||||
const platform = os.platform()
|
||||
if (platform === 'linux') {
|
||||
@@ -1398,10 +1454,10 @@ function getVersions(platform) {
|
||||
"ruby": [
|
||||
"2.2.10",
|
||||
"2.3.0", "2.3.1", "2.3.2", "2.3.3", "2.3.4", "2.3.5", "2.3.6", "2.3.7", "2.3.8",
|
||||
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9",
|
||||
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7",
|
||||
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5",
|
||||
"2.7.0",
|
||||
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9", "2.4.10",
|
||||
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8",
|
||||
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
|
||||
"2.7.0", "2.7.1",
|
||||
"head"
|
||||
],
|
||||
"jruby": [
|
||||
@@ -3415,7 +3471,7 @@ const io = __webpack_require__(1)
|
||||
const tc = __webpack_require__(533)
|
||||
const rubyBuilderVersions = __webpack_require__(156)
|
||||
|
||||
const builderReleaseTag = 'builds-no-warn'
|
||||
const builderReleaseTag = 'enable-shared'
|
||||
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
|
||||
|
||||
function getAvailableVersions(platform, engine) {
|
||||
@@ -4858,11 +4914,6 @@ async function install(platform, ruby) {
|
||||
await setupMSWin() : await setupMingw(version)
|
||||
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
|
||||
|
||||
// Install Bundler if needed
|
||||
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
|
||||
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
|
||||
}
|
||||
|
||||
return [rubyPrefix, newPathEntries]
|
||||
}
|
||||
|
||||
@@ -4879,6 +4930,8 @@ async function symLinkToEmbeddedMSYS2() {
|
||||
}
|
||||
|
||||
async function setupMingw(version) {
|
||||
core.exportVariable('MAKE', 'make.exe')
|
||||
|
||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||
core.exportVariable('SSL_CERT_FILE', certFile)
|
||||
await installMSYS(version)
|
||||
@@ -4909,6 +4962,8 @@ async function installMSYS(version) {
|
||||
}
|
||||
|
||||
async function setupMSWin() {
|
||||
core.exportVariable('MAKE', 'nmake.exe')
|
||||
|
||||
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
|
||||
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
|
||||
if (!fs.existsSync(certsDir)) {
|
||||
|
||||
@@ -2,6 +2,7 @@ const os = require('os')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const core = require('@actions/core')
|
||||
const exec = require('@actions/exec')
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
@@ -23,6 +24,9 @@ export async function run() {
|
||||
const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)
|
||||
|
||||
setupPath(ruby, newPathEntries)
|
||||
|
||||
await installBundler(platform, rubyPrefix, engine, version)
|
||||
|
||||
core.setOutput('ruby-prefix', rubyPrefix)
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
@@ -107,6 +111,58 @@ function setupPath(ruby, newPathEntries) {
|
||||
core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter))
|
||||
}
|
||||
|
||||
function readBundledWithFromGemfileLock() {
|
||||
if (fs.existsSync('Gemfile.lock')) {
|
||||
const contents = fs.readFileSync('Gemfile.lock', 'utf8')
|
||||
const lines = contents.split(/\r?\n/)
|
||||
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
||||
if (bundledWithLine !== -1) {
|
||||
const nextLine = lines[bundledWithLine+1]
|
||||
if (nextLine && /^\d+/.test(nextLine.trim())) {
|
||||
const bundlerVersion = nextLine.trim()
|
||||
const majorVersion = bundlerVersion.match(/^\d+/)[0]
|
||||
console.log(`Using Bundler ${majorVersion} from Gemfile.lock BUNDLED WITH ${bundlerVersion}`)
|
||||
return majorVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
async function installBundler(platform, rubyPrefix, engine, rubyVersion) {
|
||||
var bundlerVersion = core.getInput('bundler')
|
||||
if (bundlerVersion === 'none') {
|
||||
return
|
||||
}
|
||||
|
||||
if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') {
|
||||
bundlerVersion = readBundledWithFromGemfileLock()
|
||||
if (!bundlerVersion) {
|
||||
bundlerVersion = 'latest'
|
||||
}
|
||||
}
|
||||
|
||||
let versionArray
|
||||
if (rubyVersion.startsWith('2.2')) {
|
||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby 2.2')
|
||||
versionArray = ['-v', '~> 1']
|
||||
} else if (/^\d+/.test(bundlerVersion)) {
|
||||
versionArray = ['-v', `~> ${bundlerVersion}`]
|
||||
} else if (bundlerVersion === 'latest') {
|
||||
versionArray = []
|
||||
} else {
|
||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||
}
|
||||
|
||||
if (engine === 'rubinius') {
|
||||
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 {
|
||||
await exec.exec(path.join(rubyPrefix, 'bin', 'gem'), ['install', 'bundler', ...versionArray, '--no-document'])
|
||||
}
|
||||
}
|
||||
|
||||
function getVirtualEnvironmentName() {
|
||||
const platform = os.platform()
|
||||
if (platform === 'linux') {
|
||||
|
||||
@@ -3,10 +3,10 @@ export function getVersions(platform) {
|
||||
"ruby": [
|
||||
"2.2.10",
|
||||
"2.3.0", "2.3.1", "2.3.2", "2.3.3", "2.3.4", "2.3.5", "2.3.6", "2.3.7", "2.3.8",
|
||||
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9",
|
||||
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7",
|
||||
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5",
|
||||
"2.7.0",
|
||||
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9", "2.4.10",
|
||||
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7", "2.5.8",
|
||||
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5", "2.6.6",
|
||||
"2.7.0", "2.7.1",
|
||||
"head"
|
||||
],
|
||||
"jruby": [
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ const io = require('@actions/io')
|
||||
const tc = require('@actions/tool-cache')
|
||||
const rubyBuilderVersions = require('./ruby-builder-versions')
|
||||
|
||||
const builderReleaseTag = 'builds-no-warn'
|
||||
const builderReleaseTag = 'enable-shared'
|
||||
const releasesURL = 'https://github.com/ruby/ruby-builder/releases'
|
||||
|
||||
export function getAvailableVersions(platform, engine) {
|
||||
|
||||
+4
-5
@@ -50,11 +50,6 @@ export async function install(platform, ruby) {
|
||||
await setupMSWin() : await setupMingw(version)
|
||||
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
|
||||
|
||||
// Install Bundler if needed
|
||||
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
|
||||
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
|
||||
}
|
||||
|
||||
return [rubyPrefix, newPathEntries]
|
||||
}
|
||||
|
||||
@@ -71,6 +66,8 @@ async function symLinkToEmbeddedMSYS2() {
|
||||
}
|
||||
|
||||
async function setupMingw(version) {
|
||||
core.exportVariable('MAKE', 'make.exe')
|
||||
|
||||
if (version.startsWith('2.2') || version.startsWith('2.3')) {
|
||||
core.exportVariable('SSL_CERT_FILE', certFile)
|
||||
await installMSYS(version)
|
||||
@@ -101,6 +98,8 @@ async function installMSYS(version) {
|
||||
}
|
||||
|
||||
async function setupMSWin() {
|
||||
core.exportVariable('MAKE', 'nmake.exe')
|
||||
|
||||
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
|
||||
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
|
||||
if (!fs.existsSync(certsDir)) {
|
||||
|
||||
Reference in New Issue
Block a user