diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1092caa..8351877 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..d7edb56 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-2.6.5 diff --git a/README.md b/README.md index 84d078d..bce68d6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 31cc0c0..0c5c085 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/dist/index.js b/dist/index.js index 08a71b3..bea0df2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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' diff --git a/index.js b/index.js index 1ebeb73..5facb7e 100644 --- a/index.js +++ b/index.js @@ -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'