From 930b0460f85d652a2a5d71defee030b13fc9233b Mon Sep 17 00:00:00 2001 From: Akash Satheesan Date: Mon, 10 May 2021 21:56:39 +0530 Subject: [PATCH] fix(build): download correct cloud-agent for arch (#3331) --- ci/build/npm-postinstall.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ci/build/npm-postinstall.sh b/ci/build/npm-postinstall.sh index bbe23322..289f78eb 100755 --- a/ci/build/npm-postinstall.sh +++ b/ci/build/npm-postinstall.sh @@ -1,6 +1,24 @@ #!/usr/bin/env sh set -eu +# Copied from arch() in ci/lib.sh. +detect_arch() { + case "$(uname -m)" in + aarch64) + echo arm64 + ;; + x86_64 | amd64) + echo amd64 + ;; + *) + # This will cause the download to fail, but is intentional + uname -m + ;; + esac +} + +ARCH="${NPM_CONFIG_ARCH:-$(detect_arch)}" + main() { # Grabs the major version of node from $npm_config_user_agent which looks like # yarn/1.21.1 npm/? node/v14.2.0 darwin x64 @@ -25,7 +43,7 @@ main() { esac OS="$(uname | tr '[:upper:]' '[:lower:]')" - if curl -fsSL "https://storage.googleapis.com/coder-cloud-releases/agent/latest/$OS/cloud-agent" -o ./lib/coder-cloud-agent; then + if curl -fsSL "https://github.com/cdr/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent; then chmod +x ./lib/coder-cloud-agent else echo "Failed to download cloud agent; --link will not work"