Compare commits

...
8 Commits
7 changed files with 53 additions and 39 deletions
+4
View File
@@ -19,3 +19,7 @@ It is recommended to add this as a `git` `pre-commit` hook:
```bash ```bash
$ cp pre-commit .git/hooks/pre-commit $ cp pre-commit .git/hooks/pre-commit
``` ```
## Adding a new Ruby version
Add the new version in `ruby-builder-versions.js` and update the README.
+3 -3
View File
@@ -15,9 +15,9 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
| Interpreter | Versions | | Interpreter | Versions |
| ----------- | -------- | | ----------- | -------- |
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.0.2, head, debug, mingw, mswin | | `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 3.0.2, head, debug, mingw, mswin |
| `jruby` | 9.1.17.0, 9.2.9.0 - 9.2.19.0, head | | `jruby` | 9.1.17.0 - 9.3.1.0, head |
| `truffleruby` | 19.3.0 - 21.2.0.1, head | | `truffleruby` | 19.3.0 - 21.3.0, head |
| `truffleruby+graalvm` | 21.2.0, head | | `truffleruby+graalvm` | 21.2.0 - 21.3.0, head |
`ruby-debug` is the same as `ruby-head` but with assertions enabled (`-DRUBY_DEBUG=1`). `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. On Windows, `mingw` and `mswin` are `ruby-head` builds using the MSYS2/MinGW and the MSVC toolchains respectively.
+16 -12
View File
@@ -74,7 +74,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
if (engine === 'ruby' && common.floatVersion(rubyVersion) <= 2.2) { if (engine === 'ruby' && common.floatVersion(rubyVersion) <= 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')
bundlerVersion = '1' bundlerVersion = '1'
} else if (engine === 'ruby' && rubyVersion.match(/^2\.3\.[01]/)) { } else if (engine === 'ruby' && /^2\.3\.[01]/.test(rubyVersion)) {
console.log('Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1') console.log('Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1')
bundlerVersion = '1' bundlerVersion = '1'
} else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same } else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same
@@ -90,7 +90,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`) console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`)
} else { } else {
const gem = path.join(rubyPrefix, 'bin', 'gem') const gem = path.join(rubyPrefix, 'bin', 'gem')
const bundlerVersionConstraint = bundlerVersion.match(/^\d+\.\d+\.\d+/) ? bundlerVersion : `~> ${bundlerVersion}` const bundlerVersionConstraint = /^\d+\.\d+\.\d+/.test(bundlerVersion) ? bundlerVersion : `~> ${bundlerVersion}`
await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint]) await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint])
} }
@@ -183,17 +183,21 @@ async function computeBaseKey(platform, engine, version, lockFile, cacheVersion)
const cacheVersionSuffix = DEFAULT_CACHE_VERSION === cacheVersion ? '' : `-cachever:${cacheVersion}` const cacheVersionSuffix = DEFAULT_CACHE_VERSION === cacheVersion ? '' : `-cachever:${cacheVersion}`
let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}${cacheVersionSuffix}` let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}${cacheVersionSuffix}`
if (engine !== 'jruby' && common.isHeadVersion(version)) { if (common.isHeadVersion(version)) {
let revision = ''; if (engine !== 'jruby') {
await exec.exec('ruby', ['-e', 'print RUBY_REVISION'], { // CRuby dev versions do not change the ABI version when the ABI changes, so use the commit as the ABI version
silent: true, let print_abi = engine === 'ruby' ? 'print RUBY_REVISION' : "print RbConfig::CONFIG['ruby_version']"
listeners: { let abi = ''
stdout: (data) => { await exec.exec('ruby', ['-e', print_abi], {
revision += data.toString(); silent: true,
listeners: {
stdout: (data) => {
abi += data.toString();
}
} }
} });
}); key += `-ABI-${abi}`
key += `-revision-${revision}` }
} }
key += `-${lockFile}` key += `-${lockFile}`
Generated Vendored
+23 -18
View File
@@ -88,7 +88,7 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
if (engine === 'ruby' && common.floatVersion(rubyVersion) <= 2.2) { if (engine === 'ruby' && common.floatVersion(rubyVersion) <= 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')
bundlerVersion = '1' bundlerVersion = '1'
} else if (engine === 'ruby' && rubyVersion.match(/^2\.3\.[01]/)) { } else if (engine === 'ruby' && /^2\.3\.[01]/.test(rubyVersion)) {
console.log('Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1') console.log('Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1')
bundlerVersion = '1' bundlerVersion = '1'
} else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same } else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same
@@ -104,7 +104,7 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`) console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`)
} else { } else {
const gem = path.join(rubyPrefix, 'bin', 'gem') const gem = path.join(rubyPrefix, 'bin', 'gem')
const bundlerVersionConstraint = bundlerVersion.match(/^\d+\.\d+\.\d+/) ? bundlerVersion : `~> ${bundlerVersion}` const bundlerVersionConstraint = /^\d+\.\d+\.\d+/.test(bundlerVersion) ? bundlerVersion : `~> ${bundlerVersion}`
await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint]) await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint])
} }
@@ -197,17 +197,21 @@ async function computeBaseKey(platform, engine, version, lockFile, cacheVersion)
const cacheVersionSuffix = DEFAULT_CACHE_VERSION === cacheVersion ? '' : `-cachever:${cacheVersion}` const cacheVersionSuffix = DEFAULT_CACHE_VERSION === cacheVersion ? '' : `-cachever:${cacheVersion}`
let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}${cacheVersionSuffix}` let key = `setup-ruby-bundler-cache-v3-${platform}-${engine}-${version}${cacheVersionSuffix}`
if (engine !== 'jruby' && common.isHeadVersion(version)) { if (common.isHeadVersion(version)) {
let revision = ''; if (engine !== 'jruby') {
await exec.exec('ruby', ['-e', 'print RUBY_REVISION'], { // CRuby dev versions do not change the ABI version when the ABI changes, so use the commit as the ABI version
silent: true, let print_abi = engine === 'ruby' ? 'print RUBY_REVISION' : "print RbConfig::CONFIG['ruby_version']"
listeners: { let abi = ''
stdout: (data) => { await exec.exec('ruby', ['-e', print_abi], {
revision += data.toString(); silent: true,
listeners: {
stdout: (data) => {
abi += data.toString();
}
} }
} });
}); key += `-ABI-${abi}`
key += `-revision-${revision}` }
} }
key += `-${lockFile}` key += `-${lockFile}`
@@ -58777,17 +58781,18 @@ function getVersions(platform) {
], ],
"jruby": [ "jruby": [
"9.1.17.0", "9.1.17.0",
"9.2.9.0", "9.2.10.0", "9.2.11.0", "9.2.11.1", "9.2.12.0", "9.2.13.0", "9.2.14.0", "9.2.15.0", "9.2.16.0", "9.2.17.0", "9.2.18.0", "9.2.19.0", "9.2.9.0", "9.2.10.0", "9.2.11.0", "9.2.11.1", "9.2.12.0", "9.2.13.0", "9.2.14.0", "9.2.15.0", "9.2.16.0", "9.2.17.0", "9.2.18.0", "9.2.19.0", "9.2.20.0",
"9.3.0.0", "9.3.1.0",
"head" "head"
], ],
"truffleruby": [ "truffleruby": [
"19.3.0", "19.3.1", "19.3.0", "19.3.1",
"20.0.0", "20.1.0", "20.2.0", "20.3.0", "20.0.0", "20.1.0", "20.2.0", "20.3.0",
"21.0.0", "21.1.0", "21.2.0", "21.2.0.1", "21.0.0", "21.1.0", "21.2.0", "21.2.0.1", "21.3.0",
"head" "head"
], ],
"truffleruby+graalvm": [ "truffleruby+graalvm": [
"21.2.0", "21.2.0", "21.3.0",
"head" "head"
] ]
} }
@@ -59126,7 +59131,7 @@ function addVCVARSEnv() {
let newEnv = new Map() let newEnv = new Map()
let cmd = `cmd.exe /c "${vcVars} && set"` let cmd = `cmd.exe /c "${vcVars} && set"`
let newSet = cp.execSync(cmd).toString().trim().split(/\r?\n/) let newSet = cp.execSync(cmd).toString().trim().split(/\r?\n/)
newSet = newSet.filter(line => line.match(/\S=\S/)) newSet = newSet.filter(line => /\S=\S/.test(line))
newSet.forEach(s => { newSet.forEach(s => {
let [k,v] = common.partition(s, '=') let [k,v] = common.partition(s, '=')
newEnv.set(k,v) newEnv.set(k,v)
@@ -59499,13 +59504,13 @@ function parseRubyEngineAndVersion(rubyVersion) {
console.log(`Using ${rubyVersion} as input from file .ruby-version`) console.log(`Using ${rubyVersion} as input from file .ruby-version`)
} else if (rubyVersion === '.tool-versions') { // Read from .tool-versions } else if (rubyVersion === '.tool-versions') { // Read from .tool-versions
const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim() const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim()
const rubyLine = toolVersions.split(/\r?\n/).filter(e => e.match(/^ruby\s/))[0] const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s/.test(e))[0]
rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1] rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1]
console.log(`Using ${rubyVersion} as input from file .tool-versions`) console.log(`Using ${rubyVersion} as input from file .tool-versions`)
} }
let engine, version let engine, version
if (rubyVersion.match(/^(\d+)/) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z if (/^(\d+)/.test(rubyVersion) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z
engine = 'ruby' engine = 'ruby'
version = rubyVersion version = rubyVersion
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion } else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
+2 -2
View File
@@ -91,13 +91,13 @@ function parseRubyEngineAndVersion(rubyVersion) {
console.log(`Using ${rubyVersion} as input from file .ruby-version`) console.log(`Using ${rubyVersion} as input from file .ruby-version`)
} else if (rubyVersion === '.tool-versions') { // Read from .tool-versions } else if (rubyVersion === '.tool-versions') { // Read from .tool-versions
const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim() const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim()
const rubyLine = toolVersions.split(/\r?\n/).filter(e => e.match(/^ruby\s/))[0] const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s/.test(e))[0]
rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1] rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1]
console.log(`Using ${rubyVersion} as input from file .tool-versions`) console.log(`Using ${rubyVersion} as input from file .tool-versions`)
} }
let engine, version let engine, version
if (rubyVersion.match(/^(\d+)/) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z if (/^(\d+)/.test(rubyVersion) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z
engine = 'ruby' engine = 'ruby'
version = rubyVersion version = rubyVersion
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion } else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
+4 -3
View File
@@ -15,17 +15,18 @@ export function getVersions(platform) {
], ],
"jruby": [ "jruby": [
"9.1.17.0", "9.1.17.0",
"9.2.9.0", "9.2.10.0", "9.2.11.0", "9.2.11.1", "9.2.12.0", "9.2.13.0", "9.2.14.0", "9.2.15.0", "9.2.16.0", "9.2.17.0", "9.2.18.0", "9.2.19.0", "9.2.9.0", "9.2.10.0", "9.2.11.0", "9.2.11.1", "9.2.12.0", "9.2.13.0", "9.2.14.0", "9.2.15.0", "9.2.16.0", "9.2.17.0", "9.2.18.0", "9.2.19.0", "9.2.20.0",
"9.3.0.0", "9.3.1.0",
"head" "head"
], ],
"truffleruby": [ "truffleruby": [
"19.3.0", "19.3.1", "19.3.0", "19.3.1",
"20.0.0", "20.1.0", "20.2.0", "20.3.0", "20.0.0", "20.1.0", "20.2.0", "20.3.0",
"21.0.0", "21.1.0", "21.2.0", "21.2.0.1", "21.0.0", "21.1.0", "21.2.0", "21.2.0.1", "21.3.0",
"head" "head"
], ],
"truffleruby+graalvm": [ "truffleruby+graalvm": [
"21.2.0", "21.2.0", "21.3.0",
"head" "head"
] ]
} }
+1 -1
View File
@@ -134,7 +134,7 @@ export function addVCVARSEnv() {
let newEnv = new Map() let newEnv = new Map()
let cmd = `cmd.exe /c "${vcVars} && set"` let cmd = `cmd.exe /c "${vcVars} && set"`
let newSet = cp.execSync(cmd).toString().trim().split(/\r?\n/) let newSet = cp.execSync(cmd).toString().trim().split(/\r?\n/)
newSet = newSet.filter(line => line.match(/\S=\S/)) newSet = newSet.filter(line => /\S=\S/.test(line))
newSet.forEach(s => { newSet.forEach(s => {
let [k,v] = common.partition(s, '=') let [k,v] = common.partition(s, '=')
newEnv.set(k,v) newEnv.set(k,v)