Skip to content

Commit

Permalink
Download native macOS arm64 binary on M1
Browse files Browse the repository at this point in the history
  • Loading branch information
codeman9 committed Feb 22, 2022
1 parent 72e2fdb commit 5e607df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
8 changes: 7 additions & 1 deletion repositories/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"log"
"runtime"
"strings"

"github.com/bazelbuild/bazelisk/httputil"
Expand Down Expand Up @@ -236,6 +237,11 @@ func (gcs *GCSRepo) GetLastGreenCommit(bazeliskHome string, downstreamGreen bool
// DownloadAtCommit downloads a Bazel binary built at the given commit into the specified location and returns the absolute path.
func (gcs *GCSRepo) DownloadAtCommit(commit, destDir, destFile string) (string, error) {
log.Printf("Using unreleased version at commit %s", commit)
url := fmt.Sprintf("%s/%s/%s/bazel", nonCandidateBaseURL, platforms.GetPlatform(), commit)
platform := platforms.GetPlatform()
arch := runtime.GOARCH
if platform == "macos" && arch == "arm64" {
platform = "macos_arm64"
}
url := fmt.Sprintf("%s/%s/%s/bazel", nonCandidateBaseURL, platform, commit)
return httputil.DownloadBinary(url, destDir, destFile)
}
16 changes: 9 additions & 7 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
set -euxo pipefail

rm -rf "$HOME/Library/Caches/bazelisk"
env -u USE_BAZEL_VERSION ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="latest" ./bin/bazelisk-darwin-amd64 version

readonly arch=$(uname -m)
env -u USE_BAZEL_VERSION ./bin/bazelisk-darwin-$arch version
USE_BAZEL_VERSION="latest" ./bin/bazelisk-darwin-$arch version
USE_BAZEL_VERSION="0.28.0" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_green" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_downstream_green" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_rc" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="bazelbuild/latest" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_green" ./bin/bazelisk-darwin-$arch version
USE_BAZEL_VERSION="last_downstream_green" ./bin/bazelisk-darwin-$arch version
USE_BAZEL_VERSION="last_rc" ./bin/bazelisk-darwin-$arch version
USE_BAZEL_VERSION="bazelbuild/latest" ./bin/bazelisk-darwin-$arch version
USE_BAZEL_VERSION="bazelbuild/0.27.0" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="philwo/latest" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="philwo/latest" ./bin/bazelisk-darwin-$arch version
USE_BAZEL_VERSION="philwo/0.25.0" ./bin/bazelisk-darwin-amd64 version

0 comments on commit 5e607df

Please sign in to comment.