-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
97 lines (89 loc) · 4.21 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Setup Ruby
description: |
Sets up Ruby. Wrapper around https://github.com/ruby/setup-ruby
Supported platforms:
* MacOS ARM and MacOS 13 machines with a simple brew install and NO cache support
* All the other platforms supported by https://github.com/ruby/setup-ruby
inputs:
ruby-version:
description: 'Engine and version to use, see the syntax in the README. Reads from .ruby-version or .tool-versions if unset.'
default: 'default'
rubygems:
description: |
The version of RubyGems to use. Either 'default' (the default), 'latest', or a version number (e.g., 3.3.5).
For 'default', no action is taken and the version of RubyGems that comes with Ruby by default is used.
For 'latest', `gem update --system` is run to update to the latest RubyGems version.
Similarly, if a version number is given, `gem update --system <version>` is run to update to that version of RubyGems, as long as that version is newer than the one provided by default.
bundler:
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).
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', 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.3, Bundler 1 on Ruby < 2.3).
For 'none', nothing is done.
bundler-cache:
description: 'Run "bundle install", and cache the result automatically. Either true or false.'
default: 'false'
working-directory:
description: 'The working directory to use for resolving paths for .ruby-version, .tool-versions and Gemfile.lock.'
cache-version:
description: |
Arbitrary string that will be added to the cache key of the bundler cache. Set or change it if you need
to invalidate the cache.
force-custom-macos-install:
description: |
If true, forces the custom hack to install ruby via brew
default: 'false'
runs:
using: "composite"
steps:
- run: |
echo "macos_version=$(sw_vers -productVersion | cut -f1 -d.)" >> "$GITHUB_OUTPUT"
echo "macos_arch=$(uname -p)" >> "$GITHUB_OUTPUT"
shell: bash
if: "${{ runner.os == 'macOS' }}"
id: get_macos_version
- run: |
set -e
brew update && brew install ruby@${{ inputs.ruby-version }}
BIN_PATH="$(brew --prefix ruby@${{ inputs.ruby-version }})"
export PATH="$BIN_PATH/bin:$PATH"
echo "$BIN_PATH/bin" >> $GITHUB_PATH
bundler_version=
[[ -f "Gemfile.lock" ]] && bundler_version="$(grep -A1 "BUNDLED WITH" Gemfile.lock | tail -n1 | xargs || true)"
[[ -n "$bundler_version" ]] && gem install "bundler:$bundler_version"
run_bundle_install_lower="$(echo "$RUN_BUNDLE_INSTALL" | tr '[:upper:]' '[:lower:]')"
if [[ "$run_bundle_install_lower" == "true" ]]; then
bundle install
fi
# the setup-ruby action does not support macos-13 yet
shell: bash
env:
RUN_BUNDLE_INSTALL: ${{ inputs.bundler-cache }}
working-directory: "${{ inputs.working-directory }}"
if: |
inputs.force-custom-macos-install == 'true' ||
(
runner.os == 'macOS' &&
(
steps.get_macos_version.outputs.macos_arch == 'arm' ||
steps.get_macos_version.outputs.macos_version == '14'
)
)
- uses: ruby/setup-ruby@v1
if: |
inputs.force-custom-macos-install != 'true' &&
!(
runner.os == 'macOS' &&
(
steps.get_macos_version.outputs.macos_arch == 'arm' ||
steps.get_macos_version.outputs.macos_version == '14'
)
)
with:
ruby-version: "${{ inputs.ruby-version }}"
bundler: "${{ inputs.bundler }}"
bundler-cache: "${{ inputs.bundler-cache }}"
rubygems: "${{ inputs.rubygems }}"
working-directory: "${{ inputs.working-directory }}"
cache-version: "${{ inputs.cache-version }}"