mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 22:44:20 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ff821c778 | ||
|
|
34fa48c067 | ||
|
|
a66a46f031 | ||
|
|
537d9f67b4 | ||
|
|
69599c886c | ||
|
|
247acff66d | ||
|
|
7978ff1579 | ||
|
|
30cd88adf9 | ||
|
|
7005fbe92a | ||
|
|
026be4409b | ||
|
|
0ed24c9d6c | ||
|
|
9dab9b8155 | ||
|
|
69709d16de | ||
|
|
ae627f04d2 | ||
|
|
eb85b2a580 | ||
|
|
61efe96192 | ||
|
|
7b9c95cc8e | ||
|
|
74ac24dec4 | ||
|
|
b01832a197 | ||
|
|
66836a17bb | ||
|
|
933f496844 | ||
|
|
b3249de963 | ||
|
|
2a5386fca2 | ||
|
|
51f9fc6d8a | ||
|
|
0b83c28888 | ||
|
|
98c68de273 | ||
|
|
4c25e810ed | ||
|
|
2127b4bb68 | ||
|
|
626b752912 | ||
|
|
819c372fe9 | ||
|
|
268389d93d | ||
|
|
92bcdc74f7 | ||
|
|
5ee96a474a | ||
|
|
a61be15bff | ||
|
|
b339f321d1 | ||
|
|
73ad84b99b | ||
|
|
565ac51b83 | ||
|
|
f06c4d9ab7 | ||
|
|
5adac4fda6 | ||
|
|
3c644cf2fc | ||
|
|
101f62de1d | ||
|
|
9432c89d1a | ||
|
|
4c00b61136 | ||
|
|
d49a90aea9 | ||
|
|
1d7622c155 | ||
|
|
a90d45f642 | ||
|
|
d9cd49386b | ||
|
|
7d189e2075 |
+2
-1
@@ -10,7 +10,8 @@
|
|||||||
"SharedArrayBuffer": "readonly"
|
"SharedArrayBuffer": "readonly"
|
||||||
},
|
},
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2018
|
"ecmaVersion": 2018,
|
||||||
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,50 @@
|
|||||||
name: Test this action
|
name: Test this action
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- v1
|
||||||
|
tags-ignore:
|
||||||
|
- '*'
|
||||||
|
paths-ignore:
|
||||||
|
- README.md
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest ]
|
os: [ ubuntu-16.04, ubuntu-18.04, macos-latest, windows-latest ]
|
||||||
ruby: [ ruby-2.4, 2.5, ruby-2.6.5, 2.7.0, truffleruby, jruby ]
|
# 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 ]
|
||||||
|
exclude:
|
||||||
|
- os: windows-latest
|
||||||
|
ruby: 2.3
|
||||||
|
- os: windows-latest
|
||||||
|
ruby: jruby
|
||||||
|
- os: windows-latest
|
||||||
|
ruby: truffleruby
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
- run: ruby -v
|
- run: ruby --version
|
||||||
- run: ruby -ropen-uri -e 'puts open("https://rubygems.org/") { |f| f.read(2014) }'
|
- run: ridk version
|
||||||
|
if: matrix.os == 'windows-latest'
|
||||||
|
- 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 --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
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ruby-2.6.5
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Used for testing
|
||||||
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
gem "path"
|
||||||
|
gem "json"
|
||||||
@@ -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
|
### Supported Versions
|
||||||
for the available Ruby versions.
|
|
||||||
|
|
||||||
The action works for the `ubuntu-16.04`, `ubuntu-18.04` and `macos-latest` GitHub-hosted runners.
|
This action currently supports these versions of MRI, JRuby and TruffleRuby:
|
||||||
`windows-latest` is not yet supported.
|
|
||||||
|
|
||||||
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 |
|
||||||
|
|
||||||
|
See [versions.json](https://github.com/eregon/ruby-install-builder/blob/metadata/versions.json)
|
||||||
|
for the always up-to-date list of available Ruby versions.
|
||||||
|
|
||||||
|
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` |
|
||||||
|
|
||||||
|
Ruby 2.3, JRuby and TruffleRuby are not yet supported on `windows-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).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -24,14 +49,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: eregon/use-ruby-action@master
|
- uses: eregon/use-ruby-action@v1
|
||||||
with:
|
with:
|
||||||
ruby-version: ruby-2.6
|
ruby-version: 2.6
|
||||||
- run: ruby -v
|
- run: ruby -v
|
||||||
```
|
```
|
||||||
|
|
||||||
### Matrix
|
### Matrix
|
||||||
|
|
||||||
|
This matrix tests all stable releases of MRI, JRuby and TruffleRuby on Ubuntu and macOS.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: My workflow
|
name: My workflow
|
||||||
on: [push]
|
on: [push]
|
||||||
@@ -41,11 +68,11 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-latest, macos-latest ]
|
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 }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: eregon/use-ruby-action@master
|
- uses: eregon/use-ruby-action@v1
|
||||||
with:
|
with:
|
||||||
ruby-version: ${{ matrix.ruby }}
|
ruby-version: ${{ matrix.ruby }}
|
||||||
- run: ruby -v
|
- run: ruby -v
|
||||||
@@ -57,36 +84,47 @@ jobs:
|
|||||||
* short version like `2.6`, automatically using the latest release matching that version (`2.6.5`)
|
* 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
|
* version only like `2.6.5`, assumes MRI for the engine
|
||||||
* engine only like `truffleruby`, uses the latest stable release of that implementation
|
* 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
|
```yaml
|
||||||
name: My workflow
|
- uses: actions/cache@v1
|
||||||
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
|
|
||||||
with:
|
with:
|
||||||
ruby-version: ${{ matrix.ruby }}
|
path: vendor/bundle
|
||||||
- run: ruby -v
|
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
|
## 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.
|
* 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.
|
||||||
|
|||||||
+3
-3
@@ -1,13 +1,13 @@
|
|||||||
name: 'Setup Ruby, JRuby and TruffleRuby'
|
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'
|
author: 'Benoit Daloze'
|
||||||
branding:
|
branding:
|
||||||
color: red
|
color: red
|
||||||
icon: download
|
icon: download
|
||||||
inputs:
|
inputs:
|
||||||
ruby-version:
|
ruby-version:
|
||||||
description: 'Engine and version to use in the format "myruby-X.Y.Z"'
|
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version if unset.'
|
||||||
required: true
|
default: '.ruby-version'
|
||||||
outputs:
|
outputs:
|
||||||
ruby-prefix:
|
ruby-prefix:
|
||||||
description: 'The prefix of the installed ruby'
|
description: 'The prefix of the installed ruby'
|
||||||
|
|||||||
+245
-57
@@ -36,6 +36,8 @@ module.exports =
|
|||||||
/******/ // Load entry module and return exports
|
/******/ // Load entry module and return exports
|
||||||
/******/ return __webpack_require__(104);
|
/******/ return __webpack_require__(104);
|
||||||
/******/ };
|
/******/ };
|
||||||
|
/******/ // initialize runtime
|
||||||
|
/******/ runtime(__webpack_require__);
|
||||||
/******/
|
/******/
|
||||||
/******/ // run startup
|
/******/ // run startup
|
||||||
/******/ return startup();
|
/******/ return startup();
|
||||||
@@ -1380,42 +1382,35 @@ module.exports = require("os");
|
|||||||
const os = __webpack_require__(87)
|
const os = __webpack_require__(87)
|
||||||
const fs = __webpack_require__(747)
|
const fs = __webpack_require__(747)
|
||||||
const core = __webpack_require__(470)
|
const core = __webpack_require__(470)
|
||||||
const io = __webpack_require__(1)
|
|
||||||
const tc = __webpack_require__(533)
|
|
||||||
const axios = __webpack_require__(53)
|
|
||||||
|
|
||||||
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
|
|
||||||
const metadataURL = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata'
|
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const ruby = await getRubyEngineAndVersion(core.getInput('ruby-version'))
|
|
||||||
|
|
||||||
const rubiesDir = `${process.env.HOME}/.rubies`
|
|
||||||
await io.mkdirP(rubiesDir)
|
|
||||||
|
|
||||||
const platform = getVirtualEnvironmentName()
|
const platform = getVirtualEnvironmentName()
|
||||||
const tag = await getLatestReleaseTag()
|
let installer
|
||||||
const url = `${releasesURL}/download/${tag}/${ruby}-${platform}.tar.gz`
|
if (platform === 'windows-latest') {
|
||||||
console.log(url)
|
installer = __webpack_require__(826)
|
||||||
|
} else {
|
||||||
|
installer = __webpack_require__(442)
|
||||||
|
}
|
||||||
|
|
||||||
const downloadPath = await tc.downloadTool(url)
|
const input = core.getInput('ruby-version')
|
||||||
await tc.extractTar(downloadPath, rubiesDir)
|
const [engine, version] = parseRubyEngineAndVersion(input)
|
||||||
|
const engineVersions = await installer.getAvailableVersions(engine)
|
||||||
|
const ruby = validateRubyEngineAndVersion(engineVersions, input, engine, version)
|
||||||
|
|
||||||
const rubyPrefix = `${rubiesDir}/${ruby}`
|
const rubyPrefix = await installer.install(platform, ruby)
|
||||||
core.addPath(`${rubyPrefix}/bin`)
|
|
||||||
core.setOutput('ruby-prefix', rubyPrefix)
|
core.setOutput('ruby-prefix', rubyPrefix)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLatestReleaseTag() {
|
function parseRubyEngineAndVersion(rubyVersion) {
|
||||||
const response = await axios.get(`${metadataURL}/latest_release.tag`)
|
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
|
||||||
return response.data.trim()
|
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
|
||||||
|
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRubyEngineAndVersion(rubyVersion) {
|
|
||||||
let engine, version
|
let engine, version
|
||||||
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
|
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
|
||||||
engine = 'ruby'
|
engine = 'ruby'
|
||||||
@@ -1427,20 +1422,24 @@ async function getRubyEngineAndVersion(rubyVersion) {
|
|||||||
[engine, version] = rubyVersion.split('-', 2)
|
[engine, version] = rubyVersion.split('-', 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await axios.get(`${metadataURL}/versions.json`)
|
return [engine, version]
|
||||||
const stableVersions = response.data
|
}
|
||||||
const engineVersions = stableVersions[engine]
|
|
||||||
|
function validateRubyEngineAndVersion(engineVersions, input, engine, version) {
|
||||||
if (!engineVersions) {
|
if (!engineVersions) {
|
||||||
throw new Error(`Unknown engine ${engine} (${rubyVersion})`)
|
throw new Error(`Unknown engine ${engine} (input: ${input})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!engineVersions.includes(version)) {
|
if (!engineVersions.includes(version)) {
|
||||||
engineVersions.reverse() // inplace!
|
const latestToFirstVersion = engineVersions.slice().reverse()
|
||||||
let found = engineVersions.find(v => v.startsWith(version))
|
const found = latestToFirstVersion.find(v => v.startsWith(version))
|
||||||
if (found) {
|
if (found) {
|
||||||
version = found
|
version = found
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unknown version ${version} (${rubyVersion})`)
|
throw new Error(`Unknown version ${version} for ${engine}
|
||||||
|
input: ${input}
|
||||||
|
available versions for ${engine}: ${engineVersions.join(', ')}
|
||||||
|
File an issue at https://github.com/eregon/use-ruby-action/issues if would like support for a new version`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1449,11 +1448,11 @@ async function getRubyEngineAndVersion(rubyVersion) {
|
|||||||
|
|
||||||
function getVirtualEnvironmentName() {
|
function getVirtualEnvironmentName() {
|
||||||
const platform = os.platform()
|
const platform = os.platform()
|
||||||
if (platform == 'linux') {
|
if (platform === 'linux') {
|
||||||
return `ubuntu-${findUbuntuVersion()}`
|
return `ubuntu-${findUbuntuVersion()}`
|
||||||
} else if (platform == 'darwin') {
|
} else if (platform === 'darwin') {
|
||||||
return 'macos-latest'
|
return 'macos-latest'
|
||||||
} else if (platform == 'win32') {
|
} else if (platform === 'win32') {
|
||||||
return 'windows-latest'
|
return 'windows-latest'
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unknown platform ${platform}`)
|
throw new Error(`Unknown platform ${platform}`)
|
||||||
@@ -4841,6 +4840,50 @@ function escape(s) {
|
|||||||
}
|
}
|
||||||
//# sourceMappingURL=command.js.map
|
//# sourceMappingURL=command.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 442:
|
||||||
|
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAvailableVersions", function() { return getAvailableVersions; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "install", function() { return install; });
|
||||||
|
const core = __webpack_require__(470)
|
||||||
|
const io = __webpack_require__(1)
|
||||||
|
const tc = __webpack_require__(533)
|
||||||
|
const axios = __webpack_require__(53)
|
||||||
|
|
||||||
|
const builderReleaseTag = 'builds-newer-openssl'
|
||||||
|
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
|
||||||
|
const metadataURL = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata'
|
||||||
|
|
||||||
|
async function getAvailableVersions(engine) {
|
||||||
|
const response = await axios.get(`${metadataURL}/versions.json`)
|
||||||
|
const versions = response.data
|
||||||
|
return versions[engine]
|
||||||
|
}
|
||||||
|
|
||||||
|
async function install(platform, ruby) {
|
||||||
|
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||||
|
core.addPath(`${rubyPrefix}/bin`)
|
||||||
|
return rubyPrefix
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downloadAndExtract(platform, ruby) {
|
||||||
|
const rubiesDir = `${process.env.HOME}/.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 `${rubiesDir}/${ruby}`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 470:
|
/***/ 470:
|
||||||
@@ -5043,6 +5086,42 @@ function getState(name) {
|
|||||||
exports.getState = getState;
|
exports.getState = getState;
|
||||||
//# sourceMappingURL=core.js.map
|
//# sourceMappingURL=core.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 494:
|
||||||
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
||||||
|
|
||||||
|
var rng = __webpack_require__(139);
|
||||||
|
var bytesToUuid = __webpack_require__(722);
|
||||||
|
|
||||||
|
function v4(options, buf, offset) {
|
||||||
|
var i = buf && offset || 0;
|
||||||
|
|
||||||
|
if (typeof(options) == 'string') {
|
||||||
|
buf = options === 'binary' ? new Array(16) : null;
|
||||||
|
options = null;
|
||||||
|
}
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
var rnds = options.random || (options.rng || rng)();
|
||||||
|
|
||||||
|
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
||||||
|
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
||||||
|
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
||||||
|
|
||||||
|
// Copy bytes to buffer, if provided
|
||||||
|
if (buf) {
|
||||||
|
for (var ii = 0; ii < 16; ++ii) {
|
||||||
|
buf[i + ii] = rnds[ii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf || bytesToUuid(rnds);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = v4;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 529:
|
/***/ 529:
|
||||||
@@ -5173,7 +5252,7 @@ const os = __webpack_require__(87);
|
|||||||
const path = __webpack_require__(622);
|
const path = __webpack_require__(622);
|
||||||
const httpm = __webpack_require__(874);
|
const httpm = __webpack_require__(874);
|
||||||
const semver = __webpack_require__(280);
|
const semver = __webpack_require__(280);
|
||||||
const uuidV4 = __webpack_require__(826);
|
const uuidV4 = __webpack_require__(494);
|
||||||
const exec_1 = __webpack_require__(986);
|
const exec_1 = __webpack_require__(986);
|
||||||
const assert_1 = __webpack_require__(357);
|
const assert_1 = __webpack_require__(357);
|
||||||
class HTTPError extends Error {
|
class HTTPError extends Error {
|
||||||
@@ -5594,6 +5673,39 @@ function _evaluateVersions(versions, versionSpec) {
|
|||||||
}
|
}
|
||||||
//# sourceMappingURL=tool-cache.js.map
|
//# sourceMappingURL=tool-cache.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 538:
|
||||||
|
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "versions", function() { return versions; });
|
||||||
|
const versions = {
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 549:
|
/***/ 549:
|
||||||
@@ -7645,37 +7757,86 @@ module.exports = function mergeConfig(config1, config2) {
|
|||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 826:
|
/***/ 826:
|
||||||
/***/ (function(module, __unusedexports, __webpack_require__) {
|
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
var rng = __webpack_require__(139);
|
"use strict";
|
||||||
var bytesToUuid = __webpack_require__(722);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getAvailableVersions", function() { return getAvailableVersions; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "install", function() { return install; });
|
||||||
|
// Most of this logic is from
|
||||||
|
// https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
|
||||||
|
|
||||||
function v4(options, buf, offset) {
|
const fs = __webpack_require__(747)
|
||||||
var i = buf && offset || 0;
|
const core = __webpack_require__(470)
|
||||||
|
const exec = __webpack_require__(986)
|
||||||
|
const tc = __webpack_require__(533)
|
||||||
|
const rubyInstallerVersions = __webpack_require__(538).versions
|
||||||
|
|
||||||
if (typeof(options) == 'string') {
|
async function getAvailableVersions(engine) {
|
||||||
buf = options === 'binary' ? new Array(16) : null;
|
if (engine === 'ruby') {
|
||||||
options = null;
|
return Object.keys(rubyInstallerVersions)
|
||||||
}
|
} else {
|
||||||
options = options || {};
|
return undefined
|
||||||
|
|
||||||
var rnds = options.random || (options.rng || rng)();
|
|
||||||
|
|
||||||
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
||||||
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
||||||
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
||||||
|
|
||||||
// Copy bytes to buffer, if provided
|
|
||||||
if (buf) {
|
|
||||||
for (var ii = 0; ii < 16; ++ii) {
|
|
||||||
buf[i + ii] = rnds[ii];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf || bytesToUuid(rnds);
|
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 msys2 = await linkMSYS2()
|
||||||
|
const newPath = setupPath(msys2, rubyPrefix)
|
||||||
|
core.exportVariable('PATH', newPath)
|
||||||
|
|
||||||
|
if (!fs.existsSync(`${rubyPrefix}\\bin\\bundle.cmd`)) {
|
||||||
|
await exec.exec(`${rubyPrefix}\\bin\\gem install bundler -v "~> 1" --no-document`)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = v4;
|
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 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(';')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -8759,4 +8920,31 @@ exports.exec = exec;
|
|||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
/******/ });
|
/******/ },
|
||||||
|
/******/ function(__webpack_require__) { // webpackRuntimeModules
|
||||||
|
/******/ "use strict";
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/make namespace object */
|
||||||
|
/******/ !function() {
|
||||||
|
/******/ // define __esModule on exports
|
||||||
|
/******/ __webpack_require__.r = function(exports) {
|
||||||
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||||
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||||
|
/******/ }
|
||||||
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
/******/ };
|
||||||
|
/******/ }();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/define property getter */
|
||||||
|
/******/ !function() {
|
||||||
|
/******/ // define getter function for harmony exports
|
||||||
|
/******/ var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||||
|
/******/ if(!hasOwnProperty.call(exports, name)) {
|
||||||
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||||
|
/******/ }
|
||||||
|
/******/ };
|
||||||
|
/******/ }();
|
||||||
|
/******/
|
||||||
|
/******/ }
|
||||||
|
);
|
||||||
@@ -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.4"
|
||||||
|
}.map { |version, entry|
|
||||||
|
[version, entry[:href]]
|
||||||
|
}.to_h
|
||||||
|
|
||||||
|
js = "export const versions = #{JSON.pretty_generate(versions)}\n"
|
||||||
|
File.write 'ruby-installer-versions.js', js
|
||||||
@@ -1,42 +1,35 @@
|
|||||||
const os = require('os')
|
const os = require('os')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const core = require('@actions/core')
|
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() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const ruby = await getRubyEngineAndVersion(core.getInput('ruby-version'))
|
|
||||||
|
|
||||||
const rubiesDir = `${process.env.HOME}/.rubies`
|
|
||||||
await io.mkdirP(rubiesDir)
|
|
||||||
|
|
||||||
const platform = getVirtualEnvironmentName()
|
const platform = getVirtualEnvironmentName()
|
||||||
const tag = await getLatestReleaseTag()
|
let installer
|
||||||
const url = `${releasesURL}/download/${tag}/${ruby}-${platform}.tar.gz`
|
if (platform === 'windows-latest') {
|
||||||
console.log(url)
|
installer = require('./windows')
|
||||||
|
} else {
|
||||||
|
installer = require('./ruby-install-builder')
|
||||||
|
}
|
||||||
|
|
||||||
const downloadPath = await tc.downloadTool(url)
|
const input = core.getInput('ruby-version')
|
||||||
await tc.extractTar(downloadPath, rubiesDir)
|
const [engine, version] = parseRubyEngineAndVersion(input)
|
||||||
|
const engineVersions = await installer.getAvailableVersions(engine)
|
||||||
|
const ruby = validateRubyEngineAndVersion(engineVersions, input, engine, version)
|
||||||
|
|
||||||
const rubyPrefix = `${rubiesDir}/${ruby}`
|
const rubyPrefix = await installer.install(platform, ruby)
|
||||||
core.addPath(`${rubyPrefix}/bin`)
|
|
||||||
core.setOutput('ruby-prefix', rubyPrefix)
|
core.setOutput('ruby-prefix', rubyPrefix)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getLatestReleaseTag() {
|
function parseRubyEngineAndVersion(rubyVersion) {
|
||||||
const response = await axios.get(`${metadataURL}/latest_release.tag`)
|
if (rubyVersion === '.ruby-version') { // Read from .ruby-version
|
||||||
return response.data.trim()
|
rubyVersion = fs.readFileSync('.ruby-version', 'utf8').trim()
|
||||||
|
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getRubyEngineAndVersion(rubyVersion) {
|
|
||||||
let engine, version
|
let engine, version
|
||||||
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
|
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
|
||||||
engine = 'ruby'
|
engine = 'ruby'
|
||||||
@@ -48,20 +41,24 @@ async function getRubyEngineAndVersion(rubyVersion) {
|
|||||||
[engine, version] = rubyVersion.split('-', 2)
|
[engine, version] = rubyVersion.split('-', 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await axios.get(`${metadataURL}/versions.json`)
|
return [engine, version]
|
||||||
const stableVersions = response.data
|
}
|
||||||
const engineVersions = stableVersions[engine]
|
|
||||||
|
function validateRubyEngineAndVersion(engineVersions, input, engine, version) {
|
||||||
if (!engineVersions) {
|
if (!engineVersions) {
|
||||||
throw new Error(`Unknown engine ${engine} (${rubyVersion})`)
|
throw new Error(`Unknown engine ${engine} (input: ${input})`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!engineVersions.includes(version)) {
|
if (!engineVersions.includes(version)) {
|
||||||
engineVersions.reverse() // inplace!
|
const latestToFirstVersion = engineVersions.slice().reverse()
|
||||||
let found = engineVersions.find(v => v.startsWith(version))
|
const found = latestToFirstVersion.find(v => v.startsWith(version))
|
||||||
if (found) {
|
if (found) {
|
||||||
version = found
|
version = found
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unknown version ${version} (${rubyVersion})`)
|
throw new Error(`Unknown version ${version} for ${engine}
|
||||||
|
input: ${input}
|
||||||
|
available versions for ${engine}: ${engineVersions.join(', ')}
|
||||||
|
File an issue at https://github.com/eregon/use-ruby-action/issues if would like support for a new version`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,11 +67,11 @@ async function getRubyEngineAndVersion(rubyVersion) {
|
|||||||
|
|
||||||
function getVirtualEnvironmentName() {
|
function getVirtualEnvironmentName() {
|
||||||
const platform = os.platform()
|
const platform = os.platform()
|
||||||
if (platform == 'linux') {
|
if (platform === 'linux') {
|
||||||
return `ubuntu-${findUbuntuVersion()}`
|
return `ubuntu-${findUbuntuVersion()}`
|
||||||
} else if (platform == 'darwin') {
|
} else if (platform === 'darwin') {
|
||||||
return 'macos-latest'
|
return 'macos-latest'
|
||||||
} else if (platform == 'win32') {
|
} else if (platform === 'win32') {
|
||||||
return 'windows-latest'
|
return 'windows-latest'
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unknown platform ${platform}`)
|
throw new Error(`Unknown platform ${platform}`)
|
||||||
|
|||||||
+3
-2
@@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "use-ruby-action",
|
"name": "use-ruby-action",
|
||||||
"version": "0.1.0",
|
"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",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint index.js",
|
"lint": "eslint *.js",
|
||||||
"package": "ncc build index.js -o dist"
|
"package": "ncc build index.js -o dist"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
"homepage": "https://github.com/eregon/use-ruby-action",
|
"homepage": "https://github.com/eregon/use-ruby-action",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.1.1",
|
"@actions/core": "^1.1.1",
|
||||||
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.1",
|
||||||
"@actions/tool-cache": "^1.1.2",
|
"@actions/tool-cache": "^1.1.2",
|
||||||
"axios": "^0.19.0"
|
"axios": "^0.19.0"
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
const core = require('@actions/core')
|
||||||
|
const io = require('@actions/io')
|
||||||
|
const tc = require('@actions/tool-cache')
|
||||||
|
const axios = require('axios')
|
||||||
|
|
||||||
|
const builderReleaseTag = 'builds-newer-openssl'
|
||||||
|
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
|
||||||
|
const metadataURL = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata'
|
||||||
|
|
||||||
|
export async function getAvailableVersions(engine) {
|
||||||
|
const response = await axios.get(`${metadataURL}/versions.json`)
|
||||||
|
const versions = response.data
|
||||||
|
return versions[engine]
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function install(platform, ruby) {
|
||||||
|
const rubyPrefix = await downloadAndExtract(platform, ruby)
|
||||||
|
core.addPath(`${rubyPrefix}/bin`)
|
||||||
|
return rubyPrefix
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downloadAndExtract(platform, ruby) {
|
||||||
|
const rubiesDir = `${process.env.HOME}/.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 `${rubiesDir}/${ruby}`
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export const versions = {
|
||||||
|
"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"
|
||||||
|
}
|
||||||
+74
@@ -0,0 +1,74 @@
|
|||||||
|
// 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('./ruby-installer-versions').versions
|
||||||
|
|
||||||
|
export async function getAvailableVersions(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 msys2 = await linkMSYS2()
|
||||||
|
const newPath = setupPath(msys2, rubyPrefix)
|
||||||
|
core.exportVariable('PATH', newPath)
|
||||||
|
|
||||||
|
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 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(';')
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user