From efc82b90c18d363116b5d8f6b8860b0e3791c4e4 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 23:00:32 +0200 Subject: [PATCH 1/2] update Makefile and s3sync scripts --- Makefile | 27 +++++++++++++++++++-- scripts/s3sync.sh | 60 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 66 insertions(+), 21 deletions(-) mode change 100644 => 100755 scripts/s3sync.sh diff --git a/Makefile b/Makefile index b9aabd01..e40ce5de 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,28 @@ +# Run docker build +# usage: +# make build-beta +# make build-stable build-%: ./scripts/docker-build.sh $* -sync-%: - ./scripts/s3sync.sh $* \ No newline at end of file +# s3sync with stage.mytrezor.com +# Upload requested build for testing purposes +# usage: +# make stage-beta +# make stage-stable +stage-%: + ./scripts/s3sync.sh stage $* + +# s3sync with beta.mytrezor.com +# Upload build/beta only +# usage: +# make beta +beta: + ./scripts/s3sync.sh beta beta + +# s3sync with wallet.mytrezor.com +# Upload build/stable only +# usage: +# make stable +stable: + ./scripts/s3sync.sh stable stable \ No newline at end of file diff --git a/scripts/s3sync.sh b/scripts/s3sync.sh old mode 100644 new mode 100755 index 44a141a2..a4904366 --- a/scripts/s3sync.sh +++ b/scripts/s3sync.sh @@ -13,41 +13,63 @@ function confirm { fi } -if [ "x$1" == "x" ]; then - echo "./s3sync.sh stage|beta|wallet [-d]" + +# Validate params +if [ "x$1" == "x" ] || [ "x$2" == "x" ]; then + echo "Invalid params" + echo "./s3sync.sh beta|stable stage|beta|stable [clear]" exit 1 fi +# 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 if [ "x$1" == "xstage" ]; then - DIST=../build/beta BUCKET=stage.mytrezor.com DISTRIBUTION_ID="E24M0QWO692FQL" - elif [ "x$1" == "xbeta" ]; then - DIST=../build/beta BUCKET=beta.mytrezor.com DISTRIBUTION_ID="E1PONNHWUNCQ9M" - - confirm - -elif [ "x$1" == "xwallet" ]; then - DIST=../build/prod +elif [ "x$2" == "xstable" ]; then BUCKET=wallet.mytrezor.com DISTRIBUTION_ID="EZM01GFTITGVD" +fi - confirm +echo "sync "$SOURCE" with "$BUCKET"/next" +if [ "x$1" == "xbeta" ] || [ "x$1" == "xstable" ]; then + confirm fi -set -e -cd `dirname $0` +# set -e +# cd `dirname $0` -if [ "x$2" == "x-d" ]; then - aws s3 sync --delete --cache-control 'public, max-age=3600' $DIST s3://$BUCKET/next -else - aws s3 sync --cache-control 'public, max-age=3600' $DIST s3://$BUCKET/next -fi +# if [ "x$3" == "x-d" ]; 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 -aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*' +# aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/next/*' echo "DONE" \ No newline at end of file From c21573b1cde12bf47cdb9310313439dd38423c5f Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 24 Oct 2018 23:01:23 +0200 Subject: [PATCH 2/2] renamed "prod" directory to "stable" --- .gitlab-ci.yml | 4 ++-- Dockerfile | 2 +- package.json | 4 ++-- scripts/docker-build.sh | 6 ++++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94a353f3..168202be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,11 +48,11 @@ build beta: build production: stage: build script: - - yarn run build:prod + - yarn run build:stable artifacts: expire_in: 1 month paths: - - build/prod + - build/stable # deploy deploy review: diff --git a/Dockerfile b/Dockerfile index d1dd82de..7d2db3a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:9.3 -ARG BUILD_TYPE=prod +ARG BUILD_TYPE=stable WORKDIR /trezor-wallet-app diff --git a/package.json b/package.json index 32617cbc..80a26712 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "dev": "npx webpack-dev-server --config webpack/dev.babel.js", "dev:local": "npx webpack-dev-server --config webpack/local.babel.js", "build": "rimraf build && run-s build:*", - "build:prod": "rimraf build/prod && npx webpack --config webpack/production.babel.js --output-path build/prod --progress --bail", + "build:stable": "rimraf build/stable && npx webpack --config webpack/production.babel.js --output-path build/stable --progress --bail", "build:beta": "rimraf build/beta && cross-env BUILD=beta npx webpack --config webpack/production.babel.js --output-path build/beta --progress --bail", "build:dev": "rimraf build.dev && cross-env BUILD=development npx webpack --config webpack/production.babel.js --output-path build/dev --progress --bail", "flow": "flow check src", @@ -22,7 +22,7 @@ "test:unit": "npx jest", "test-unit:watch": "npx jest -o --watch", "server:beta": "node ./server/index.js --buildType=beta", - "server:prod": "node ./server/index.js --buildType=prod" + "server:stable": "node ./server/index.js --buildType=stable" }, "dependencies": { "babel": "^6.23.0", diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index 630b3efc..bea0d4e1 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -2,7 +2,7 @@ cd "$(dirname "$0")" -if [[ "$1" == "dev" || "$1" == 'beta' || "$1" == 'prod' ]] +if [[ "$1" == "dev" || "$1" == "beta" || "$1" == "stable" ]] then mkdir -p ../build rm -rf ../build/$1 @@ -12,6 +12,8 @@ if [[ "$1" == "dev" || "$1" == 'beta' || "$1" == 'prod' ]] docker cp trezor-wallet:/trezor-wallet-app/build/$1 ../build/$1 docker stop trezor-wallet docker rm trezor-wallet + echo "DONE!" + echo "Build directory: "$1 else - echo "invalid parameters... valid parameters are (beta, dev, prod)" + echo "invalid parameters... valid parameters are (dev, beta, stable)" fi \ No newline at end of file