@@ -26,18 +26,21 @@ The remote host must have internet access.
26
26
${not_curl_usage-}
27
27
Usage:
28
28
29
- $arg0 [--dry-run] [--version X.X.X] [--edge ] [--method detect] \
29
+ ${ arg0} [--dry-run] [--mainline | --stable | -- version X.X.X] [--method detect] \
30
30
[--prefix ~/.local] [--rsh ssh] [user@host]
31
31
32
32
--dry-run
33
33
Echo the commands for the install process without running them.
34
34
35
+ --mainline
36
+ Install the latest mainline version (default).
37
+
38
+ --stable
39
+ Install the latest stable version instead of the latest mainline version.
40
+
35
41
--version X.X.X
36
42
Install a specific version instead of the latest.
37
43
38
- --edge
39
- Install the latest edge version instead of the latest stable version.
40
-
41
44
--method [detect | standalone]
42
45
Choose the installation method. Defaults to detect.
43
46
- detect detects the system package manager and tries to use it.
89
92
}
90
93
91
94
echo_latest_version () {
92
- if [ " ${EDGE-} " ]; then
93
- version=" $( curl -fsSL https://api.github.com/repos/coder/coder/releases | awk ' match($0,/.*"html_url": "(.*\/releases\/tag\/.*)".*/)' | head -n 1 | awk -F ' "' ' {print $4}' ) "
94
- else
95
+ if [ " ${MAINLINE} " = 0 ]; then
95
96
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860
96
97
version=" $( curl -fsSLI -o /dev/null -w " %{url_effective}" https://github.com/coder/coder/releases/latest) "
97
- fi
98
- version=" ${version# https:// github.com/ coder/ coder/ releases/ tag/ } "
99
- version=" ${version# v} "
100
- echo " $version "
98
+ version=" ${version# https:// github.com/ coder/ coder/ releases/ tag/ v} "
99
+ else
100
+ # Fetch the releases from the GitHub API, sort by version number,
101
+ # and take the first result. Note that we're sorting by space-
102
+ # separated numbers and without utilizing the sort -V flag for the
103
+ # best compatibility.
104
+ version=" $(
105
+ curl -fsSL https://api.github.com/repos/coder/coder/releases \
106
+ | awk -F' "' ' /"tag_name"/ {print $4}' \
107
+ | tr -d v \
108
+ | tr . ' ' \
109
+ | sort -k1,1nr -k2,2nr -k3,3nr \
110
+ | head -n1 \
111
+ | tr ' ' .
112
+ ) "
113
+ fi
114
+ echo " ${version} "
101
115
}
102
116
103
117
echo_standalone_postinstall () {
224
238
}
225
239
226
240
main () {
241
+ MAINLINE=1
227
242
TERRAFORM_VERSION=" 1.6.6"
228
243
229
244
if [ " ${TRACE-} " ]; then
@@ -236,7 +251,6 @@ main() {
236
251
OPTIONAL \
237
252
ALL_FLAGS \
238
253
RSH_ARGS \
239
- EDGE \
240
254
RSH \
241
255
WITH_TERRAFORM \
242
256
CAP_NET_ADMIN
@@ -282,8 +296,12 @@ main() {
282
296
--version=* )
283
297
VERSION=" $( parse_arg " $@ " ) "
284
298
;;
285
- --edge)
286
- EDGE=1
299
+ # Support edge for backwards compatibility.
300
+ --mainline | --edge)
301
+ MAINLINE=1
302
+ ;;
303
+ --stable)
304
+ MAINLINE=0
287
305
;;
288
306
--rsh)
289
307
RSH=" $( parse_arg " $@ " ) "
0 commit comments