Skip to content

Commit

Permalink
feat: support both x64 and arm64 for MacOS
Browse files Browse the repository at this point in the history
Closes #10
  • Loading branch information
barmac committed Apr 12, 2024
1 parent 0bdf7eb commit af857f9
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

set -euo pipefail

# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for modeler.
GH_REPO="https://github.com/camunda/camunda-modeler"
TOOL_NAME="modeler"
TOOL_TEST=""

NIGHTLY_LOCATION="https://downloads.camunda.cloud/release/camunda-modeler/nightly"

# after this version links use architecture in name
MACOS_OLD_ARCH_VERSION="5.22.0"

fail() {
echo -e "asdf-$TOOL_NAME: $*"
exit 1
Expand Down Expand Up @@ -40,7 +42,7 @@ file_name() {

case "$platform_name" in
mac)
echo "camunda-modeler-$version-mac.zip"
echo $(mac_file_name $version)
;;
linux)
echo "camunda-modeler-$version-linux-x64.tar.gz"
Expand All @@ -51,6 +53,41 @@ file_name() {
esac
}

mac_file_name() {
local version="$1"

# handle pre-arm links
if [[ "$version" != "nightly" && $(semver_compare "$version" "$MACOS_OLD_ARCH_VERSION") != "gt" ]]; then
echo "camunda-modeler-$version-mac.zip"
return
fi

case "$(arch)" in
arm64)
echo "camunda-modeler-$version-mac-arm64.zip"
;;
*)
echo "camunda-modeler-$version-mac-x64.zip"
;;
esac
}

semver_compare() {
local IFS=.
local i version1=($1) version2=($2)

for ((i=1; i<=${#version1[@]}; i++)); do
if (( ${version1[i]} < ${version2[i]} )); then
echo "lt"
return
elif (( ${version1[i]} > ${version2[i]} )); then
echo "gt"
return
fi
done
echo "eq"
}

executable() {
local platform_name="$(platform)"

Expand Down

0 comments on commit af857f9

Please sign in to comment.