Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 57 additions & 20 deletionsinstall.sh
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand DownExpand Up@@ -88,16 +91,25 @@ The installer will cache all downloaded assets into ~/.cache/coder
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
# 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"
echo_latest_stable_version() {
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-2758860
version="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/coder/coder/releases/latest)"
version="${version#https://github.com/coder/coder/releases/tag/v}"
echo "${version}"
Copy link
Member

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

Copy link
MemberAuthor

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”. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Alright, we can always adoptlocal keyword :)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

mtojek reacted with eyes emoji
}

echo_latest_mainline_version() {
# 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.
curl -fsSL https://api.github.com/repos/coder/coder/releases |
awk -F'"' '/"tag_name"/ {print $4}' |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: you didn't want to usejq? :)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I’d love to, but it’s a dependency we can’t afford.

mtojek and bpmct reacted with thumbs up emoji
tr -d v |
tr . ' ' |
sort -k1,1nr -k2,2nr -k3,3nr |
head -n1 |
tr ' ' .
}

echo_standalone_postinstall() {
Expand All@@ -106,9 +118,18 @@ echo_standalone_postinstall() {
return
fi

channel=mainline
advisory="To install our stable release (v${STABLE_VERSION}), use the --stable flag. "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: the trailing space might not be most convenient form, but I see why you have added this way, one condition less.

mafredri reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I initially had the entire advisory as two separate vars, then I noticed the repetition and extracted common parts 😅, I can go back to that method if you think it’s preferable.

Copy link
Member

@mtojekmtojekApr 3, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Probably not worth it, this is just a single condition :) Thanks for sharing more context!

mafredri reacted with thumbs up emoji
if [ "${MAINLINE}" = 0 ]; then
channel=stable
advisory=""
fi

cath <<EOF

Coder has been installed to
Coder ${channel} release v${VERSION} installed. ${advisory}See our releases documentation or GitHub for more information on versioning.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Awesome 👏


The Coder binary has been placed in the following location:

$STANDALONE_INSTALL_PREFIX/bin/$STANDALONE_BINARY_NAME

Expand DownExpand Up@@ -218,12 +239,13 @@ There is another binary in your PATH that conflicts with the binary we've instal

This is likely because of an existing installation of Coder. See our documentation for suggestions on how to resolve this.

https://coder.com/docs/v2/latest/install/install.sh#path-conflicts
https://coder.com/docs/v2/latest/install/install.sh#path-conflicts

EOF
}

main() {
MAINLINE=1
TERRAFORM_VERSION="1.6.6"

if [ "${TRACE-}" ]; then
Expand All@@ -236,7 +258,6 @@ main() {
OPTIONAL \
ALL_FLAGS \
RSH_ARGS \
EDGE \
RSH \
WITH_TERRAFORM \
CAP_NET_ADMIN
Expand DownExpand Up@@ -282,8 +303,12 @@ main() {
--version=*)
VERSION="$(parse_arg "$@")"
;;
--edge)
EDGE=1
# Support edge for backward compatibility.
--mainline | --edge)
MAINLINE=1
;;
--stable)
MAINLINE=0
;;
--rsh)
RSH="$(parse_arg "$@")"
Expand DownExpand Up@@ -364,7 +389,12 @@ main() {
TERRAFORM_INSTALL_PREFIX=${TERRAFORM_INSTALL_PREFIX:-/usr/local}
STANDALONE_INSTALL_PREFIX=${STANDALONE_INSTALL_PREFIX:-/usr/local}
STANDALONE_BINARY_NAME=${STANDALONE_BINARY_NAME:-coder}
VERSION=${VERSION:-$(echo_latest_version)}
STABLE_VERSION=$(echo_latest_stable_version)
if [ "${MAINLINE}" = 0 ]; then
VERSION=${STABLE_VERSION}
else
VERSION=$(echo_latest_mainline_version)
fi

distro_name

Expand All@@ -378,6 +408,13 @@ main() {
with_terraform
fi

# If the version is the same as the stable version, we're installing
# the stable version.
if [ "${MAINLINE}" != 0 ] && [ "${VERSION}" = "${STABLE_VERSION}" ]; then
echoh "The latest mainline version has been promoted to stable, selecting stable."
MAINLINE=0
fi

# Standalone installs by pulling pre-built releases from GitHub.
if [ "$METHOD" = standalone ]; then
if has_standalone; then
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp