Skip to content

Commit ef45abe

Browse files
hobbypunk90eregon
andauthored
Add support for mise.toml (#700)
Co-authored-by: Benoit Daloze <[email protected]>
1 parent 8388f20 commit ef45abe

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
- uses: actions/checkout@v4
7575
- uses: ruby/setup-ruby@v1
7676
with:
77-
ruby-version: '3.3' # Not needed with a `.ruby-version` or `.tool-versions`
77+
ruby-version: '3.3' # Not needed with a `.ruby-version`, `.tool-versions` or `mise.toml`
7878
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
7979
- run: bundle exec rake
8080
```
@@ -139,11 +139,12 @@ and the [condition and expression syntax](https://help.github.com/en/actions/ref
139139
* engine only like `ruby` and `truffleruby`, uses the latest stable release of that implementation
140140
* `.ruby-version` reads from the project's `.ruby-version` file
141141
* `.tool-versions` reads from the project's `.tool-versions` file
142-
* If the `ruby-version` input is not specified, `.ruby-version` is tried first, followed by `.tool-versions`
142+
* `mise.toml` reads from the project's `mise.toml` file
143+
* If the `ruby-version` input is not specified, `.ruby-version` is tried first, followed by `.tool-versions`, followed by `mise.toml`
143144

144145
### Working Directory
145146

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

149150
### RubyGems

action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ branding:
66
icon: download
77
inputs:
88
ruby-version:
9-
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version or .tool-versions if unset.'
9+
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version, .tool-versions or mise.toml if unset.'
1010
default: 'default'
1111
rubygems:
1212
description: |
@@ -26,7 +26,7 @@ inputs:
2626
description: 'Run "bundle install", and cache the result automatically. Either true or false.'
2727
default: 'false'
2828
working-directory:
29-
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions and Gemfile.lock.'
29+
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions, mise.toml and Gemfile.lock.'
3030
cache-version:
3131
description: |
3232
Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need

dist/index.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ function parseRubyEngineAndVersion(rubyVersion) {
117117
rubyVersion = '.ruby-version'
118118
} else if (fs.existsSync('.tool-versions')) {
119119
rubyVersion = '.tool-versions'
120+
} else if (fs.existsSync('mise.toml')) {
121+
rubyVersion = 'mise.toml'
120122
} else {
121123
throw new Error('input ruby-version needs to be specified if no .ruby-version or .tool-versions file exists')
122124
}
@@ -130,6 +132,11 @@ function parseRubyEngineAndVersion(rubyVersion) {
130132
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s/.test(e))[0]
131133
rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1]
132134
console.log(`Using ${rubyVersion} as input from file .tool-versions`)
135+
} else if (rubyVersion === 'mise.toml') { // Read from mise.toml
136+
const toolVersions = fs.readFileSync('mise.toml', 'utf8').trim()
137+
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s*=\s*/.test(e))[0]
138+
rubyVersion = rubyLine.match(/^ruby\s*=\s*['"](.+)['"]$/)[1]
139+
console.log(`Using ${rubyVersion} as input from file mise.toml`)
133140
}
134141

135142
let engine, version

0 commit comments

Comments
 (0)