Skip to content

feat: install from homebrew in install.sh #9414

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
merged 3 commits into from
Aug 30, 2023
Merged
Changes from all 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
45 changes: 40 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ The detection method works as follows:
- Debian, Ubuntu, Raspbian: install the deb package from GitHub.
- Fedora, CentOS, RHEL, openSUSE: install the rpm package from GitHub.
- Alpine: install the apk package from GitHub.
- macOS: install the release from GitHub.
- All others: install the release from GitHub.
- macOS: if \`brew\` is available, install from the coder/coder Homebrew tap.
- Otherwise, download from GitHub and install into \`--prefix\`.

We build releases on GitHub for amd64, armv7, and arm64 on Windows, Linux, and macOS.

Expand Down Expand Up @@ -118,6 +118,26 @@ Run Coder:
EOF
}

echo_brew_postinstall() {
if [ "${DRY_RUN-}" ]; then
echo_dryrun_postinstall
return
fi

cath <<EOF
brew formula has been installed.

To run a Coder server:

$ coder server

To connect to a Coder deployment:

$ coder login <deployment url>

EOF
}

echo_systemd_postinstall() {
if [ "${DRY_RUN-}" ]; then
echo_dryrun_postinstall
Expand Down Expand Up @@ -303,9 +323,7 @@ main() {
DISTRO=${DISTRO:-$(distro)}

case $DISTRO in
# macOS uses the standalone installation for now.
# Homebrew support is planned. See: https://github.com/coder/coder/issues/1925
macos) install_standalone ;;
darwin) install_macos ;;
# The .deb and .rpm files are pulled from GitHub.
debian) install_deb ;;
fedora | opensuse) install_rpm ;;
Expand Down Expand Up @@ -408,6 +426,23 @@ with_terraform() {
"$sh_c" cp "$CACHE_DIR/terraform" "$COPY_LOCATION"
}

install_macos() {
# If there is no `brew` binary available, just default to installing standalone
if command_exists brew; then
echoh "Installing v$VERSION of the coder formula from coder/coder."
echoh

sh_c brew install coder/coder/coder

echo_brew_postinstall
return
fi

echoh "Homebrew is not available."
echoh "Falling back to standalone installation."
install_standalone
}

install_deb() {
echoh "Installing v$VERSION of the $ARCH deb package from GitHub."
echoh
Expand Down