Skip to content

Commit a61be15

Browse files
committed
Read from .ruby-version if version is unset or set to '.ruby-version'
* Fixes #4
1 parent b339f32 commit a61be15

File tree

6 files changed

+17
-3
lines changed

6 files changed

+17
-3
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
matrix:
88
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
99
# Use various version syntaxes here for testing
10-
ruby: [ 2.3, ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, jruby, truffleruby ]
10+
ruby: [ .ruby-version, 2.3, ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, jruby, truffleruby ]
1111
exclude:
1212
- os: windows-latest
1313
ruby: 2.3

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby-2.6.5

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ jobs:
5353
- run: ruby -v
5454
```
5555
56+
You can leave `ruby-version` unset to use the project's `.ruby-version` file.
57+
5658
### Matrix
5759

5860
This matrix tests all stable releases of MRI, JRuby and TruffleRuby on Ubuntu and macOS.
@@ -82,6 +84,7 @@ jobs:
8284
* short version like `2.6`, automatically using the latest release matching that version (`2.6.5`)
8385
* version only like `2.6.5`, assumes MRI for the engine
8486
* engine only like `truffleruby`, uses the latest stable release of that implementation
87+
* `.ruby-version` reads from the project's `.ruby-version` file
8588

8689
### Bundler
8790

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ branding:
66
icon: download
77
inputs:
88
ruby-version:
9-
description: 'Engine and version to use, see the syntax in the README'
10-
required: true
9+
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version if unset.'
10+
default: '.ruby-version'
1111
outputs:
1212
ruby-prefix:
1313
description: 'The prefix of the installed ruby'

dist/index.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ async function getLatestReleaseTag() {
4747
}
4848

4949
async function getRubyEngineAndVersion(rubyVersion) {
50+
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
51+
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
52+
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
53+
}
54+
5055
let engine, version
5156
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
5257
engine = 'ruby'

0 commit comments

Comments
 (0)