mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 14:34:21 +02:00
Tweak rubygems input behavior
When a fixed version is passed, it should be the minimum RubyGems version for the whole matrix, i.e., RubyGems should not be dowgraded past the default version of the oldest Ruby in the matrix.
This commit is contained in:
committed by
Benoit Daloze
parent
578365d08b
commit
8781aa98b4
@@ -123,16 +123,27 @@ jobs:
|
|||||||
rubygems: latest
|
rubygems: latest
|
||||||
- run: ruby -e "exit(Gem.rubygems_version > Gem::Version.new('3.0.3'))"
|
- run: ruby -e "exit(Gem.rubygems_version > Gem::Version.new('3.0.3'))"
|
||||||
|
|
||||||
testFixedRubygemsVersion:
|
testFixedRubygemsVersionUpgrades:
|
||||||
name: "Test rubygems input set to a fixed version upgrades RubyGems to that versoin"
|
name: "Test rubygems input set to a fixed version upgrades RubyGems to that version if the default is older"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
ruby-version: 2.6
|
ruby-version: 2.6
|
||||||
rubygems: 3.3.5
|
rubygems: 3.2.3
|
||||||
- run: gem --version | grep -F "3.3.5"
|
- run: gem --version | grep -F "3.2.3"
|
||||||
|
|
||||||
|
testFixedRubygemsVersionNoop:
|
||||||
|
name: "Test rubygems input set to a fixed version noops if the default is newer"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ./
|
||||||
|
with:
|
||||||
|
ruby-version: 3.1
|
||||||
|
rubygems: 3.2.3
|
||||||
|
- run: gem --version | grep -F "3.3.3"
|
||||||
|
|
||||||
testExactBundlerVersion:
|
testExactBundlerVersion:
|
||||||
name: "Test with an exact Bundler version"
|
name: "Test with an exact Bundler version"
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ inputs:
|
|||||||
The version of RubyGems to use. Either 'default', 'latest', or a version number (e.g., 3.3.5).
|
The version of RubyGems to use. Either 'default', 'latest', or a version number (e.g., 3.3.5).
|
||||||
For 'default', no action is taken and the version of RubyGems that comes with Ruby by default is used.
|
For 'default', no action is taken and the version of RubyGems that comes with Ruby by default is used.
|
||||||
For 'latest', `gem update --system` is run to update to the latest RubyGems version.
|
For 'latest', `gem update --system` is run to update to the latest RubyGems version.
|
||||||
Similarly, if a version number is given, `gem update --system <version>` is run to update to that version of RubyGems.
|
Similarly, if a version number is given, `gem update --system <version>` is run to update to that version of RubyGems, as long as that version is newer than the one provided by default.
|
||||||
Defaults to 'default'.
|
Defaults to 'default'.
|
||||||
bundler:
|
bundler:
|
||||||
description: |
|
description: |
|
||||||
|
|||||||
+21
-2
@@ -58965,12 +58965,31 @@ __nccwpck_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ });
|
/* harmony export */ });
|
||||||
const path = __nccwpck_require__(5622)
|
const path = __nccwpck_require__(5622)
|
||||||
const exec = __nccwpck_require__(1514)
|
const exec = __nccwpck_require__(1514)
|
||||||
|
const semver = __nccwpck_require__(5911)
|
||||||
|
|
||||||
async function rubygemsUpdate(rubygemsVersionInput, rubyPrefix) {
|
async function rubygemsUpdate(rubygemsVersionInput, rubyPrefix) {
|
||||||
const gem = path.join(rubyPrefix, 'bin', 'gem')
|
const gem = path.join(rubyPrefix, 'bin', 'gem')
|
||||||
const rubygemsVersion = (rubygemsVersionInput === 'latest') ? [] : [rubygemsVersionInput]
|
|
||||||
|
|
||||||
await exec.exec(gem, ['update', '--system', ...rubygemsVersion])
|
let gemVersion = ''
|
||||||
|
|
||||||
|
await exec.exec(gem, ['--version'], {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data) => (gemVersion += data.toString()),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gemVersion = semver.coerce(gemVersion.trim())
|
||||||
|
console.log(`Default RubyGems version is ${gemVersion}`)
|
||||||
|
|
||||||
|
if (rubygemsVersionInput === 'latest') {
|
||||||
|
console.log('Updating RubyGems to latest version')
|
||||||
|
await exec.exec(gem, ['update', '--system'])
|
||||||
|
} else if (semver.gt(rubygemsVersionInput, gemVersion)) {
|
||||||
|
console.log(`Updating RubyGems to ${rubygemsVersionInput}`)
|
||||||
|
await exec.exec(gem, ['update', '--system', rubygemsVersionInput])
|
||||||
|
} else {
|
||||||
|
console.log(`Skipping RubyGems update because the given version (${rubygemsVersionInput}) is not newer than the default version (${gemVersion})`)
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -26,7 +26,8 @@
|
|||||||
"@actions/core": "^1.4.0",
|
"@actions/core": "^1.4.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/io": "^1.1.1",
|
"@actions/io": "^1.1.1",
|
||||||
"@actions/tool-cache": "^1.7.1"
|
"@actions/tool-cache": "^1.7.1",
|
||||||
|
"semver": "^6.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.31.1"
|
"@vercel/ncc": "^0.31.1"
|
||||||
|
|||||||
+21
-2
@@ -1,11 +1,30 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const exec = require('@actions/exec')
|
const exec = require('@actions/exec')
|
||||||
|
const semver = require('semver')
|
||||||
|
|
||||||
export async function rubygemsUpdate(rubygemsVersionInput, rubyPrefix) {
|
export async function rubygemsUpdate(rubygemsVersionInput, rubyPrefix) {
|
||||||
const gem = path.join(rubyPrefix, 'bin', 'gem')
|
const gem = path.join(rubyPrefix, 'bin', 'gem')
|
||||||
const rubygemsVersion = (rubygemsVersionInput === 'latest') ? [] : [rubygemsVersionInput]
|
|
||||||
|
|
||||||
await exec.exec(gem, ['update', '--system', ...rubygemsVersion])
|
let gemVersion = ''
|
||||||
|
|
||||||
|
await exec.exec(gem, ['--version'], {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data) => (gemVersion += data.toString()),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gemVersion = semver.coerce(gemVersion.trim())
|
||||||
|
console.log(`Default RubyGems version is ${gemVersion}`)
|
||||||
|
|
||||||
|
if (rubygemsVersionInput === 'latest') {
|
||||||
|
console.log('Updating RubyGems to latest version')
|
||||||
|
await exec.exec(gem, ['update', '--system'])
|
||||||
|
} else if (semver.gt(rubygemsVersionInput, gemVersion)) {
|
||||||
|
console.log(`Updating RubyGems to ${rubygemsVersionInput}`)
|
||||||
|
await exec.exec(gem, ['update', '--system', rubygemsVersionInput])
|
||||||
|
} else {
|
||||||
|
console.log(`Skipping RubyGems update because the given version (${rubygemsVersionInput}) is not newer than the default version (${gemVersion})`)
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user