Read from .ruby-version if version is unset or set to '.ruby-version'

* Fixes https://github.com/eregon/use-ruby-action/issues/4
This commit is contained in:
Benoit Daloze
2020-01-06 22:00:45 +01:00
parent b339f321d1
commit a61be15bff
6 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ jobs:
matrix:
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
# Use various version syntaxes here for testing
ruby: [ 2.3, ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, jruby, truffleruby ]
ruby: [ .ruby-version, 2.3, ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, jruby, truffleruby ]
exclude:
- os: windows-latest
ruby: 2.3
+1
View File
@@ -0,0 +1 @@
ruby-2.6.5
+3
View File
@@ -53,6 +53,8 @@ jobs:
- run: ruby -v
```
You can leave `ruby-version` unset to use the project's `.ruby-version` file.
### Matrix
This matrix tests all stable releases of MRI, JRuby and TruffleRuby on Ubuntu and macOS.
@@ -82,6 +84,7 @@ jobs:
* short version like `2.6`, automatically using the latest release matching that version (`2.6.5`)
* version only like `2.6.5`, assumes MRI for the engine
* engine only like `truffleruby`, uses the latest stable release of that implementation
* `.ruby-version` reads from the project's `.ruby-version` file
### Bundler
+2 -2
View File
@@ -6,8 +6,8 @@ branding:
icon: download
inputs:
ruby-version:
description: 'Engine and version to use, see the syntax in the README'
required: true
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version if unset.'
default: '.ruby-version'
outputs:
ruby-prefix:
description: 'The prefix of the installed ruby'
Generated Vendored
+5
View File
@@ -1428,6 +1428,11 @@ async function getLatestReleaseTag() {
}
async function getRubyEngineAndVersion(rubyVersion) {
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
}
let engine, version
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
engine = 'ruby'
+5
View File
@@ -47,6 +47,11 @@ async function getLatestReleaseTag() {
}
async function getRubyEngineAndVersion(rubyVersion) {
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
}
let engine, version
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
engine = 'ruby'