-
Notifications
You must be signed in to change notification settings - Fork 903
feat(install.sh): add support for --mainline
(default) and --stable
#12858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mafredri
merged 3 commits into
main
from
mafredri/feat-install.sh-add-stable-mainline-support
Apr 3, 2024
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
feat(install.sh): add support for
--mainline
(default) and --stable
- Loading branch information
commit 339acb9a8a0c5d13888fbf19f1aa7556a9920b32
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,18 +26,21 @@ The remote host must have internet access. | |
${not_curl_usage-} | ||
Usage: | ||
|
||
$arg0 [--dry-run] [--version X.X.X] [--edge] [--method detect] \ | ||
${arg0} [--dry-run] [--mainline | --stable | --version X.X.X] [--method detect] \ | ||
[--prefix ~/.local] [--rsh ssh] [user@host] | ||
|
||
--dry-run | ||
Echo the commands for the install process without running them. | ||
|
||
--mainline | ||
Install the latest mainline version (default). | ||
|
||
--stable | ||
Install the latest stable version instead of the latest mainline version. | ||
|
||
--version X.X.X | ||
Install a specific version instead of the latest. | ||
|
||
--edge | ||
Install the latest edge version instead of the latest stable version. | ||
|
||
--method [detect | standalone] | ||
Choose the installation method. Defaults to detect. | ||
- detect detects the system package manager and tries to use it. | ||
|
@@ -89,15 +92,26 @@ EOF | |
} | ||
|
||
echo_latest_version() { | ||
if [ "${EDGE-}" ]; then | ||
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}')" | ||
else | ||
if [ "${MAINLINE}" = 0 ]; then | ||
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860 | ||
version="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/coder/coder/releases/latest)" | ||
fi | ||
version="${version#https://github.com/coder/coder/releases/tag/}" | ||
version="${version#v}" | ||
echo "$version" | ||
version="${version#https://github.com/coder/coder/releases/tag/v}" | ||
else | ||
# Fetch the releases from the GitHub API, sort by version number, | ||
# and take the first result. Note that we're sorting by space- | ||
# separated numbers and without utilizing the sort -V flag for the | ||
# best compatibility. | ||
version="$( | ||
curl -fsSL https://api.github.com/repos/coder/coder/releases | | ||
awk -F'"' '/"tag_name"/ {print $4}' | | ||
tr -d v | | ||
tr . ' ' | | ||
sort -k1,1nr -k2,2nr -k3,3nr | | ||
head -n1 | | ||
tr ' ' . | ||
)" | ||
fi | ||
echo "${version}" | ||
} | ||
|
||
echo_standalone_postinstall() { | ||
|
@@ -224,6 +238,7 @@ EOF | |
} | ||
|
||
main() { | ||
MAINLINE=1 | ||
TERRAFORM_VERSION="1.6.6" | ||
|
||
if [ "${TRACE-}" ]; then | ||
|
@@ -236,7 +251,6 @@ main() { | |
OPTIONAL \ | ||
ALL_FLAGS \ | ||
RSH_ARGS \ | ||
EDGE \ | ||
RSH \ | ||
WITH_TERRAFORM \ | ||
CAP_NET_ADMIN | ||
|
@@ -282,8 +296,12 @@ main() { | |
--version=*) | ||
VERSION="$(parse_arg "$@")" | ||
;; | ||
--edge) | ||
EDGE=1 | ||
# Support edge for backwards compatibility. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: isn't it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both forms seem to be used, but perhaps “backward” is the more common one. |
||
--mainline | --edge) | ||
MAINLINE=1 | ||
;; | ||
--stable) | ||
MAINLINE=0 | ||
;; | ||
--rsh) | ||
RSH="$(parse_arg "$@")" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be confusing with VERSION
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the upper/lower case is a good enough distinction, and this practice (case) is often used to separate script global and function local variables. Although inherently case doesn’t differentiate between scope, for that local/typeset/declare needs to be used. Since we’re supporting posix shell though, we don’t try to use such “advance features”. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, we can always adopt
local
keyword :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caveat emptor: https://unix.stackexchange.com/questions/493729/list-of-shells-that-support-local-keyword-for-defining-local-variables#493743