mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 22:44:20 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad1ebae995 | ||
|
|
f4a8aa6c33 | ||
|
|
bc0f274d1c | ||
|
|
1c896c8ea1 |
@@ -36,27 +36,33 @@ export async function hashFile(file) {
|
|||||||
return hash.digest('hex')
|
return hash.digest('hex')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVirtualEnvironmentName() {
|
function getImageOS() {
|
||||||
const platform = os.platform()
|
const imageOS = process.env['ImageOS']
|
||||||
if (platform === 'linux') {
|
if (!imageOS) {
|
||||||
return `ubuntu-${findUbuntuVersion()}`
|
throw new Error('The environment variable ImageOS must be set')
|
||||||
} else if (platform === 'darwin') {
|
|
||||||
return 'macos-latest'
|
|
||||||
} else if (platform === 'win32') {
|
|
||||||
return 'windows-latest'
|
|
||||||
} else {
|
|
||||||
throw new Error(`Unknown platform ${platform}`)
|
|
||||||
}
|
}
|
||||||
|
return imageOS
|
||||||
}
|
}
|
||||||
|
|
||||||
function findUbuntuVersion() {
|
export function getVirtualEnvironmentName() {
|
||||||
const lsb_release = fs.readFileSync('/etc/lsb-release', 'utf8')
|
const imageOS = getImageOS()
|
||||||
const match = lsb_release.match(/^DISTRIB_RELEASE=(\d+\.\d+)$/m)
|
|
||||||
|
let match = imageOS.match(/^ubuntu(\d+)/) // e.g. ubuntu18
|
||||||
if (match) {
|
if (match) {
|
||||||
return match[1]
|
return `ubuntu-${match[1]}.04`
|
||||||
} else {
|
|
||||||
throw new Error('Could not find Ubuntu version')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match = imageOS.match(/^macos(\d{2})(\d+)/) // e.g. macos1015
|
||||||
|
if (match) {
|
||||||
|
return `macos-${match[1]}.${match[2]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
match = imageOS.match(/^win(\d+)/) // e.g. win19
|
||||||
|
if (match) {
|
||||||
|
return `windows-20${match[1]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(`Unknown ImageOS ${imageOS}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function shouldExtractInToolCache(engine, version) {
|
export function shouldExtractInToolCache(engine, version) {
|
||||||
|
|||||||
+64
-61
@@ -32140,27 +32140,33 @@ async function hashFile(file) {
|
|||||||
return hash.digest('hex')
|
return hash.digest('hex')
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVirtualEnvironmentName() {
|
function getImageOS() {
|
||||||
const platform = os.platform()
|
const imageOS = process.env['ImageOS']
|
||||||
if (platform === 'linux') {
|
if (!imageOS) {
|
||||||
return `ubuntu-${findUbuntuVersion()}`
|
throw new Error('The environment variable ImageOS must be set')
|
||||||
} else if (platform === 'darwin') {
|
|
||||||
return 'macos-latest'
|
|
||||||
} else if (platform === 'win32') {
|
|
||||||
return 'windows-latest'
|
|
||||||
} else {
|
|
||||||
throw new Error(`Unknown platform ${platform}`)
|
|
||||||
}
|
}
|
||||||
|
return imageOS
|
||||||
}
|
}
|
||||||
|
|
||||||
function findUbuntuVersion() {
|
function getVirtualEnvironmentName() {
|
||||||
const lsb_release = fs.readFileSync('/etc/lsb-release', 'utf8')
|
const imageOS = getImageOS()
|
||||||
const match = lsb_release.match(/^DISTRIB_RELEASE=(\d+\.\d+)$/m)
|
|
||||||
|
let match = imageOS.match(/^ubuntu(\d+)/) // e.g. ubuntu18
|
||||||
if (match) {
|
if (match) {
|
||||||
return match[1]
|
return `ubuntu-${match[1]}.04`
|
||||||
} else {
|
|
||||||
throw new Error('Could not find Ubuntu version')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
match = imageOS.match(/^macos(\d{2})(\d+)/) // e.g. macos1015
|
||||||
|
if (match) {
|
||||||
|
return `macos-${match[1]}.${match[2]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
match = imageOS.match(/^win(\d+)/) // e.g. win19
|
||||||
|
if (match) {
|
||||||
|
return `windows-20${match[1]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(`Unknown ImageOS ${imageOS}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldExtractInToolCache(engine, version) {
|
function shouldExtractInToolCache(engine, version) {
|
||||||
@@ -51227,25 +51233,15 @@ async function setupRuby(options = {}) {
|
|||||||
core.setOutput('ruby-prefix', rubyPrefix)
|
core.setOutput('ruby-prefix', rubyPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The returned gemfile is guaranteed to exist, the lockfile might not exist
|
||||||
function detectGemfiles() {
|
function detectGemfiles() {
|
||||||
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
|
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
|
||||||
if (fs.existsSync(gemfilePath)) {
|
if (fs.existsSync(gemfilePath)) {
|
||||||
const lockPath = `${gemfilePath}.lock`
|
return [gemfilePath, `${gemfilePath}.lock`]
|
||||||
if (fs.existsSync(lockPath)) {
|
|
||||||
return [gemfilePath, lockPath]
|
|
||||||
} else {
|
|
||||||
return [gemfilePath, null]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const gemsRbPath = "gems.rb"
|
if (fs.existsSync("gems.rb")) {
|
||||||
if (fs.existsSync(gemsRbPath)) {
|
return ["gems.rb", "gems.locked"]
|
||||||
const lockPath = "gems.locked"
|
|
||||||
if (fs.existsSync(lockPath)) {
|
|
||||||
return [gemsRbPath, lockPath]
|
|
||||||
} else {
|
|
||||||
return [gemsRbPath, null]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [null, null]
|
return [null, null]
|
||||||
@@ -51329,7 +51325,7 @@ function envPreInstall() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readBundledWithFromGemfileLock(lockFile) {
|
function readBundledWithFromGemfileLock(lockFile) {
|
||||||
if (lockFile !== null) {
|
if (lockFile !== null && fs.existsSync(lockFile)) {
|
||||||
const contents = fs.readFileSync(lockFile, 'utf8')
|
const contents = fs.readFileSync(lockFile, 'utf8')
|
||||||
const lines = contents.split(/\r?\n/)
|
const lines = contents.split(/\r?\n/)
|
||||||
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
||||||
@@ -51367,12 +51363,15 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
|
|||||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rubyVersion.match(/^2\.[12]/)) {
|
if (engine === 'ruby' && rubyVersion.match(/^2\.[12]/)) {
|
||||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2')
|
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2')
|
||||||
bundlerVersion = '1'
|
bundlerVersion = '1'
|
||||||
} else if (rubyVersion.startsWith('2.3')) {
|
} else if (engine === 'ruby' && rubyVersion.startsWith('2.3')) {
|
||||||
console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3')
|
console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3')
|
||||||
bundlerVersion = '1'
|
bundlerVersion = '1'
|
||||||
|
} else if (engine === 'jruby' && rubyVersion.startsWith('9.1.')) { // JRuby 9.1 targets Ruby 2.3, treat it the same
|
||||||
|
console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1')
|
||||||
|
bundlerVersion = '1'
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((engine === 'ruby' || engine === 'truffleruby') && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
if ((engine === 'ruby' || engine === 'truffleruby') && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
||||||
@@ -51394,24 +51393,22 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
|
|||||||
// config
|
// config
|
||||||
const path = 'vendor/bundle'
|
const path = 'vendor/bundle'
|
||||||
|
|
||||||
if (lockFile !== null) {
|
|
||||||
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
|
|
||||||
}
|
|
||||||
await exec.exec('bundle', ['config', '--local', 'path', path])
|
await exec.exec('bundle', ['config', '--local', 'path', path])
|
||||||
|
|
||||||
|
if (fs.existsSync(lockFile)) {
|
||||||
|
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
|
||||||
|
} else {
|
||||||
|
// Generate the lockfile so we can use it to compute the cache key.
|
||||||
|
// This will also automatically pick up the latest gem versions compatible with the Gemfile.
|
||||||
|
await exec.exec('bundle', ['lock'])
|
||||||
|
}
|
||||||
|
|
||||||
// cache key
|
// cache key
|
||||||
const paths = [path]
|
const paths = [path]
|
||||||
const baseKey = await computeBaseKey(platform, engine, version, gemfile)
|
const baseKey = await computeBaseKey(platform, engine, version, lockFile)
|
||||||
let key = baseKey
|
const key = `${baseKey}-${await common.hashFile(lockFile)}`
|
||||||
let restoreKeys
|
// If only Gemfile.lock changes we can reuse part of the cache (but it will keep old gem versions in the cache)
|
||||||
if (lockFile !== null) {
|
const restoreKeys = [`${baseKey}-`]
|
||||||
key += `-${lockFile}-${await common.hashFile(lockFile)}`
|
|
||||||
// If only Gemfile.lock changes we can reuse part of the cache (but it will keep old gem versions in the cache)
|
|
||||||
restoreKeys = [`${baseKey}-${lockFile}-`]
|
|
||||||
} else {
|
|
||||||
// Only exact key, to never mix native gems of different platforms or Ruby versions
|
|
||||||
restoreKeys = []
|
|
||||||
}
|
|
||||||
console.log(`Cache key: ${key}`)
|
console.log(`Cache key: ${key}`)
|
||||||
|
|
||||||
// restore cache & install
|
// restore cache & install
|
||||||
@@ -51430,15 +51427,11 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
|
|||||||
console.log(`Found cache for key: ${cachedKey}`)
|
console.log(`Found cache for key: ${cachedKey}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let alreadyInstalled = false
|
// Always run 'bundle install' to list the gems
|
||||||
if (cachedKey === key) {
|
await exec.exec('bundle', ['install', '--jobs', '4'])
|
||||||
const exitCode = await exec.exec('bundle', ['check'], { ignoreReturnCode: true })
|
|
||||||
alreadyInstalled = (exitCode === 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!alreadyInstalled) {
|
|
||||||
await exec.exec('bundle', ['install', '--jobs', '4'])
|
|
||||||
|
|
||||||
|
// @actions/cache only allows to save for non-existing keys
|
||||||
|
if (cachedKey !== key) {
|
||||||
// Error handling from https://github.com/actions/cache/blob/master/src/save.ts
|
// Error handling from https://github.com/actions/cache/blob/master/src/save.ts
|
||||||
console.log('Saving cache')
|
console.log('Saving cache')
|
||||||
try {
|
try {
|
||||||
@@ -51457,8 +51450,9 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function computeBaseKey(platform, engine, version, gemfile) {
|
async function computeBaseKey(platform, engine, version, lockFile) {
|
||||||
let baseKey = `setup-ruby-toolcache-bundle-install-${platform}-${engine}-${version}-${gemfile}`
|
let key = `setup-ruby-bundler-cache-v2-${platform}-${engine}-${version}`
|
||||||
|
|
||||||
if (engine !== 'jruby' && common.isHeadVersion(version)) {
|
if (engine !== 'jruby' && common.isHeadVersion(version)) {
|
||||||
let revision = '';
|
let revision = '';
|
||||||
await exec.exec('ruby', ['-e', 'print RUBY_REVISION'], {
|
await exec.exec('ruby', ['-e', 'print RUBY_REVISION'], {
|
||||||
@@ -51469,9 +51463,11 @@ async function computeBaseKey(platform, engine, version, gemfile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
baseKey += `-revision-${revision}`
|
key += `-revision-${revision}`
|
||||||
}
|
}
|
||||||
return baseKey
|
|
||||||
|
key += `-${lockFile}`
|
||||||
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__filename.endsWith('index.js')) { run() }
|
if (__filename.endsWith('index.js')) { run() }
|
||||||
@@ -52945,10 +52941,17 @@ async function downloadAndExtract(platform, engine, version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDownloadURL(platform, engine, version) {
|
function getDownloadURL(platform, engine, version) {
|
||||||
|
let builderPlatform = platform
|
||||||
|
if (platform.startsWith('windows-')) {
|
||||||
|
builderPlatform = 'windows-latest'
|
||||||
|
} else if (platform.startsWith('macos-')) {
|
||||||
|
builderPlatform = 'macos-latest'
|
||||||
|
}
|
||||||
|
|
||||||
if (common.isHeadVersion(version)) {
|
if (common.isHeadVersion(version)) {
|
||||||
return getLatestHeadBuildURL(platform, engine, version)
|
return getLatestHeadBuildURL(builderPlatform, engine, version)
|
||||||
} else {
|
} else {
|
||||||
return `${releasesURL}/download/${builderReleaseTag}/${engine}-${version}-${platform}.tar.gz`
|
return `${releasesURL}/download/${builderReleaseTag}/${engine}-${version}-${builderPlatform}.tar.gz`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,25 +75,15 @@ export async function setupRuby(options = {}) {
|
|||||||
core.setOutput('ruby-prefix', rubyPrefix)
|
core.setOutput('ruby-prefix', rubyPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The returned gemfile is guaranteed to exist, the lockfile might not exist
|
||||||
function detectGemfiles() {
|
function detectGemfiles() {
|
||||||
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
|
const gemfilePath = process.env['BUNDLE_GEMFILE'] || 'Gemfile'
|
||||||
if (fs.existsSync(gemfilePath)) {
|
if (fs.existsSync(gemfilePath)) {
|
||||||
const lockPath = `${gemfilePath}.lock`
|
return [gemfilePath, `${gemfilePath}.lock`]
|
||||||
if (fs.existsSync(lockPath)) {
|
|
||||||
return [gemfilePath, lockPath]
|
|
||||||
} else {
|
|
||||||
return [gemfilePath, null]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const gemsRbPath = "gems.rb"
|
if (fs.existsSync("gems.rb")) {
|
||||||
if (fs.existsSync(gemsRbPath)) {
|
return ["gems.rb", "gems.locked"]
|
||||||
const lockPath = "gems.locked"
|
|
||||||
if (fs.existsSync(lockPath)) {
|
|
||||||
return [gemsRbPath, lockPath]
|
|
||||||
} else {
|
|
||||||
return [gemsRbPath, null]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [null, null]
|
return [null, null]
|
||||||
@@ -177,7 +167,7 @@ function envPreInstall() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function readBundledWithFromGemfileLock(lockFile) {
|
function readBundledWithFromGemfileLock(lockFile) {
|
||||||
if (lockFile !== null) {
|
if (lockFile !== null && fs.existsSync(lockFile)) {
|
||||||
const contents = fs.readFileSync(lockFile, 'utf8')
|
const contents = fs.readFileSync(lockFile, 'utf8')
|
||||||
const lines = contents.split(/\r?\n/)
|
const lines = contents.split(/\r?\n/)
|
||||||
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
|
||||||
@@ -215,12 +205,15 @@ async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefi
|
|||||||
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
throw new Error(`Cannot parse bundler input: ${bundlerVersion}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rubyVersion.match(/^2\.[12]/)) {
|
if (engine === 'ruby' && rubyVersion.match(/^2\.[12]/)) {
|
||||||
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2')
|
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2')
|
||||||
bundlerVersion = '1'
|
bundlerVersion = '1'
|
||||||
} else if (rubyVersion.startsWith('2.3')) {
|
} else if (engine === 'ruby' && rubyVersion.startsWith('2.3')) {
|
||||||
console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3')
|
console.log('Ruby 2.3 has a bug with Bundler 2 (https://github.com/rubygems/rubygems/issues/3570), using Bundler 1 instead on Ruby 2.3')
|
||||||
bundlerVersion = '1'
|
bundlerVersion = '1'
|
||||||
|
} else if (engine === 'jruby' && rubyVersion.startsWith('9.1.')) { // JRuby 9.1 targets Ruby 2.3, treat it the same
|
||||||
|
console.log('JRuby 9.1 has a bug with Bundler 2 (https://github.com/ruby/setup-ruby/issues/108), using Bundler 1 instead on JRuby 9.1')
|
||||||
|
bundlerVersion = '1'
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((engine === 'ruby' || engine === 'truffleruby') && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
if ((engine === 'ruby' || engine === 'truffleruby') && common.isHeadVersion(rubyVersion) && bundlerVersion === '2') {
|
||||||
@@ -242,24 +235,22 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
|
|||||||
// config
|
// config
|
||||||
const path = 'vendor/bundle'
|
const path = 'vendor/bundle'
|
||||||
|
|
||||||
if (lockFile !== null) {
|
|
||||||
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
|
|
||||||
}
|
|
||||||
await exec.exec('bundle', ['config', '--local', 'path', path])
|
await exec.exec('bundle', ['config', '--local', 'path', path])
|
||||||
|
|
||||||
|
if (fs.existsSync(lockFile)) {
|
||||||
|
await exec.exec('bundle', ['config', '--local', 'deployment', 'true'])
|
||||||
|
} else {
|
||||||
|
// Generate the lockfile so we can use it to compute the cache key.
|
||||||
|
// This will also automatically pick up the latest gem versions compatible with the Gemfile.
|
||||||
|
await exec.exec('bundle', ['lock'])
|
||||||
|
}
|
||||||
|
|
||||||
// cache key
|
// cache key
|
||||||
const paths = [path]
|
const paths = [path]
|
||||||
const baseKey = await computeBaseKey(platform, engine, version, gemfile)
|
const baseKey = await computeBaseKey(platform, engine, version, lockFile)
|
||||||
let key = baseKey
|
const key = `${baseKey}-${await common.hashFile(lockFile)}`
|
||||||
let restoreKeys
|
// If only Gemfile.lock changes we can reuse part of the cache (but it will keep old gem versions in the cache)
|
||||||
if (lockFile !== null) {
|
const restoreKeys = [`${baseKey}-`]
|
||||||
key += `-${lockFile}-${await common.hashFile(lockFile)}`
|
|
||||||
// If only Gemfile.lock changes we can reuse part of the cache (but it will keep old gem versions in the cache)
|
|
||||||
restoreKeys = [`${baseKey}-${lockFile}-`]
|
|
||||||
} else {
|
|
||||||
// Only exact key, to never mix native gems of different platforms or Ruby versions
|
|
||||||
restoreKeys = []
|
|
||||||
}
|
|
||||||
console.log(`Cache key: ${key}`)
|
console.log(`Cache key: ${key}`)
|
||||||
|
|
||||||
// restore cache & install
|
// restore cache & install
|
||||||
@@ -278,15 +269,11 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
|
|||||||
console.log(`Found cache for key: ${cachedKey}`)
|
console.log(`Found cache for key: ${cachedKey}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let alreadyInstalled = false
|
// Always run 'bundle install' to list the gems
|
||||||
if (cachedKey === key) {
|
await exec.exec('bundle', ['install', '--jobs', '4'])
|
||||||
const exitCode = await exec.exec('bundle', ['check'], { ignoreReturnCode: true })
|
|
||||||
alreadyInstalled = (exitCode === 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!alreadyInstalled) {
|
|
||||||
await exec.exec('bundle', ['install', '--jobs', '4'])
|
|
||||||
|
|
||||||
|
// @actions/cache only allows to save for non-existing keys
|
||||||
|
if (cachedKey !== key) {
|
||||||
// Error handling from https://github.com/actions/cache/blob/master/src/save.ts
|
// Error handling from https://github.com/actions/cache/blob/master/src/save.ts
|
||||||
console.log('Saving cache')
|
console.log('Saving cache')
|
||||||
try {
|
try {
|
||||||
@@ -305,8 +292,9 @@ async function bundleInstall(gemfile, lockFile, platform, engine, version) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function computeBaseKey(platform, engine, version, gemfile) {
|
async function computeBaseKey(platform, engine, version, lockFile) {
|
||||||
let baseKey = `setup-ruby-toolcache-bundle-install-${platform}-${engine}-${version}-${gemfile}`
|
let key = `setup-ruby-bundler-cache-v2-${platform}-${engine}-${version}`
|
||||||
|
|
||||||
if (engine !== 'jruby' && common.isHeadVersion(version)) {
|
if (engine !== 'jruby' && common.isHeadVersion(version)) {
|
||||||
let revision = '';
|
let revision = '';
|
||||||
await exec.exec('ruby', ['-e', 'print RUBY_REVISION'], {
|
await exec.exec('ruby', ['-e', 'print RUBY_REVISION'], {
|
||||||
@@ -317,9 +305,11 @@ async function computeBaseKey(platform, engine, version, gemfile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
baseKey += `-revision-${revision}`
|
key += `-revision-${revision}`
|
||||||
}
|
}
|
||||||
return baseKey
|
|
||||||
|
key += `-${lockFile}`
|
||||||
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__filename.endsWith('index.js')) { run() }
|
if (__filename.endsWith('index.js')) { run() }
|
||||||
|
|||||||
+9
-2
@@ -57,10 +57,17 @@ async function downloadAndExtract(platform, engine, version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDownloadURL(platform, engine, version) {
|
function getDownloadURL(platform, engine, version) {
|
||||||
|
let builderPlatform = platform
|
||||||
|
if (platform.startsWith('windows-')) {
|
||||||
|
builderPlatform = 'windows-latest'
|
||||||
|
} else if (platform.startsWith('macos-')) {
|
||||||
|
builderPlatform = 'macos-latest'
|
||||||
|
}
|
||||||
|
|
||||||
if (common.isHeadVersion(version)) {
|
if (common.isHeadVersion(version)) {
|
||||||
return getLatestHeadBuildURL(platform, engine, version)
|
return getLatestHeadBuildURL(builderPlatform, engine, version)
|
||||||
} else {
|
} else {
|
||||||
return `${releasesURL}/download/${builderReleaseTag}/${engine}-${version}-${platform}.tar.gz`
|
return `${releasesURL}/download/${builderReleaseTag}/${engine}-${version}-${builderPlatform}.tar.gz`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user