Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ jobs:
rubygems: 3.2.3
- run: gem --version | grep -F "3.3.3"

testMajorBundlerVersion:
name: "Test with a major Bundler version"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./
with:
ruby-version: 2.6
bundler: 2
- run: bundle --version | grep -P "Bundler version 2\.\d+\.\d+"

testMinorBundlerVersion:
name: "Test with a minor Bundler version"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./
with:
ruby-version: 2.6
bundler: 2.2
- run: bundle --version | grep -P "Bundler version 2\.2\.\d+"

testExactBundlerVersion:
name: "Test with an exact Bundler version"
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inputs:
Defaults to 'default'.
bundler:
description: |
The version of Bundler to install. Either 'none', 'latest', 'Gemfile.lock', or a version number (e.g., 1, 2, 2.1.4).
The version of Bundler to install. Either 'none', 'latest', 'Gemfile.lock', or a version number (e.g., 1, 2, 2.1, 2.1.4).
For 'Gemfile.lock', the version is determined based on the BUNDLED WITH section from the file Gemfile.lock, $BUNDLE_GEMFILE.lock or gems.locked.
Defaults to 'Gemfile.lock' if the file exists and 'latest' otherwise.
required: false
Expand Down
9 changes: 6 additions & 3 deletions bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
bundlerVersion = '2'
}

if (/^\d+/.test(bundlerVersion)) {
// OK
if (/^\d+(?:\.\d+){0,2}$/.test(bundlerVersion)) {
// OK - input is a 1, 2, or 3 part version number
} else {
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
}
Expand Down Expand Up @@ -95,9 +95,12 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`)
} else {
const gem = path.join(rubyPrefix, 'bin', 'gem')
const bundlerVersionConstraint = /^\d+\.\d+\.\d+/.test(bundlerVersion) ? bundlerVersion : `~> ${bundlerVersion}`
// Workaround for https://github.com/rubygems/rubygems/issues/5245
const force = (platform.startsWith('windows-') && engine === 'ruby' && floatVersion >= 3.1) ? ['--force'] : []

const versionParts = [...bundlerVersion.matchAll(/\d+/g)].length
const bundlerVersionConstraint = versionParts === 3 ? bundlerVersion : `~> ${bundlerVersion}.0`

await exec.exec(gem, ['install', 'bundler', ...force, '-v', bundlerVersionConstraint])
}

Expand Down
9 changes: 6 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.