Skip to content

Commit dbac261

Browse files
committed
Add support for JRuby on Windows
1 parent 0f26fed commit dbac261

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

.github/workflows/test.yml

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ jobs:
1616
# Use various version syntaxes here for testing
1717
ruby: [ .ruby-version, 2.3, ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, jruby, truffleruby ]
1818
exclude:
19-
- os: windows-latest
20-
ruby: jruby
2119
- os: windows-latest
2220
ruby: truffleruby
2321
runs-on: ${{ matrix.os }}

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ The action works for all [GitHub-hosted runners](https://help.github.com/en/acti
2929
| macOS | `macos-latest` |
3030
| Windows | `windows-latest` |
3131

32-
JRuby and TruffleRuby are not yet supported on `windows-latest`.
33-
3432
The prebuilt rubies are generated by [eregon/ruby-install-builder](https://github.com/eregon/ruby-install-builder)
3533
and on Windows by [RubyInstaller2](https://github.com/oneclick/rubyinstaller2).
3634
The full list of available Ruby versions can be seen at [versions.json](https://github.com/eregon/ruby-install-builder/blob/metadata/versions.json)

dist/index.js

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

index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ const core = require('@actions/core')
55
async function run() {
66
try {
77
const platform = getVirtualEnvironmentName()
8+
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
9+
810
let installer
9-
if (platform === 'windows-latest') {
11+
if (platform === 'windows-latest' && engine !== 'jruby') {
1012
installer = require('./windows')
1113
} else {
1214
installer = require('./ruby-install-builder')
1315
}
1416

15-
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
1617
const engineVersions = await installer.getAvailableVersions(engine)
1718
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
1819

ruby-install-builder.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const os = require('os')
2+
const path = require('path')
13
const core = require('@actions/core')
24
const io = require('@actions/io')
35
const tc = require('@actions/tool-cache')
@@ -15,12 +17,12 @@ export async function getAvailableVersions(engine) {
1517

1618
export async function install(platform, ruby) {
1719
const rubyPrefix = await downloadAndExtract(platform, ruby)
18-
core.addPath(`${rubyPrefix}/bin`)
20+
core.addPath(path.join(rubyPrefix, 'bin'))
1921
return rubyPrefix
2022
}
2123

2224
async function downloadAndExtract(platform, ruby) {
23-
const rubiesDir = `${process.env.HOME}/.rubies`
25+
const rubiesDir = path.join(os.homedir(), '.rubies')
2426
await io.mkdirP(rubiesDir)
2527

2628
const url = `${releasesURL}/download/${builderReleaseTag}/${ruby}-${platform}.tar.gz`
@@ -29,5 +31,5 @@ async function downloadAndExtract(platform, ruby) {
2931
const downloadPath = await tc.downloadTool(url)
3032
await tc.extractTar(downloadPath, rubiesDir)
3133

32-
return `${rubiesDir}/${ruby}`
34+
return path.join(rubiesDir, ruby)
3335
}

0 commit comments

Comments
 (0)