#!/usr/bin/env bash

set -euo pipefail
set -x

# upload new versiotn
script_dir="$(dirname "$(readlink --canonicalize "${BASH_SOURCE[0]}")")"
deb="$1"
deb_sha="$(sha256sum "$deb" | awk '{ print $1; }')"
s3_path="zoox-third-party/$deb_sha/$(basename "$deb")"

aws --endpoint-url=https://z3.zooxlabs.com \
    --profile z3 \
    s3 cp "$deb" "s3://$s3_path" \
    --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers

echo "New SHA: $deb_sha"
