Skip to content

Commit

Permalink
Install script update for Darwin ARM 64 (M1 Mac etc) support (#827)
Browse files Browse the repository at this point in the history
* Adds native binary support for Darwin Arm64 (e.g. M1 Mac) (#826)

* Add Darwin ARM64 binaries

* Update install script for Darwin Arm64

* Fix install script for M1 mac
  • Loading branch information
berndverst authored Nov 10, 2021
1 parent 4ccf10f commit 1c5e1b3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/dapr_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
target_arch: arm64
- os: macOS-latest
target_arch: arm
- os: macOS-latest
target_arch: arm64
steps:
- name: Set up Go ${{ env.GOVER }}
uses: actions/setup-go@v2
Expand Down
42 changes: 34 additions & 8 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ getSystemInfo() {
}

verifySupported() {
releaseTag=$1
local supported=(darwin-amd64 linux-amd64 linux-arm linux-arm64)
local current_osarch="${OS}-${ARCH}"

Expand All @@ -51,13 +52,16 @@ verifySupported() {
done

if [ "$current_osarch" == "darwin-arm64" ]; then
echo "The darwin_arm64 arch has no native binary, however you can use the amd64 version so long as you have rosetta installed"
echo "Use 'softwareupdate --install-rosetta' to install rosetta if you don't already have it"
ARCH="amd64"
return
if isReleaseAvailable $releaseTag; then
return
else
echo "The darwin_arm64 arch has no native binary for this version of Dapr, however you can use the amd64 version so long as you have rosetta installed"
echo "Use 'softwareupdate --install-rosetta' to install rosetta if you don't already have it"
ARCH="amd64"
return
fi
fi


echo "No prebuilt binary for ${current_osarch}"
exit 1
}
Expand Down Expand Up @@ -133,6 +137,28 @@ downloadFile() {
fi
}

isReleaseAvailable() {
LATEST_RELEASE_TAG=$1

DAPR_CLI_ARTIFACT="${DAPR_CLI_FILENAME}_${OS}_${ARCH}.tar.gz"
DOWNLOAD_BASE="https://github.com/${GITHUB_ORG}/${GITHUB_REPO}/releases/download"
DOWNLOAD_URL="${DOWNLOAD_BASE}/${LATEST_RELEASE_TAG}/${DAPR_CLI_ARTIFACT}"

if [ "$DAPR_HTTP_REQUEST_CLI" == "curl" ]; then
httpstatus=$(curl -sSLI -o /dev/null -w "%{http_code}" "$DOWNLOAD_URL")
if [ "$httpstatus" == "200" ]; then
return 0
fi
else
wget -q --spider "$DOWNLOAD_URL"
exitstatus=$?
if [ $exitstatus -eq 0 ]; then
return 0
fi
fi
return 1
}

installFile() {
tar xf "$ARTIFACT_TMP_FILE" -C "$DAPR_TMP_ROOT"
local tmp_root_dapr_cli="$DAPR_TMP_ROOT/$DAPR_CLI_FILENAME"
Expand Down Expand Up @@ -181,18 +207,18 @@ installCompleted() {
trap "fail_trap" EXIT

getSystemInfo
verifySupported
checkExistingDapr
checkHttpRequestCLI


if [ -z "$1" ]; then
echo "Getting the latest Dapr CLI..."
getLatestRelease
else
ret_val=v$1
fi

verifySupported $ret_val
checkExistingDapr

echo "Installing $ret_val Dapr CLI..."

downloadFile $ret_val
Expand Down

0 comments on commit 1c5e1b3

Please sign in to comment.