1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-11 01:28:10 +00:00
trezor-wallet/scripts/s3sync.sh

86 lines
2.0 KiB
Bash
Raw Normal View History

2018-10-19 15:02:30 +00:00
#!/bin/bash
# Before first use:
# Install awscli (pip install awscli)
# Configure access credentials (aws configure), region is "eu-central-1"
2018-10-24 21:34:38 +00:00
# Usage:
# ./s3sync.sh DESTINATION SOURCE [clear]
# @DESTINATION: required, destination server
# @SOURCE: required, build
# @CLEAR: optional, delete previous uploads
# ./s3sync.sh stage beta
# ./s3sync.sh stage stable
# ./s3sync.sh stage stable clear
# ./s3sync.sh beta beta
# ./s3sync.sh stable stable
2018-10-19 15:02:30 +00:00
function confirm {
read -r -p "Are you sure? [y/N] " response
if [[ $response =~ ^(yes|y)$ ]]; then
echo "let's go!"
else
exit 2
fi
}
2018-10-24 21:00:32 +00:00
# Validate params
if [ "x$1" == "x" ] || [ "x$2" == "x" ]; then
echo "Invalid params"
2018-10-24 21:34:38 +00:00
echo "./s3sync.sh stage|beta|stable beta|stable [clear]"
2018-10-19 15:02:30 +00:00
exit 1
fi
2018-10-24 21:00:32 +00:00
# Validate destination param
if [ "x$1" != "xstage" ] && [ "x$1" != "xbeta" ] && [ "x$1" != "xstable" ]; then
echo "Invalid destination: "$1
echo "use: stage|beta|stable"
exit 1
fi
# Validate source param
if [ "x$2" != "xbeta" ] && [ "x$2" != "xstable" ]; then
echo "Invalid source: "$2
echo "use: beta|stable"
exit 1
fi
# Set source directory
if [ "x$2" == "xbeta" ]; then
SOURCE=../build/beta
elif [ "x$2" == "xstable" ]; then
SOURCE=../build/stable
fi
# Set destination
2018-10-19 15:02:30 +00:00
if [ "x$1" == "xstage" ]; then
BUCKET=stage.mytrezor.com
DISTRIBUTION_ID="E24M0QWO692FQL"
elif [ "x$1" == "xbeta" ]; then
BUCKET=beta.mytrezor.com
DISTRIBUTION_ID="E1PONNHWUNCQ9M"
2018-10-24 21:00:32 +00:00
elif [ "x$2" == "xstable" ]; then
2018-10-19 15:02:30 +00:00
BUCKET=wallet.mytrezor.com
DISTRIBUTION_ID="EZM01GFTITGVD"
2018-10-24 21:00:32 +00:00
fi
2018-10-19 15:02:30 +00:00
2018-10-24 21:00:32 +00:00
echo "sync "$SOURCE" with "$BUCKET"/next"
2018-10-19 15:02:30 +00:00
2018-10-24 21:00:32 +00:00
if [ "x$1" == "xbeta" ] || [ "x$1" == "xstable" ]; then
confirm
2018-10-19 15:02:30 +00:00
fi
2018-10-24 21:34:38 +00:00
set -e
cd `dirname $0`
2018-10-19 15:02:30 +00:00
2018-10-24 21:34:38 +00:00
if [ "x$3" == "x-clear" ]; then
aws s3 sync --delete --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next
else
aws s3 sync --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next
fi
2018-10-19 15:02:30 +00:00
2018-10-24 21:34:38 +00:00
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/next/*'
2018-10-19 15:02:30 +00:00
echo "DONE"