Compare commits

..
59 Commits
Author SHA1 Message Date
Benoit Daloze 3551d3fbd4 Store the available Ruby versions in this repository
* That way it's always perfectly synchronized with the action. In
  practice querying another repository sometimes returned a stale copy.
* Avoids an extra HTTPS request.
* The axios dependency is no longer needed.
* Makes it possible to tweak the versions available according to the platform.
2020-01-25 18:03:33 +01:00
Benoit Daloze 07160f610f Move ruby-installer-versions.js to windows-versions.js for clarity 2020-01-25 18:03:19 +01:00
Benoit Daloze 0449254cae Add Rubinius to the README 2020-01-25 18:03:19 +01:00
Benoit Daloze 689f94552b Add support for Rubinius
* Only works on ubuntu-latest.
2020-01-25 16:54:03 +01:00
Benoit Daloze db2d09d84c Rubinius fails to build the latest json 2.3.0 gem 2020-01-25 16:54:00 +01:00
Benoit Daloze 8b354c238c Show OpenSSL version for all platforms in test 2020-01-20 22:56:18 +01:00
Benoit Daloze 7f4c88c00b Give credit where credit is due 2020-01-19 23:08:30 +01:00
Benoit Daloze dbac26120b Add support for JRuby on Windows 2020-01-19 22:56:19 +01:00
Benoit Daloze 0f26fedc26 Improve error message 2020-01-19 22:55:15 +01:00
Benoit Daloze 7da380d64e Add support for Ruby 2.3 on Windows 2020-01-19 18:24:29 +01:00
Benoit Daloze 5f2df8a190 Link to the full list of versions on Windows 2020-01-19 15:13:03 +01:00
Benoit Daloze 4ff821c778 Try to trigger CI on push to branches but not to tags
* Running CI on tag is redundant with the branch push.
* Do not build on pushes to v1 as CI already ran on the master commit before.
2020-01-19 14:46:57 +01:00
Benoit Daloze 34fa48c067 Simplify steps descriptions 2020-01-19 14:46:57 +01:00
Benoit Daloze a66a46f031 Refactor code to share logic between ruby-install-builder and windows
* Make use of ruby-installer-versions.js to validate the version on Windows.
2020-01-19 14:46:57 +01:00
Benoit Daloze 537d9f67b4 Add explicit dependency on @actions/exec 2020-01-19 14:28:24 +01:00
Benoit Daloze 69599c886c Add a script to generate a list of available version from RubyInstaller 2020-01-19 14:28:19 +01:00
Benoit Daloze 247acff66d Remove no longer needed workaround 2020-01-19 13:01:02 +01:00
Benoit Daloze 7978ff1579 Print the OpenSSL version 2020-01-18 16:42:55 +01:00
Benoit Daloze 30cd88adf9 Use the newer builds from ruby-install-builder
* Which uses a newer OpenSSL for Ruby 2.3 on Ubuntu and macOS.
2020-01-18 16:36:23 +01:00
Benoit Daloze 7005fbe92a Embed the used tag in this repo for atomic updates
* Avoids stale cached requests for the latest_release.tag file.
* This also ensures reproducible builds for this repository.
2020-01-18 16:36:05 +01:00
Benoit Daloze 026be4409b Fix typo in OpenSSL test 2020-01-18 14:39:18 +01:00
Benoit Daloze 0ed24c9d6c Use shorter links in README 2020-01-17 23:17:26 +01:00
Benoit Daloze 9dab9b8155 Use a table for the Supported Platforms 2020-01-17 23:14:05 +01:00
Benoit Daloze 69709d16de Simplify the supported versions section
* Do not recommend a specific version syntax, different projects have
  different needs. The sample usages below already show the recommendation.
2020-01-17 23:01:13 +01:00
Benoit Daloze ae627f04d2 Skip CI when only modifying the README 2020-01-17 22:55:24 +01:00
Benoit Daloze eb85b2a580 Use the full repository name as the README title 2020-01-17 22:31:38 +01:00
Benoit Daloze 61efe96192 Use a single bug tracker for the action 2020-01-17 22:30:14 +01:00
Benoit Daloze 7b9c95cc8e Use "the PATH" instead of "$PATH"
* Since $PATH is a Unix-specific syntax.
2020-01-17 22:26:52 +01:00
Benoit Daloze 74ac24dec4 Add a section about versioning 2020-01-17 22:09:58 +01:00
Benoit Daloze b01832a197 Recommend to use eregon/use-ruby-action@v1 in the README 2020-01-17 22:00:29 +01:00
Benoit Daloze 66836a17bb Add TruffleRuby 19.3.1 2020-01-15 10:54:10 +01:00
Benoit Daloze 933f496844 Add a note about Ruby 2.4 on Windows
* See https://github.com/eregon/ruby-build/pull/1#issuecomment-573237440
2020-01-11 00:03:25 +01:00
Benoit Daloze b3249de963 Fix typo 2020-01-10 23:07:19 +01:00
Benoit Daloze 2a5386fca2 Improve clarity about the key for caching bundle install 2020-01-10 23:06:04 +01:00
Benoit Daloze 51f9fc6d8a Show a full example for caching bundle install
* Which should help avoid conflicts with previous caches
* See https://github.com/eregon/use-ruby-action/issues/7
2020-01-10 23:00:33 +01:00
Benoit Daloze 0b83c28888 Add a note about the workaround for https://github.com/actions/virtual-environments/issues/242 2020-01-09 18:16:05 +01:00
MSP-Greg 98c68de273 Set CLASSPATH to empty for JRuby 2020-01-09 18:15:08 +01:00
Benoit Daloze 4c25e810ed All 33 Ruby versions between 2.3.0 and 2.7.0 are now supported 2020-01-09 00:12:16 +01:00
Benoit Daloze 2127b4bb68 All Ruby versions between 2.4.0 and 2.6.5 are now supported 2020-01-08 22:47:25 +01:00
MSP-Greg 626b752912 Correct Windows MSYS2 paths 2020-01-08 22:41:06 +01:00
Benoit Daloze 819c372fe9 Install Bundler 1 on Windows for Ruby < 2.6 without Bundler 2020-01-08 22:15:01 +01:00
Benoit Daloze 268389d93d Use Bundler 1 for Rubies which don't already ship Bundler (< 2.6) 2020-01-08 21:55:11 +01:00
Benoit Daloze 92bcdc74f7 Link to the actions/cache example for Bundler caching 2020-01-07 22:11:59 +01:00
Benoit Daloze 5ee96a474a Keep documentation about the version syntax in one place 2020-01-06 22:11:28 +01:00
Benoit Daloze a61be15bff Read from .ruby-version if version is unset or set to '.ruby-version'
* Fixes https://github.com/eregon/use-ruby-action/issues/4
2020-01-06 22:00:45 +01:00
Benoit Daloze b339f321d1 Run lint in CI 2020-01-06 22:00:30 +01:00
Benoit Daloze 73ad84b99b Document about Bundler 2020-01-05 23:34:38 +01:00
Benoit Daloze 565ac51b83 Check that Bundler works 2020-01-05 23:26:03 +01:00
Benoit Daloze f06c4d9ab7 Install Bundler if needed on Windows 2020-01-05 23:21:44 +01:00
Benoit Daloze 5adac4fda6 Check that Bundler is installed 2020-01-05 23:20:09 +01:00
Benoit Daloze 3c644cf2fc Better error if MSYS2 is missing 2020-01-05 19:47:18 +01:00
Benoit Daloze 101f62de1d Add support for Windows 2020-01-05 19:33:14 +01:00
Benoit Daloze 9432c89d1a Recommend the short version syntax
* It's safer long-term and ensures to use the latest release with the most bug fixes.
2020-01-05 13:11:27 +01:00
Benoit Daloze 4c00b61136 Simplify the README 2020-01-05 13:03:07 +01:00
Benoit Daloze d49a90aea9 tmp 2020-01-05 13:02:10 +01:00
Benoit Daloze 1d7622c155 Use a consistent ordering for JRuby and TruffleRuby 2020-01-05 13:00:17 +01:00
Benoit Daloze a90d45f642 Improve the README 2020-01-05 12:55:52 +01:00
Benoit Daloze d9cd49386b Add support for Ruby 2.3
* Fixes https://github.com/eregon/use-ruby-action/issues/3
2020-01-05 12:50:37 +01:00
Benoit Daloze 7d189e2075 Improve error message when a version is not available 2020-01-04 16:18:37 +01:00
15 changed files with 631 additions and 3411 deletions
+2 -1
View File
@@ -10,7 +10,8 @@
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
}
+40 -5
View File
@@ -1,17 +1,52 @@
name: Test this action
on: [push]
on:
push:
branches-ignore:
- v1
tags-ignore:
- '*'
paths-ignore:
- README.md
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest ]
ruby: [ ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, truffleruby, jruby ]
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
# Use various version syntaxes here for testing
ruby: [ .ruby-version, 2.3, ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, jruby, truffleruby, rubinius ]
exclude:
- os: windows-latest
ruby: truffleruby
- os: ubuntu-16.04
ruby: rubinius
- os: macos-latest
ruby: rubinius
- os: windows-latest
ruby: rubinius
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: ./
with:
ruby-version: ${{ matrix.ruby }}
- run: ruby -v
- run: ruby -ropen-uri -e 'puts open("https://rubygems.org/") { |f| f.read(2014) }'
- run: ruby --version
- run: ridk version
if: matrix.os == 'windows-latest' && !startsWith(matrix.ruby, '2.3')
- name: OpenSSL version
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
- name: OpenSSL test
run: ruby -ropen-uri -e 'puts open(%{https://rubygems.org/}) { |f| f.read(1024) }'
- name: C extension test
run: gem install json:2.2.0 --no-document
- name: Bundler version
run: bundle --version
- name: Bundler test
run: bundle install
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn install
- run: yarn run lint
+1
View File
@@ -0,0 +1 @@
ruby-2.6.5
+5
View File
@@ -0,0 +1,5 @@
# Used for testing
source 'https://rubygems.org'
gem "path"
gem "json", "2.2.0"
+72 -33
View File
@@ -1,16 +1,41 @@
# use-ruby
# use-ruby-action
This action downloads a prebuilt ruby and adds it to `$PATH`.
This action downloads a prebuilt ruby and adds it to the `PATH`.
It currently supports the latest stable versions of MRI, JRuby and TruffleRuby.
It is very efficient and takes about 5 seconds to download, extract and add the given Ruby to the `PATH`.
No extra packages need to be installed.
See https://github.com/eregon/ruby-install-builder/blob/metadata/versions.json
for the available Ruby versions.
### Supported Versions
The action works for the `ubuntu-16.04`, `ubuntu-18.04` and `macos-latest` GitHub-hosted runners.
`windows-latest` is not yet supported.
This action currently supports these versions of MRI, JRuby and TruffleRuby:
The prebuilt rubies are generated by https://github.com/eregon/ruby-install-builder.
| Interpreter | Versions |
| ----------- | -------- |
| Ruby | 2.3.0 - 2.3.8, 2.4.0 - 2.4.9, 2.5.0 - 2.5.7, 2.6.0 - 2.6.5, 2.7.0 |
| JRuby | 9.2.9.0 |
| TruffleRuby | 19.3.0, 19.3.1 |
| Rubinius | 4.13 |
Note that Ruby 2.3 and the OpenSSL version it needs (1.0.2) are both end-of-life,
which means Ruby 2.3 is unmaintained and considered insecure.
On Windows, Ruby 2.4 uses OpenSSL 1.0.2, which is no longer maintained.
### Supported Platforms
The action works for all [GitHub-hosted runners](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners).
| Operating System | Versions |
| ----------- | -------- |
| Ubuntu | `ubuntu-latest` (= `ubuntu-18.04`), `ubuntu-16.04` |
| macOS | `macos-latest` |
| Windows | `windows-latest` |
Rubinius is only available on `ubuntu-latest`.
The prebuilt rubies are generated by [eregon/ruby-install-builder](https://github.com/eregon/ruby-install-builder)
and on Windows by [RubyInstaller2](https://github.com/oneclick/rubyinstaller2).
The full list of available Ruby versions can be seen in [ruby-install-builder-versions.js](ruby-install-builder-versions.js)
for Ubuntu and macOS and in [windows-versions.js](windows-versions.js) for Windows.
## Usage
@@ -24,14 +49,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: eregon/use-ruby-action@master
- uses: eregon/use-ruby-action@v1
with:
ruby-version: ruby-2.6
ruby-version: 2.6
- run: ruby -v
```
### Matrix
This matrix tests all stable releases of MRI, JRuby and TruffleRuby on Ubuntu and macOS.
```yaml
name: My workflow
on: [push]
@@ -41,11 +68,11 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
ruby: [ ruby-2.6, ruby-2.7, truffleruby-19.3.0, jruby-9.2.9.0 ]
ruby: [ 2.4, 2.5, 2.6, 2.7, jruby, truffleruby ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: eregon/use-ruby-action@master
- uses: eregon/use-ruby-action@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: ruby -v
@@ -57,36 +84,48 @@ 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` (also the default value) reads from the project's `.ruby-version` file
### All Stable Versions
### Bundler
With that, we can test on all stable releases of MRI, JRuby and TruffleRuby with:
Currently, Bundler is guaranteed to be installed for all versions.
If the Ruby ships with Bundler (Ruby >= 2.6), that version is used.
Otherwise (Ruby < 2.6), Bundler 1 is installed when that Ruby was built.
### Caching `bundle install`
You can cache the installed gems with these two steps:
```yaml
name: My workflow
on: [push]
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
ruby: [ 2.4, 2.5, 2.6, 2.7, truffleruby, jruby ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: eregon/use-ruby-action@master
- uses: actions/cache@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: ruby -v
path: vendor/bundle
key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-
- name: Bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
```
## Efficiency
When using a single job with a Ruby version, replace `${{ matrix.ruby }}` with the Ruby version.
When using `.ruby-version`, replace `${{ matrix.ruby }}` with `${{ hashFiles('.ruby-version') }}`.
It takes about 5 seconds to setup the given Ruby.
This uses the [cache action](https://github.com/actions/cache).
The code above is a more complete version of the [Ruby - Gem example](https://github.com/actions/cache/blob/master/examples.md#ruby---gem).
Make sure to include `use-ruby` in the `key` to avoid conflicting with previous caches.
## Limitations
* Currently does not work on Windows since the builder doesn't build on Windows.
https://github.com/MSP-Greg/actions-ruby is an alternative on Windows.
* This action currently only works with GitHub-hosted runners, not private runners.
## Versioning
This action follows semantic versioning with a moving `v1` branch.
This follows the [recommendations](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) of GitHub Actions.
## Credits
Most of the Windows logic is from https://github.com/MSP-Greg/actions-ruby by MSP-Greg.
Many thanks to MSP-Greg and Lars Kanis for the help with Ruby Installer.
+3 -3
View File
@@ -1,13 +1,13 @@
name: 'Setup Ruby, JRuby and TruffleRuby'
description: 'Download a prebuilt Ruby and add it to $PATH in 5 seconds'
description: 'Download a prebuilt Ruby and add it to the PATH in 5 seconds'
author: 'Benoit Daloze'
branding:
color: red
icon: download
inputs:
ruby-version:
description: 'Engine and version to use in the format "myruby-X.Y.Z"'
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'
Generated Vendored
+282 -3300
View File
File diff suppressed because it is too large Load Diff
+27
View File
@@ -0,0 +1,27 @@
require 'net/http'
require 'yaml'
require 'json'
url = 'https://raw.githubusercontent.com/oneclick/rubyinstaller.org-website/master/_data/downloads.yaml'
entries = YAML.load(Net::HTTP.get(URI(url)), symbolize_names: true)
versions = entries.select { |entry|
entry[:filetype] == 'rubyinstaller7z' and
entry[:name].include?('(x64)')
}.group_by { |entry|
entry[:name][/Ruby (\d+\.\d+\.\d+)/, 1]
}.map { |version, builds|
unless builds.sort_by { |build| build[:name] } == builds.reverse
raise "not sorted as expected for #{version}"
end
[version, builds.first]
}.sort_by { |version, entry|
version
}.select { |version, entry|
version >= "2.3"
}.map { |version, entry|
[version, entry[:href]]
}.to_h
js = "export const versions = #{JSON.pretty_generate(versions)}\n"
File.write 'windows-versions.js', js
+29 -33
View File
@@ -1,42 +1,35 @@
const os = require('os')
const fs = require('fs')
const core = require('@actions/core')
const io = require('@actions/io')
const tc = require('@actions/tool-cache')
const axios = require('axios')
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
const metadataURL = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata'
async function run() {
try {
const ruby = await getRubyEngineAndVersion(core.getInput('ruby-version'))
const rubiesDir = `${process.env.HOME}/.rubies`
await io.mkdirP(rubiesDir)
const platform = getVirtualEnvironmentName()
const tag = await getLatestReleaseTag()
const url = `${releasesURL}/download/${tag}/${ruby}-${platform}.tar.gz`
console.log(url)
const [engine, version] = parseRubyEngineAndVersion(core.getInput('ruby-version'))
const downloadPath = await tc.downloadTool(url)
await tc.extractTar(downloadPath, rubiesDir)
let installer
if (platform === 'windows-latest' && engine !== 'jruby') {
installer = require('./windows')
} else {
installer = require('./ruby-install-builder')
}
const rubyPrefix = `${rubiesDir}/${ruby}`
core.addPath(`${rubyPrefix}/bin`)
const engineVersions = installer.getAvailableVersions(platform, engine)
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)
const rubyPrefix = await installer.install(platform, ruby)
core.setOutput('ruby-prefix', rubyPrefix)
} catch (error) {
core.setFailed(error.message)
}
}
async function getLatestReleaseTag() {
const response = await axios.get(`${metadataURL}/latest_release.tag`)
return response.data.trim()
}
function parseRubyEngineAndVersion(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`)
}
async function getRubyEngineAndVersion(rubyVersion) {
let engine, version
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
engine = 'ruby'
@@ -48,20 +41,23 @@ async function getRubyEngineAndVersion(rubyVersion) {
[engine, version] = rubyVersion.split('-', 2)
}
const response = await axios.get(`${metadataURL}/versions.json`)
const stableVersions = response.data
const engineVersions = stableVersions[engine]
return [engine, version]
}
function validateRubyEngineAndVersion(platform, engineVersions, engine, version) {
if (!engineVersions) {
throw new Error(`Unknown engine ${engine} (${rubyVersion})`)
throw new Error(`Unknown engine ${engine} on ${platform}`)
}
if (!engineVersions.includes(version)) {
engineVersions.reverse() // inplace!
let found = engineVersions.find(v => v.startsWith(version))
const latestToFirstVersion = engineVersions.slice().reverse()
const found = latestToFirstVersion.find(v => v.startsWith(version))
if (found) {
version = found
} else {
throw new Error(`Unknown version ${version} (${rubyVersion})`)
throw new Error(`Unknown version ${version} for ${engine} on ${platform}
available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}
File an issue at https://github.com/eregon/use-ruby-action/issues if would like support for a new version`)
}
}
@@ -70,11 +66,11 @@ async function getRubyEngineAndVersion(rubyVersion) {
function getVirtualEnvironmentName() {
const platform = os.platform()
if (platform == 'linux') {
if (platform === 'linux') {
return `ubuntu-${findUbuntuVersion()}`
} else if (platform == 'darwin') {
} else if (platform === 'darwin') {
return 'macos-latest'
} else if (platform == 'win32') {
} else if (platform === 'win32') {
return 'windows-latest'
} else {
throw new Error(`Unknown platform ${platform}`)
+4 -4
View File
@@ -1,10 +1,10 @@
{
"name": "use-ruby-action",
"version": "0.1.0",
"description": "Download a prebuilt ruby and add it to $PATH",
"description": "Download a prebuilt Ruby and add it to the PATH in 5 seconds",
"main": "index.js",
"scripts": {
"lint": "eslint index.js",
"lint": "eslint *.js",
"package": "ncc build index.js -o dist"
},
"repository": {
@@ -24,9 +24,9 @@
"homepage": "https://github.com/eregon/use-ruby-action",
"dependencies": {
"@actions/core": "^1.1.1",
"@actions/exec": "^1.0.1",
"@actions/io": "^1.0.1",
"@actions/tool-cache": "^1.1.2",
"axios": "^0.19.0"
"@actions/tool-cache": "^1.1.2"
},
"devDependencies": {
"@zeit/ncc": "^0.20.5",
+25
View File
@@ -0,0 +1,25 @@
export function getVersions(platform) {
const versions = {
"ruby": [
"2.3.0", "2.3.1", "2.3.2", "2.3.3", "2.3.4", "2.3.5", "2.3.6", "2.3.7", "2.3.8",
"2.4.0", "2.4.1", "2.4.2", "2.4.3", "2.4.4", "2.4.5", "2.4.6", "2.4.7", "2.4.9",
"2.5.0", "2.5.1", "2.5.2", "2.5.3", "2.5.4", "2.5.5", "2.5.6", "2.5.7",
"2.6.0", "2.6.1", "2.6.2", "2.6.3", "2.6.4", "2.6.5",
"2.7.0"
],
"jruby": [
"9.2.9.0"
],
"truffleruby": [
"19.3.0", "19.3.1"
]
}
if (platform === 'ubuntu-18.04') {
versions['rubinius'] = [
"4.13"
]
}
return versions
}
+37
View File
@@ -0,0 +1,37 @@
const os = require('os')
const path = require('path')
const core = require('@actions/core')
const io = require('@actions/io')
const tc = require('@actions/tool-cache')
const rubyBuilderVersions = require('./ruby-install-builder-versions')
const builderReleaseTag = 'builds-newer-openssl'
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
export function getAvailableVersions(platform, engine) {
return rubyBuilderVersions.getVersions(platform)[engine]
}
export async function install(platform, ruby) {
const rubyPrefix = await downloadAndExtract(platform, ruby)
core.addPath(path.join(rubyPrefix, 'bin'))
if (ruby.startsWith('rubinius')) {
core.addPath(path.join(rubyPrefix, 'gems', 'bin'))
}
return rubyPrefix
}
async function downloadAndExtract(platform, ruby) {
const rubiesDir = path.join(os.homedir(), '.rubies')
await io.mkdirP(rubiesDir)
const url = `${releasesURL}/download/${builderReleaseTag}/${ruby}-${platform}.tar.gz`
console.log(url)
const downloadPath = await tc.downloadTool(url)
await tc.extractTar(downloadPath, rubiesDir)
return path.join(rubiesDir, ruby)
}
+26
View File
@@ -0,0 +1,26 @@
export const versions = {
"2.3.0": "https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.3.0-x64-mingw32.7z",
"2.3.1": "https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.3.1-x64-mingw32.7z",
"2.3.3": "https://dl.bintray.com/oneclick/rubyinstaller/ruby-2.3.3-x64-mingw32.7z",
"2.4.1": "https://github.com/oneclick/rubyinstaller2/releases/download/2.4.1-2/rubyinstaller-2.4.1-2-x64.7z",
"2.4.2": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.4.2-2/rubyinstaller-2.4.2-2-x64.7z",
"2.4.3": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.4.3-2/rubyinstaller-2.4.3-2-x64.7z",
"2.4.4": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.4.4-2/rubyinstaller-2.4.4-2-x64.7z",
"2.4.5": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.4.5-1/rubyinstaller-2.4.5-1-x64.7z",
"2.4.6": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.6-1/rubyinstaller-2.4.6-1-x64.7z",
"2.4.7": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.7-1/rubyinstaller-2.4.7-1-x64.7z",
"2.4.9": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.4.9-1/rubyinstaller-2.4.9-1-x64.7z",
"2.5.0": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.0-2/rubyinstaller-2.5.0-2-x64.7z",
"2.5.1": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.1-2/rubyinstaller-2.5.1-2-x64.7z",
"2.5.3": "https://github.com/oneclick/rubyinstaller2/releases/download/rubyinstaller-2.5.3-1/rubyinstaller-2.5.3-1-x64.7z",
"2.5.5": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.5-1/rubyinstaller-2.5.5-1-x64.7z",
"2.5.6": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.6-1/rubyinstaller-2.5.6-1-x64.7z",
"2.5.7": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.5.7-1/rubyinstaller-2.5.7-1-x64.7z",
"2.6.0": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.0-1/rubyinstaller-2.6.0-1-x64.7z",
"2.6.1": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.1-1/rubyinstaller-2.6.1-1-x64.7z",
"2.6.2": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.2-1/rubyinstaller-2.6.2-1-x64.7z",
"2.6.3": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.3-1/rubyinstaller-2.6.3-1-x64.7z",
"2.6.4": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.4-1/rubyinstaller-2.6.4-1-x64.7z",
"2.6.5": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.6.5-1/rubyinstaller-2.6.5-1-x64.7z",
"2.7.0": "https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.0-1/rubyinstaller-2.7.0-1-x64.7z"
}
+78
View File
@@ -0,0 +1,78 @@
// Most of this logic is from
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
const fs = require('fs')
const core = require('@actions/core')
const exec = require('@actions/exec')
const tc = require('@actions/tool-cache')
const rubyInstallerVersions = require('./windows-versions').versions
export function getAvailableVersions(platform, engine) {
if (engine === 'ruby') {
return Object.keys(rubyInstallerVersions)
} else {
return undefined
}
}
export async function install(platform, ruby) {
const version = ruby.split('-', 2)[1]
const url = rubyInstallerVersions[version]
console.log(url)
if (!url.endsWith('.7z')) {
throw new Error('URL should end in .7z')
}
const base = url.slice(url.lastIndexOf('/') + 1, url.length - '.7z'.length)
const downloadPath = await tc.downloadTool(url)
await exec.exec(`7z x ${downloadPath} -xr!${base}\\share\\doc -oC:\\`)
const rubyPrefix = `C:\\${base}`
const [hostedRuby, msys2] = await linkMSYS2()
const newPath = setupPath(msys2, rubyPrefix)
core.exportVariable('PATH', newPath)
if (version.startsWith('2.3')) {
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`)
}
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
}
return rubyPrefix
}
async function linkMSYS2() {
const toolCacheVersions = tc.findAllVersions('Ruby')
toolCacheVersions.sort()
if (toolCacheVersions.length === 0) {
throw new Error('Could not find MSYS2 in the toolcache')
}
const latestVersion = toolCacheVersions.slice(-1)[0]
const latestHostedRuby = tc.find('Ruby', latestVersion)
const hostedMSYS2 = `${latestHostedRuby}\\msys64`
const msys2 = 'C:\\msys64'
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedMSYS2}`)
return [latestHostedRuby, msys2]
}
function setupPath(msys2, rubyPrefix) {
let path = process.env['PATH'].split(';')
// Remove conflicting dev tools from PATH
path = path.filter(e => !e.match(/\b(Chocolatey|CMake|mingw64|OpenSSL|Strawberry)\b/))
// Remove default Ruby in PATH
path = path.filter(e => !e.match(/\bRuby\b/))
// Add MSYS2 in PATH
path.unshift(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
// Add the downloaded Ruby in PATH
path.unshift(`${rubyPrefix}\\bin`)
return path.join(';')
}
Generated
-32
View File
@@ -108,14 +108,6 @@ astral-regex@^1.0.0:
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9"
integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==
axios@^0.19.0:
version "0.19.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.0.tgz#8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8"
integrity sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==
dependencies:
follow-redirects "1.5.10"
is-buffer "^2.0.2"
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
@@ -188,13 +180,6 @@ cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"
debug@=3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"
debug@^4.0.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
@@ -382,13 +367,6 @@ flatted@^2.0.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.1.tgz#69e57caa8f0eacbc281d2e2cb458d46fdb449e08"
integrity sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==
follow-redirects@1.5.10:
version "1.5.10"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
dependencies:
debug "=3.1.0"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -487,11 +465,6 @@ inquirer@^7.0.0:
strip-ansi "^5.1.0"
through "^2.3.6"
is-buffer@^2.0.2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.4.tgz#3e572f23c8411a5cfd9557c849e3665e0b290623"
integrity sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==
is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
@@ -584,11 +557,6 @@ mkdirp@^0.5.1:
dependencies:
minimist "0.0.8"
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
ms@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"