@@ -5,6 +5,8 @@ const exec = require('@actions/exec')
55const cache = require ( '@actions/cache' )
66const common = require ( './common' )
77
8+ export const DEFAULT_CACHE_VERSION = '0'
9+
810// The returned gemfile is guaranteed to exist, the lockfile might not exist
911export function detectGemfiles ( ) {
1012 const gemfilePath = process . env [ 'BUNDLE_GEMFILE' ] || 'Gemfile'
@@ -95,7 +97,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
9597 return bundlerVersion
9698}
9799
98- export async function bundleInstall ( gemfile , lockFile , platform , engine , rubyVersion , bundlerVersion ) {
100+ export async function bundleInstall ( gemfile , lockFile , platform , engine , rubyVersion , bundlerVersion , cacheVersion ) {
99101 if ( gemfile === null ) {
100102 console . log ( 'Could not determine gemfile path, skipping "bundle install" and caching' )
101103 return false
@@ -128,7 +130,7 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
128130
129131 // cache key
130132 const paths = [ cachePath ]
131- const baseKey = await computeBaseKey ( platform , engine , rubyVersion , lockFile )
133+ const baseKey = await computeBaseKey ( platform , engine , rubyVersion , lockFile , cacheVersion )
132134 const key = `${ baseKey } -${ await common . hashFile ( lockFile ) } `
133135 // If only Gemfile.lock changes we can reuse part of the cache, and clean old gem versions below
134136 const restoreKeys = [ `${ baseKey } -` ]
@@ -177,8 +179,9 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
177179 return true
178180}
179181
180- async function computeBaseKey ( platform , engine , version , lockFile ) {
181- let key = `setup-ruby-bundler-cache-v3-${ platform } -${ engine } -${ version } `
182+ async function computeBaseKey ( platform , engine , version , lockFile , cacheVersion ) {
183+ const cacheVersionSuffix = DEFAULT_CACHE_VERSION === cacheVersion ? '' : `-cachever:${ cacheVersion } `
184+ let key = `setup-ruby-bundler-cache-v3-${ platform } -${ engine } -${ version } ${ cacheVersionSuffix } `
182185
183186 if ( engine !== 'jruby' && common . isHeadVersion ( version ) ) {
184187 let revision = '' ;
0 commit comments