Skip to content

Commit

Permalink
Add support for mise.toml (#700)
Browse files Browse the repository at this point in the history
Co-authored-by: Benoit Daloze <[email protected]>
  • Loading branch information
hobbypunk90 and eregon authored Feb 5, 2025
1 parent 8388f20 commit ef45abe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3' # Not needed with a `.ruby-version` or `.tool-versions`
ruby-version: '3.3' # Not needed with a `.ruby-version`, `.tool-versions` or `mise.toml`
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: bundle exec rake
```
Expand Down Expand Up @@ -139,11 +139,12 @@ and the [condition and expression syntax](https://help.github.com/en/actions/ref
* engine only like `ruby` and `truffleruby`, uses the latest stable release of that implementation
* `.ruby-version` reads from the project's `.ruby-version` file
* `.tool-versions` reads from the project's `.tool-versions` file
* If the `ruby-version` input is not specified, `.ruby-version` is tried first, followed by `.tool-versions`
* `mise.toml` reads from the project's `mise.toml` file
* If the `ruby-version` input is not specified, `.ruby-version` is tried first, followed by `.tool-versions`, followed by `mise.toml`

### Working Directory

The `working-directory` input can be set to resolve `.ruby-version`, `.tool-versions` and `Gemfile.lock`
The `working-directory` input can be set to resolve `.ruby-version`, `.tool-versions`, `mise.toml` and `Gemfile.lock`
if they are not at the root of the repository, see [action.yml](action.yml) for details.

### RubyGems
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ branding:
icon: download
inputs:
ruby-version:
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version or .tool-versions if unset.'
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version, .tool-versions or mise.toml if unset.'
default: 'default'
rubygems:
description: |
Expand All @@ -26,7 +26,7 @@ inputs:
description: 'Run "bundle install", and cache the result automatically. Either true or false.'
default: 'false'
working-directory:
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions and Gemfile.lock.'
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions, mise.toml and Gemfile.lock.'
cache-version:
description: |
Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need
Expand Down
7 changes: 7 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ function parseRubyEngineAndVersion(rubyVersion) {
rubyVersion = '.ruby-version'
} else if (fs.existsSync('.tool-versions')) {
rubyVersion = '.tool-versions'
} else if (fs.existsSync('mise.toml')) {
rubyVersion = 'mise.toml'
} else {
throw new Error('input ruby-version needs to be specified if no .ruby-version or .tool-versions file exists')
}
Expand All @@ -130,6 +132,11 @@ function parseRubyEngineAndVersion(rubyVersion) {
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s/.test(e))[0]
rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1]
console.log(`Using ${rubyVersion} as input from file .tool-versions`)
} else if (rubyVersion === 'mise.toml') { // Read from mise.toml
const toolVersions = fs.readFileSync('mise.toml', 'utf8').trim()
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s*=\s*/.test(e))[0]
rubyVersion = rubyLine.match(/^ruby\s*=\s*['"](.+)['"]$/)[1]
console.log(`Using ${rubyVersion} as input from file mise.toml`)
}

let engine, version
Expand Down

0 comments on commit ef45abe

Please sign in to comment.