tdlight-java/travis/build_success.sh

124 lines
5.3 KiB
Bash
Raw Normal View History

#!/bin/bash -e
set -e
2020-08-18 18:23:30 +02:00
# ====== Setup environment variables
2020-08-20 21:08:01 +02:00
echo "Setup variabled."
source ./travis/setup_variables.sh
2020-08-20 21:08:01 +02:00
echo "Setup variables. OK"
# ====== Copy build output
mv $TDNATIVES_BIN_DIR/$SRC_TDJNI_LIBNAME $TRAVIS_BUILD_DIR/out/$DEST_TDJNI_LIBNAME
2020-08-20 21:08:01 +02:00
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
mv $TDNATIVES_DOCS_BIN_DIR $TRAVIS_BUILD_DIR/out/docs
2020-08-19 17:57:33 +02:00
fi
# ====== Deploy phase
2020-08-18 18:25:39 +02:00
# Setup ssh
2020-08-20 21:08:01 +02:00
echo "Setup ssh."
2020-08-20 20:15:49 +02:00
[ -d ~/.ssh ] || mkdir -p ~/.ssh
echo "$GIT_IGN_TRAVIS_DEPLOY_PRIVATE_KEY" | base64 --decode > ~/.ssh/id_rsa || true
2020-08-18 18:52:49 +02:00
chmod 600 ~/.ssh/id_rsa || true
2020-08-20 21:08:01 +02:00
ssh-keyscan ssh.git.ignuranza.net >> $HOME/.ssh/known_hosts || true
ssh-keyscan git.ignuranza.net >> $HOME/.ssh/known_hosts || true
echo "Setup ssh. OK"
2020-08-18 18:25:39 +02:00
# Setup user
2020-08-20 21:08:01 +02:00
echo "Setup git user."
2020-08-18 18:25:39 +02:00
git config --global user.email "andrea@cavallium.it"
git config --global user.name "Andrea Cavalli"
2020-08-19 13:09:57 +02:00
git config pull.rebase false
2020-08-20 21:08:01 +02:00
echo "Setup git user. OK"
2020-08-18 18:25:39 +02:00
# Prepare repository
2020-08-20 21:08:01 +02:00
echo "Setup repository."
cd $TRAVIS_BUILD_DIR
git clone --depth=1 "git@ssh.git.ignuranza.net:tdlight-team/tdlight-java-natives-$TRAVIS_OS_NAME_STANDARD-$TRAVIS_CPU_ARCH_STANDARD.git"
cd "tdlight-java-natives-$TRAVIS_OS_NAME_STANDARD-$TRAVIS_CPU_ARCH_STANDARD"
2020-08-20 20:15:49 +02:00
[ -d "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD" ] || mkdir -p "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD"
# Add the folder to git if not added
mv "$TRAVIS_BUILD_DIR/out/$DEST_TDJNI_LIBNAME" "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD/$DEST_TDJNI_LIBNAME"
2020-08-20 21:08:01 +02:00
echo "Setup repository. OK"
2020-08-20 14:43:00 +02:00
# IF THE NATIVE LIBRARY IS CHANGED
2020-08-20 21:08:01 +02:00
echo "Checking natives changed."
git add "src" || true
git add "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD" || true
2020-08-20 11:14:06 +02:00
git status --porcelain
echo "File observed: $(git status --porcelain | grep "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD/$DEST_TDJNI_LIBNAME")"
2020-08-20 21:08:01 +02:00
echo "Checking natives changed. OK"
2020-08-19 17:57:33 +02:00
if [[ ! -z "$(git status --porcelain | grep "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD/$DEST_TDJNI_LIBNAME")" ]]; then
# Do the upgrade of the repository
2020-08-20 21:08:01 +02:00
echo "Upgrade repository."
git add "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD/$DEST_TDJNI_LIBNAME" || true
mvn build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} \
versions:commit
NEW_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
git add pom.xml
git commit -m "Updated native library"
git tag -a "v$NEW_VERSION" -m "Version $NEW_VERSION"
git push origin "v$NEW_VERSION"
git push
2020-08-23 14:19:09 +02:00
mvn -B -V deploy -P publish-to-mchv
mvn -B -V deploy -P publish-to-github
# Upgrade the dependency of tdlight-java
cd $TRAVIS_BUILD_DIR
2020-08-20 14:43:00 +02:00
[ -d tdlight-java ] && sudo rm -rf --interactive=never tdlight-java
2020-08-19 13:09:57 +02:00
git clone --depth=1 -b master --single-branch git@ssh.git.ignuranza.net:tdlight-team/tdlight-java.git
2020-08-20 14:43:00 +02:00
git submodule update --remote --init --recursive
cd $TRAVIS_BUILD_DIR/tdlight-java
git checkout master
mvn versions:use-latest-releases -Dincludes=it.tdlight:tdlight-natives-$TRAVIS_OS_NAME_STANDARD-$TRAVIS_CPU_ARCH_STANDARD
[ -f pom.xml.versionsBackup ] && rm pom.xml.versionsBackup
git add pom.xml
git commit -m "Upgrade $TRAVIS_OS_NAME_STANDARD-$TRAVIS_CPU_ARCH_STANDARD natives"
git push
2020-08-20 21:08:01 +02:00
echo "Upgrade repository. OK"
else
echo "Binaries are already updated."
fi
if [ "$TRAVIS_OS_NAME_STANDARD" = "linux" ]; then
if [ "$TRAVIS_CPU_ARCH" = "amd64" ]; then
# Patch TdApi.java
echo "Patching TdApi.java"
2020-08-20 14:43:00 +02:00
cd $TDLIB_SERIALIZER_DIR
2020-08-20 02:01:54 +02:00
python3 $TDLIB_SERIALIZER_DIR $JAVA_SRC_DIR/it/tdlight/tdlib/TdApi.java $JAVA_SRC_DIR/it/tdlight/tdlib/new_TdApi.java $TDLIB_SERIALIZER_DIR/headers.txt
rm $JAVA_SRC_DIR/it/tdlight/tdlib/TdApi.java
unexpand --tabs=2 $JAVA_SRC_DIR/it/tdlight/tdlib/new_TdApi.java > $JAVA_SRC_DIR/it/tdlight/tdlib/TdApi.java
rm $JAVA_SRC_DIR/it/tdlight/tdlib/new_TdApi.java
2020-08-20 14:43:00 +02:00
# Upgrade the file of tdlight-java
cd $TRAVIS_BUILD_DIR
[ -d tdlight-java ] && sudo rm -rf --interactive=never tdlight-java
git clone --depth=1 -b master --single-branch git@ssh.git.ignuranza.net:tdlight-team/tdlight-java.git
git submodule update --remote --init --recursive
2020-08-19 12:54:45 +02:00
cd $TRAVIS_BUILD_DIR/tdlight-java
2020-08-20 14:43:00 +02:00
git checkout master
2020-08-20 02:01:54 +02:00
cp $JAVA_SRC_DIR/it/tdlight/tdlib/TdApi.java $TRAVIS_BUILD_DIR/tdlight-java/src/main/java/it/tdlight/tdlib/TdApi.java
# IF TdApi.java IS CHANGED
2020-08-20 14:43:00 +02:00
cd $TRAVIS_BUILD_DIR/tdlight-java
git add "src/main/java/it/tdlight/tdlib/TdApi.java"
git status --porcelain
echo "File observed: $(git status --porcelain | grep "src/main/java/it/tdlight/tdlib/TdApi.java")"
if [[ ! -z "$(git status --porcelain | grep "src/main/java/it/tdlight/tdlib/TdApi.java")" ]]; then
# Upgrade TdApi.java in repository master
2020-08-20 14:43:00 +02:00
cd $TRAVIS_BUILD_DIR/tdlight-java
2020-08-20 02:01:54 +02:00
git add src/main/java/it/tdlight/tdlib/TdApi.java
git commit -m "Upgraded TdApi.java"
git push
else
echo "TdApi.java already updated."
fi
else
echo "Don't update TdApi.java."
fi
else
echo "Don't update TdApi.java."
fi
2020-08-20 18:02:00 +02:00
echo "Finished."