| #!/usr/bin/env bash |
| # Copyright 2016 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style |
| # license that can be found in the LICENSE file. |
| |
| # Usage: |
| # |
| # Upload jiri prebuilt for the current OS. |
| # > ./scripts/upload_jiri |
| # |
| |
| # This script uploads jiri binaries to Google storage, therefore it expects to |
| # be run in an environment with the credentials necessary for uploading to |
| # gs://fuchsia-build. The binaries stored in a convention which matches the |
| # expectations of bootstrap_jiri. |
| |
| readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| readonly GIT_DIR="$(dirname "${SCRIPT_DIR}")" |
| |
| readonly HOST_ARCH=$(uname -m) |
| if [ "$HOST_ARCH" == "aarch64" ]; then |
| readonly ARCH="arm64" |
| elif [ "$HOST_ARCH" == "x86_64" ]; then |
| readonly ARCH="amd64" |
| else |
| echo "Arch not supported: $HOST_ARCH" |
| exit 1 |
| fi |
| readonly HOST_OS="$(uname | tr '[:upper:]' '[:lower:]')" |
| |
| readonly PKG_PATH="fuchsia.googlesource.com/jiri" |
| readonly GS_BUCKET="gs://fuchsia-build/jiri" |
| |
| # Use the git SHA of the latest commit in the jiri repo as the version of the binaries. |
| readonly VERSION="$(git --git-dir="${GIT_DIR}/.git" --work-tree="${GIT_DIR}" log -1 --format=%H)" |
| |
| # Upload the binary |
| gsutil cp "jiri" "${GS_BUCKET}/${HOST_OS}-${ARCH}/${VERSION}" |