mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-14 06:54:20 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5ee2364f0 | ||
|
|
8731780d5e | ||
|
|
3882fb634e | ||
|
|
d6ebfae201 | ||
|
|
3325fe2d4e |
@@ -1,7 +1,12 @@
|
|||||||
name: Update the v1 branch when a release is published
|
name: Update the v1 branch when a release is published
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
|
permissions:
|
||||||
|
contents: write # for Git to git push
|
||||||
types: [published]
|
types: [published]
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ on:
|
|||||||
paths-ignore:
|
paths-ignore:
|
||||||
- README.md
|
- README.md
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -98,6 +100,11 @@ jobs:
|
|||||||
- run: bundle exec rake --version
|
- run: bundle exec rake --version
|
||||||
- run: bundle exec rake
|
- run: bundle exec rake
|
||||||
|
|
||||||
|
- name: Test `gem github:` in a Gemfile
|
||||||
|
run: bundle install
|
||||||
|
env:
|
||||||
|
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/gem_from_github.gemfile
|
||||||
|
|
||||||
- name: which ruby, rake
|
- name: which ruby, rake
|
||||||
if: "!startsWith(matrix.os, 'windows')"
|
if: "!startsWith(matrix.os, 'windows')"
|
||||||
run: which -a ruby rake
|
run: which -a ruby rake
|
||||||
|
|||||||
@@ -159,8 +159,8 @@ By default, Bundler is installed as follows:
|
|||||||
|
|
||||||
* If there is a `Gemfile.lock` file (or `$BUNDLE_GEMFILE.lock` or `gems.locked`) with a `BUNDLED WITH` section,
|
* If there is a `Gemfile.lock` file (or `$BUNDLE_GEMFILE.lock` or `gems.locked`) with a `BUNDLED WITH` section,
|
||||||
that version of Bundler will be installed and used.
|
that version of Bundler will be installed and used.
|
||||||
* If the Ruby ships with Bundler (as a default gem), that version is used.
|
* If the Ruby ships with Bundler 2.2+ (as a default gem), that version is used.
|
||||||
* Otherwise, the latest compatible Bundler version is installed (Bundler 2 on Ruby >= 2.4, Bundler 1 on Ruby < 2.4).
|
* Otherwise, the latest compatible Bundler version is installed (Bundler 2 on Ruby >= 2.3, Bundler 1 on Ruby < 2.3).
|
||||||
|
|
||||||
This behavior can be customized, see [action.yml](action.yml) for more details about the `bundler` input.
|
This behavior can be customized, see [action.yml](action.yml) for more details about the `bundler` input.
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -18,8 +18,8 @@ inputs:
|
|||||||
description: |
|
description: |
|
||||||
The version of Bundler to install. Either 'Gemfile.lock' (the default), 'default', 'latest', 'none', or a version number (e.g., 1, 2, 2.1, 2.1.4).
|
The version of Bundler to install. Either 'Gemfile.lock' (the default), 'default', 'latest', 'none', or a version number (e.g., 1, 2, 2.1, 2.1.4).
|
||||||
For 'Gemfile.lock', the version of the BUNDLED WITH section from the Gemfile.lock if it exists. If the file or section does not exist then the same as 'default'.
|
For 'Gemfile.lock', the version of the BUNDLED WITH section from the Gemfile.lock if it exists. If the file or section does not exist then the same as 'default'.
|
||||||
For 'default', the version of Bundler that comes with that Ruby by default is used, or if that Ruby comes without Bundler then the same as 'latest'.
|
For 'default', if the Ruby ships with Bundler 2.2+ as a default gem, that version is used, otherwise the same as 'latest'.
|
||||||
For 'latest', the latest compatible Bundler version is installed (Bundler 2 on Ruby >= 2.4, Bundler 1 on Ruby < 2.4).
|
For 'latest', the latest compatible Bundler version is installed (Bundler 2 on Ruby >= 2.3, Bundler 1 on Ruby < 2.3).
|
||||||
For 'none', nothing is done.
|
For 'none', nothing is done.
|
||||||
bundler-cache:
|
bundler-cache:
|
||||||
description: 'Run "bundle install", and cache the result automatically. Either true or false.'
|
description: 'Run "bundle install", and cache the result automatically. Either true or false.'
|
||||||
|
|||||||
+5
-8
@@ -71,18 +71,15 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
|
|||||||
const floatVersion = common.floatVersion(rubyVersion)
|
const floatVersion = common.floatVersion(rubyVersion)
|
||||||
|
|
||||||
if (bundlerVersion === 'default') {
|
if (bundlerVersion === 'default') {
|
||||||
if (engine === 'ruby' && floatVersion < 3.0 && common.hasBundlerDefaultGem(engine, rubyVersion)) {
|
if (common.isBundler2dot2Default(engine, rubyVersion)) {
|
||||||
// Ruby 2.6 and 2.7 have a old Bundler default gem which does not work well for `gem 'foo', github: 'foo/foo'`:
|
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
|
||||||
|
return '2'
|
||||||
|
} else if (common.hasBundlerDefaultGem(engine, rubyVersion)) {
|
||||||
|
// Those Rubies have a old Bundler default gem < 2.2 which does not work well for `gem 'foo', github: 'foo/foo'`:
|
||||||
// https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304
|
// https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304
|
||||||
// Also, Ruby 2.6 would get Bundler 1 yet Ruby 2.3 - 2.5 get latest Bundler 2 which might be unexpected.
|
// Also, Ruby 2.6 would get Bundler 1 yet Ruby 2.3 - 2.5 get latest Bundler 2 which might be unexpected.
|
||||||
console.log(`Using latest Bundler for ${engine}-${rubyVersion} because the default Bundler gem is too old for that Ruby version`)
|
console.log(`Using latest Bundler for ${engine}-${rubyVersion} because the default Bundler gem is too old for that Ruby version`)
|
||||||
bundlerVersion = 'latest'
|
bundlerVersion = 'latest'
|
||||||
} else if (common.isBundler2Default(engine, rubyVersion)) {
|
|
||||||
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
|
|
||||||
return '2'
|
|
||||||
} else if (common.isBundler1Default(engine, rubyVersion) && engine !== 'ruby') {
|
|
||||||
console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`)
|
|
||||||
return '1'
|
|
||||||
} else {
|
} else {
|
||||||
bundlerVersion = 'latest'
|
bundlerVersion = 'latest'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,18 @@ export function isBundler2Default(engine, rubyVersion) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isBundler2dot2Default(engine, rubyVersion) {
|
||||||
|
if (engine === 'ruby') {
|
||||||
|
return floatVersion(rubyVersion) >= 3.0
|
||||||
|
} else if (engine.startsWith('truffleruby')) {
|
||||||
|
return floatVersion(rubyVersion) >= 22.0
|
||||||
|
} else if (engine === 'jruby') {
|
||||||
|
return floatVersion(rubyVersion) >= 9.3
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function floatVersion(rubyVersion) {
|
export function floatVersion(rubyVersion) {
|
||||||
const match = rubyVersion.match(/^\d+\.\d+/)
|
const match = rubyVersion.match(/^\d+\.\d+/)
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|||||||
+18
-8
@@ -85,18 +85,15 @@ async function installBundler(bundlerVersionInput, rubygemsInputSet, lockFile, p
|
|||||||
const floatVersion = common.floatVersion(rubyVersion)
|
const floatVersion = common.floatVersion(rubyVersion)
|
||||||
|
|
||||||
if (bundlerVersion === 'default') {
|
if (bundlerVersion === 'default') {
|
||||||
if (engine === 'ruby' && floatVersion < 3.0 && common.hasBundlerDefaultGem(engine, rubyVersion)) {
|
if (common.isBundler2dot2Default(engine, rubyVersion)) {
|
||||||
// Ruby 2.6 and 2.7 have a old Bundler default gem which does not work well for `gem 'foo', github: 'foo/foo'`:
|
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
|
||||||
|
return '2'
|
||||||
|
} else if (common.hasBundlerDefaultGem(engine, rubyVersion)) {
|
||||||
|
// Those Rubies have a old Bundler default gem < 2.2 which does not work well for `gem 'foo', github: 'foo/foo'`:
|
||||||
// https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304
|
// https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304
|
||||||
// Also, Ruby 2.6 would get Bundler 1 yet Ruby 2.3 - 2.5 get latest Bundler 2 which might be unexpected.
|
// Also, Ruby 2.6 would get Bundler 1 yet Ruby 2.3 - 2.5 get latest Bundler 2 which might be unexpected.
|
||||||
console.log(`Using latest Bundler for ${engine}-${rubyVersion} because the default Bundler gem is too old for that Ruby version`)
|
console.log(`Using latest Bundler for ${engine}-${rubyVersion} because the default Bundler gem is too old for that Ruby version`)
|
||||||
bundlerVersion = 'latest'
|
bundlerVersion = 'latest'
|
||||||
} else if (common.isBundler2Default(engine, rubyVersion)) {
|
|
||||||
console.log(`Using Bundler 2 shipped with ${engine}-${rubyVersion}`)
|
|
||||||
return '2'
|
|
||||||
} else if (common.isBundler1Default(engine, rubyVersion) && engine !== 'ruby') {
|
|
||||||
console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`)
|
|
||||||
return '1'
|
|
||||||
} else {
|
} else {
|
||||||
bundlerVersion = 'latest'
|
bundlerVersion = 'latest'
|
||||||
}
|
}
|
||||||
@@ -262,6 +259,7 @@ __nccwpck_require__.r(__webpack_exports__);
|
|||||||
/* harmony export */ "hasBundlerDefaultGem": () => (/* binding */ hasBundlerDefaultGem),
|
/* harmony export */ "hasBundlerDefaultGem": () => (/* binding */ hasBundlerDefaultGem),
|
||||||
/* harmony export */ "isBundler1Default": () => (/* binding */ isBundler1Default),
|
/* harmony export */ "isBundler1Default": () => (/* binding */ isBundler1Default),
|
||||||
/* harmony export */ "isBundler2Default": () => (/* binding */ isBundler2Default),
|
/* harmony export */ "isBundler2Default": () => (/* binding */ isBundler2Default),
|
||||||
|
/* harmony export */ "isBundler2dot2Default": () => (/* binding */ isBundler2dot2Default),
|
||||||
/* harmony export */ "floatVersion": () => (/* binding */ floatVersion),
|
/* harmony export */ "floatVersion": () => (/* binding */ floatVersion),
|
||||||
/* harmony export */ "hashFile": () => (/* binding */ hashFile),
|
/* harmony export */ "hashFile": () => (/* binding */ hashFile),
|
||||||
/* harmony export */ "supportedPlatforms": () => (/* binding */ supportedPlatforms),
|
/* harmony export */ "supportedPlatforms": () => (/* binding */ supportedPlatforms),
|
||||||
@@ -357,6 +355,18 @@ function isBundler2Default(engine, rubyVersion) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isBundler2dot2Default(engine, rubyVersion) {
|
||||||
|
if (engine === 'ruby') {
|
||||||
|
return floatVersion(rubyVersion) >= 3.0
|
||||||
|
} else if (engine.startsWith('truffleruby')) {
|
||||||
|
return floatVersion(rubyVersion) >= 22.0
|
||||||
|
} else if (engine === 'jruby') {
|
||||||
|
return floatVersion(rubyVersion) >= 9.3
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function floatVersion(rubyVersion) {
|
function floatVersion(rubyVersion) {
|
||||||
const match = rubyVersion.match(/^\d+\.\d+/)
|
const match = rubyVersion.match(/^\d+\.\d+/)
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
# Ruby < 2.3 only support Bundler 1, which no longer works with gem github:
|
||||||
|
if RUBY_VERSION >= '2.3'
|
||||||
|
unless Gem::Version.new(Bundler::VERSION) >= Gem::Version.new("2.2.0")
|
||||||
|
raise "Expected Bundler 2.2+ is used on Ruby >= 2.3"
|
||||||
|
end
|
||||||
|
|
||||||
|
# From https://github.com/ruby/setup-ruby/issues/358#issuecomment-1195899304
|
||||||
|
# Tests using github: and the repository uses a non-master default branch.
|
||||||
|
gem 'rack-test', github: 'rack/rack-test'
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user