Automatically find the latest stable version

This commit is contained in:
Benoit Daloze
2020-01-02 16:15:42 +01:00
parent ec43599b3f
commit 3f99912f55
6 changed files with 3317 additions and 10 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ jobs:
fail-fast: false
matrix:
os: [ 'ubuntu-16.04', 'ubuntu-18.04', 'macos-latest' ]
ruby: [ 'ruby-2.6.5', 'ruby-2.7.0', 'truffleruby-19.3.0', 'jruby-9.2.9.0' ]
ruby: [ 'ruby-2.6.5', '2.7.0', 'truffleruby', 'jruby-9.2.9.0' ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
+4
View File
@@ -46,6 +46,10 @@ jobs:
- run: ruby -v
```
If a specific version is not given, it uses the latest stable release of that implementation.
For instance `truffleruby` is currently the same as `truffleruby-19.3.0`.
## Efficiency
It takes about 5 seconds to setup the given Ruby.
Generated Vendored
+3263 -4
View File
File diff suppressed because it is too large Load Diff
+12 -4
View File
@@ -1,16 +1,24 @@
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 os = require('os')
const fs = require('fs')
const axios = require('axios')
async function run() {
try {
const rubyVersion = core.getInput('ruby-version')
let ruby = rubyVersion
if (!ruby.includes('-')) {
ruby = 'ruby-' + ruby;
if (ruby.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
ruby = 'ruby-' + ruby
}
if (!ruby.includes('-')) { // myruby -> myruby-stableVersion
const versionsUrl = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata/versions.json'
const response = await axios.get(versionsUrl)
const stableVersions = response.data[ruby]
const latestStableVersion = stableVersions[stableVersions.length-1]
ruby = ruby + '-' + latestStableVersion
}
const rubiesDir = `${process.env.HOME}/.rubies`
+35
View File
@@ -122,6 +122,15 @@
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
"dev": true
},
"axios": {
"version": "0.19.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
"integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
"requires": {
"follow-redirects": "1.5.10",
"is-buffer": "^2.0.2"
}
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
@@ -210,6 +219,14 @@
"which": "^1.2.9"
}
},
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"deep-is": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
@@ -454,6 +471,14 @@
"integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==",
"dev": true
},
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
"requires": {
"debug": "=3.1.0"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@@ -606,6 +631,11 @@
}
}
},
"is-buffer": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
"integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
},
"is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -723,6 +753,11 @@
}
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"mute-stream": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
+2 -1
View File
@@ -25,7 +25,8 @@
"dependencies": {
"@actions/core": "^1.1.1",
"@actions/io": "^1.0.1",
"@actions/tool-cache": "^1.1.2"
"@actions/tool-cache": "^1.1.2",
"axios": "^0.19.0"
},
"devDependencies": {
"@zeit/ncc": "^0.20.5",