|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | + |
| 4 | +if [[ -n $(git diff HEAD) ]]; then |
| 5 | + echo "Error: You have uncommitted changes. Please commit and push them to git so we can track them." |
| 6 | + exit 1 |
| 7 | +fi |
| 8 | + |
| 9 | +# Get current branch name |
| 10 | +local_branch=$(git rev-parse --abbrev-ref HEAD) |
| 11 | + |
| 12 | +# Fetch latest from remote |
| 13 | +git fetch origin $local_branch |
| 14 | + |
| 15 | +# Check if local is behind remote |
| 16 | +if [[ -n $(git diff HEAD..origin/$local_branch) ]]; then |
| 17 | + echo "Error: Your branch is not in sync with remote" |
| 18 | + echo "Please push your local changes and sync your local branch $local_branch with remote" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +set -e |
| 23 | + |
| 24 | +SCRIPT_DIRECTORY=$(dirname -- "$(realpath -- "$0")") |
| 25 | +CHRONON_ROOT_DIR=$(dirname "$SCRIPT_DIRECTORY") |
| 26 | + |
| 27 | +echo "Working in $CHRONON_ROOT_DIR" |
| 28 | +cd $CHRONON_ROOT_DIR |
| 29 | + |
| 30 | +echo "Building jars" |
| 31 | + |
| 32 | +bazel build //cloud_gcp:cloud_gcp_lib_deploy.jar |
| 33 | +bazel build //service:service_assembly_deploy.jar |
| 34 | + |
| 35 | +CLOUD_GCP_JAR="$CHRONON_ROOT_DIR/bazel-bin/cloud_gcp/cloud_gcp_lib_deploy.jar" |
| 36 | +SERVICE_JAR="$CHRONON_ROOT_DIR/bazel-bin/service/service_assembly_deploy.jar" |
| 37 | + |
| 38 | +if [ ! -f "$CLOUD_GCP_JAR" ]; then |
| 39 | + echo "$CLOUD_GCP_JAR not found" |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | + |
| 43 | +if [ ! -f "$SERVICE_JAR" ]; then |
| 44 | + echo "$SERVICE_JAR not found" |
| 45 | + exit 1 |
| 46 | +fi |
| 47 | + |
| 48 | +# We copy to build output as the docker build can't access the bazel-bin (as its a symlink) |
| 49 | +echo "Copying jars to build_output" |
| 50 | +mkdir -p build_output |
| 51 | +cp bazel-bin/service/service_assembly_deploy.jar build_output/ |
| 52 | +cp bazel-bin/cloud_aws/cloud_aws_lib_deploy.jar build_output/ |
| 53 | +cp bazel-bin/cloud_gcp/cloud_gcp_lib_deploy.jar build_output/ |
| 54 | + |
| 55 | +echo "Kicking off a docker login" |
| 56 | +docker login |
| 57 | + |
| 58 | +docker buildx build \ |
| 59 | + --platform linux/amd64,linux/arm64 \ |
| 60 | + -f docker/fetcher/Dockerfile \ |
| 61 | + -t ziplineai/chronon-fetcher:$(git rev-parse --short HEAD) \ |
| 62 | + -t ziplineai/chronon-fetcher:latest \ |
| 63 | + --push \ |
| 64 | + . |
| 65 | + |
| 66 | +# Clean up build output dir |
| 67 | +rm -rf build_output |
0 commit comments