-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-versions
executable file
·88 lines (71 loc) · 1.81 KB
/
install-versions
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
#!/usr/bin/env bash
set -euo pipefail
versions=()
while IFS='' read -r version ; do
versions+=("${version}")
done < ./versions
bundle update \
--bundler
bundler_major_version="$(
bundler \
--version \
| grep \
--extended-regexp \
--only-matching \
'[[:digit:]]' \
| head \
-1
)"
prefix="rails "
for version in "${versions[@]}" ; do
if [[ "${version}" = "4"* ]] && [[ "${bundler_major_version}" = "2" ]] ; then
echo "INFO: Skipping Rails ${version} because it doesn't work with Bundler v2" >&2
continue
fi
echo "INFO: Installing Rails ${version}..." >&2
rm \
-rf \
-- "./${prefix}${version}"
cat \
-- Gemfile.template \
| sed "s/RAILS_VERSION/${version}/" \
> Gemfile
bundle check \
|| bundle install \
--path vendor/bundle
flags=
# Work around bootsnap issue with Rails 6.0, 6.1, 7.0: `rails new`
# post-install fails with `cannot load such file -- bootsnap/setup`.
if (( $(echo "${version} >= 6.0" | bc -l) )) ; then
flags="--skip-bootsnap"
fi
# Work around dependency issues with Rails 6.0.
if [[ "${version}" = "6.0" ]] ; then
# @see https://stackoverflow.com/q/47605810
bundle add \
webpacker \
--version="~> 4.0"
# @see https://stackoverflow.com/q/38663706
bundle add \
listen \
--version="~> 3.2"
fi
# Work around dependency issues with Rails 7.0.
if [[ "${version}" = "7.0" ]] ; then
flags="--skip-javascript"
fi
# Work around dependency issues with Rails 7.1.
if [[ "${version}" = "7.1" ]] ; then
bundle add \
stringio \
--version="~> 3.0"
fi
bundle exec \
rails new \
"${prefix}${version}" "${flags}"
# Remove auto-initialized git repository.
rm -rf \
-- "${prefix}${version}"/.git
echo "INFO: Installed Rails ${version}" >&2
echo
done