Files
spark/src/sdk/update_github.sh
T

69 lines
1.5 KiB
Bash

#!/bin/bash
set -e
# This script used to only update github
# it shoudl be called "publish_sdk" but
# it gets called from the ops repo and there's
# no way to atomically change both repos
# so we keep the name
SDK="spark_sdk"
STAGE="/tmp/bts_staging"
SRC=$1
GH=$2
TG=$3
OPP=$4
if [ "$#" -lt 3 ]; then
echo "update_github.sh <source> <https://github.com/your_repo/$SDK.git> <tag> [-push_params]"
echo "set tag to 'stage' if you don't want to push"
exit 0
fi
if [ "$TG" == "stage" ]; then echo "STAGE ONLY"; fi
git lfs install
if [ -d "$STAGE" ]; then
rm -rf $STAGE
fi
mkdir $STAGE
git clone --recurse-submodules "$GH" $STAGE/$SDK
rm -rf $STAGE/$SDK/*
cp -L -r -f "$SRC"/** $STAGE/$SDK/
pushd $STAGE/$SDK
#clean all the stuff we don't want in github
rm ./examples/*/*.so
rm ./lib/data_files/cert_secure_logon.txt
./disable_onixs.py ./lib/libspark.so
rm -r ./externals/lib/libonixs*
rm -r ./externals/include/OnixS/
rm -r ./externals/lib/celoxica/
rm -r ./externals/include/celoxica/
if [ "$TG" != "stage" ]; then
git status
git add .
git commit -m "$SDK update $TG"
git tag "$TG"
git push origin master --tags $OPP
popd
rm -rf $STAGE
fi
# Build SDK docker
docker build . --build-arg SDK_VERSION=$TG --build-arg SDK_BUILD_DATE="$(date)" -t spark_sdk
# Save it to disk
docker save spark_sdk > spark_sdk.img
docker rmi spark_sdk
# add it to zip file
zip -rm spark_sdk.zip spark_sdk.img examples
# upload zip file to api.bluetradesys.com
scp spark_sdk.zip bts@api.bluetradesys.com:/data/sdk/download/