@@ -28,7 +28,7 @@ inputs:
2828 ruby-version :
2929 description : Ruby version to use (only for iOS)
3030 required : false
31- default : ' 3.1 '
31+ default : ' 3.2 '
3232 xcode-version :
3333 description : Xcode version to select (e.g., 16.3)
3434 required : false
@@ -264,27 +264,48 @@ runs:
264264
265265 # Map requested version to available version on Bitrise stack
266266 REQUESTED_VERSION="${{ inputs.ruby-version }}"
267- if [ "$REQUESTED_VERSION" = "3.1" ]; then
268- # Use the available 3.1.7 version
269- RUBY_VERSION="3.1.7"
270- echo "Using available Ruby 3.1.7"
271- elif [ "$REQUESTED_VERSION" = "3.2" ]; then
272- RUBY_VERSION="3.2.9"
273- echo "Using available Ruby 3.2.9"
274- elif [ "$REQUESTED_VERSION" = "3.3" ]; then
275- RUBY_VERSION="3.3.9"
276- echo "Using available Ruby 3.3.9"
277- elif [ "$REQUESTED_VERSION" = "3.4" ]; then
278- RUBY_VERSION="3.4.5"
279- echo "Using available Ruby 3.4.5"
280- else
281- RUBY_VERSION="$REQUESTED_VERSION"
267+
268+ # Check if .ruby-version file exists and has a full version
269+ if [ -f ".ruby-version" ]; then
270+ EXISTING_VERSION=$(cat .ruby-version | tr -d '\n' | tr -d ' ')
271+ echo "Found .ruby-version file with version: $EXISTING_VERSION"
272+
273+ # Check if the version from .ruby-version is available
274+ if rbenv versions --bare | grep -q "^${EXISTING_VERSION}$"; then
275+ RUBY_VERSION="$EXISTING_VERSION"
276+ echo "Using Ruby version from .ruby-version: $RUBY_VERSION"
277+ else
278+ echo "Ruby $EXISTING_VERSION from .ruby-version is not installed"
279+ echo "Available versions:"
280+ rbenv versions
281+ # Fall back to mapping logic below
282+ fi
283+ fi
284+
285+ # If RUBY_VERSION not set, map requested version to available
286+ if [ -z "$RUBY_VERSION" ]; then
287+ if [ "$REQUESTED_VERSION" = "3.1" ]; then
288+ RUBY_VERSION="3.2.9"
289+ echo "Mapping 3.1 -> 3.2.9 (3.1.x not available)"
290+ elif [ "$REQUESTED_VERSION" = "3.2" ]; then
291+ RUBY_VERSION="3.2.9"
292+ echo "Using available Ruby 3.2.9"
293+ elif [ "$REQUESTED_VERSION" = "3.3" ]; then
294+ RUBY_VERSION="3.3.9"
295+ echo "Using available Ruby 3.3.9"
296+ elif [ "$REQUESTED_VERSION" = "3.4" ]; then
297+ RUBY_VERSION="3.4.5"
298+ echo "Using available Ruby 3.4.5"
299+ else
300+ RUBY_VERSION="$REQUESTED_VERSION"
301+ fi
282302 fi
283303
284304 echo "Setting Ruby version to: $RUBY_VERSION"
285- # Remove any local .ruby-version file that might conflict
305+
306+ # Update .ruby-version file to ensure consistency
286307 if [ -f ".ruby-version" ]; then
287- echo "Found .ruby-version file, backing it up and updating it "
308+ echo "Backing up and updating .ruby-version file "
288309 cp .ruby-version .ruby-version.backup
289310 echo "$RUBY_VERSION" > .ruby-version
290311 fi
0 commit comments