|
| 1 | +#!/bin/bash -e |
| 2 | + |
| 3 | +# Global variables |
| 4 | +top_dir="" |
| 5 | +token="" |
| 6 | +should_publish_app="" |
| 7 | + |
| 8 | +# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself |
| 9 | +# Get the source directory of the distribution |
| 10 | +function get_top_dir { |
| 11 | + SCRIPT=$(realpath "$0") |
| 12 | + SCRIPTPATH=$(dirname "$SCRIPT") |
| 13 | + top_dir=$(realpath "$SCRIPTPATH/..") |
| 14 | + echo "The dxCompiler top directory is: $top_dir" |
| 15 | +} |
| 16 | + |
| 17 | +function build { |
| 18 | + # build the release on staging |
| 19 | + echo "building staging release" |
| 20 | + dx login --staging --token $staging_token --noprojects |
| 21 | + $top_dir/scripts/build_release.py --multi-region $build_flags |
| 22 | + |
| 23 | + ## test that it actually works |
| 24 | + echo "running multi region tests on staging" |
| 25 | + $top_dir/scripts/multi_region_tests.py |
| 26 | + #$top_dir/scripts/proxy_test.py |
| 27 | + |
| 28 | + echo "leave staging" |
| 29 | + dx clearenv |
| 30 | + |
| 31 | + ## build on production |
| 32 | + echo "building on production" |
| 33 | + dx login --token $production_token --noprojects |
| 34 | + $top_dir/scripts/build_release.py --multi-region $build_flags |
| 35 | +} |
| 36 | + |
| 37 | +function parse_cmd_line { |
| 38 | + while [[ $# -ge 1 ]] |
| 39 | + do |
| 40 | + case "$1" in |
| 41 | + --token) |
| 42 | + token=$2 |
| 43 | + shift |
| 44 | + ;; |
| 45 | + --publish-app) |
| 46 | + should_publish_app=$2 |
| 47 | + shift |
| 48 | + ;; |
| 49 | + *) |
| 50 | + echo "unknown argument $1" |
| 51 | + echo "arguments: " |
| 52 | + echo " --token: dx auth token" |
| 53 | + echo " --should_publish_app: either 'true' or 'false'" |
| 54 | + exit 1 |
| 55 | + esac |
| 56 | + shift |
| 57 | + done |
| 58 | + |
| 59 | + if [[ $token == "" ]]; then |
| 60 | + echo "dx token is missing" |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | + |
| 64 | + if [[ $should_publish_app == "" ]]; then |
| 65 | + echo "should_publish_app is missing" |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | + |
| 69 | + if [[ $should_publish_app != "true" && $should_publish_app != "false" ]]; then |
| 70 | + echo "should_publish_app must be 'true' or 'false'" |
| 71 | + exit 1 |
| 72 | + fi |
| 73 | +} |
| 74 | + |
| 75 | +# main program |
| 76 | +parse_cmd_line $@ |
| 77 | +get_top_dir |
| 78 | +build |
0 commit comments