2020-08-18 16:31:36 +02:00
|
|
|
#!/bin/bash -e
|
2020-08-19 18:14:55 +02:00
|
|
|
set -e
|
2020-08-18 18:23:30 +02:00
|
|
|
|
2020-08-19 20:13:35 +02:00
|
|
|
# ====== Setup environment variables
|
2020-08-19 20:58:00 +02:00
|
|
|
source ./travis/setup_variables.sh
|
2020-08-19 00:57:20 +02:00
|
|
|
|
2020-08-19 20:13:35 +02:00
|
|
|
# ====== Copy build output
|
|
|
|
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
|
|
|
mv $TDNATIVES_BIN_DIR/libtdjni.so $TRAVIS_BUILD_DIR/out/libtdjni.so
|
|
|
|
mv $TDNATIVES_DOCS_BIN_DIR $TRAVIS_BUILD_DIR/out/docs
|
|
|
|
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
|
|
|
|
mv $TDNATIVES_BIN_DIR/tdjni.dll $TRAVIS_BUILD_DIR/out/libtdjni.dll
|
2020-08-19 17:57:33 +02:00
|
|
|
fi
|
2020-08-18 17:27:52 +02:00
|
|
|
|
2020-08-19 20:13:35 +02:00
|
|
|
# ====== Deploy phase
|
2020-08-18 17:27:52 +02:00
|
|
|
|
2020-08-18 18:25:39 +02:00
|
|
|
# Setup ssh
|
2020-08-18 18:45:26 +02:00
|
|
|
mkdir -p ~/.ssh
|
2020-08-18 20:08:49 +02:00
|
|
|
echo "$GIT_IGN_TRAVIS_DEPLOY_PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
|
2020-08-18 18:52:49 +02:00
|
|
|
chmod 600 ~/.ssh/id_rsa || true
|
2020-08-18 17:31:59 +02:00
|
|
|
ssh-keyscan ssh.git.ignuranza.net >> $HOME/.ssh/known_hosts
|
|
|
|
ssh-keyscan git.ignuranza.net >> $HOME/.ssh/known_hosts
|
2020-08-18 18:25:39 +02:00
|
|
|
|
|
|
|
# Setup user
|
|
|
|
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-18 18:25:39 +02:00
|
|
|
|
2020-08-18 21:05:38 +02:00
|
|
|
# Prepare repository
|
2020-08-19 00:57:20 +02:00
|
|
|
cd $TRAVIS_BUILD_DIR
|
2020-08-19 12:35:07 +02:00
|
|
|
git clone --depth=1 "git@ssh.git.ignuranza.net:tdlight-team/tdlight-java-natives-$TRAVIS_OS_NAME_STANDARD-$TRAVIS_CPU_ARCH_STANDARD.git"
|
2020-08-18 17:27:52 +02:00
|
|
|
cd "tdlight-java-natives-$TRAVIS_OS_NAME_STANDARD-$TRAVIS_CPU_ARCH_STANDARD"
|
2020-08-19 11:40:49 +02:00
|
|
|
mkdir -p "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD"
|
2020-08-19 17:57:33 +02:00
|
|
|
mv "$TRAVIS_BUILD_DIR/out/$SRC_TDJNI_LIBNAME" "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD/$DEST_TDJNI_LIBNAME"
|
2020-08-18 21:05:38 +02:00
|
|
|
|
2020-08-19 00:57:20 +02:00
|
|
|
# IF THE NATIVE LIBRARY IS CHANGED
|
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
|
2020-08-19 00:57:20 +02:00
|
|
|
# Do the upgrade of the repository
|
2020-08-19 17:57:33 +02:00
|
|
|
git add "src/main/resources/libs/$TRAVIS_OS_NAME_SHORT/$TRAVIS_CPU_ARCH_STANDARD/$DEST_TDJNI_LIBNAME"
|
2020-08-19 00:57:20 +02:00
|
|
|
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
|
|
|
|
mvn -B -V deploy
|
|
|
|
|
|
|
|
# Upgrade the dependency of tdlight-java
|
|
|
|
cd $TRAVIS_BUILD_DIR
|
2020-08-19 16:19:38 +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-19 12:54:45 +02:00
|
|
|
cd $TRAVIS_BUILD_DIR/tdlight-java
|
|
|
|
git checkout master
|
2020-08-19 00:57:20 +02:00
|
|
|
mvn versions:use-latest-releases -Dincludes=it.tdlight:tdlight-natives-$TRAVIS_OS_NAME_STANDARD-$TRAVIS_CPU_ARCH_STANDARD
|
2020-08-19 14:39:22 +02:00
|
|
|
[ -f pom.xml.versionsBackup ] && rm pom.xml.versionsBackup
|
2020-08-19 00:57:20 +02:00
|
|
|
git add pom.xml
|
|
|
|
git commit -m "Upgrade $TRAVIS_OS_NAME_STANDARD-$TRAVIS_CPU_ARCH_STANDARD natives"
|
|
|
|
git push
|
|
|
|
else
|
2020-08-18 21:28:30 +02:00
|
|
|
echo "Binaries are already updated."
|
2020-08-18 21:05:38 +02:00
|
|
|
fi
|
|
|
|
|
2020-08-19 00:57:20 +02:00
|
|
|
if [ "$TRAVIS_OS_NAME_STANDARD" = "linux" ]; then
|
|
|
|
if [ "$TRAVIS_CPU_ARCH" = "amd64" ]; then
|
2020-08-18 21:28:30 +02:00
|
|
|
|
2020-08-19 20:13:35 +02:00
|
|
|
# Patch TdApi.java
|
2020-08-19 00:57:20 +02:00
|
|
|
echo "Patching TdApi.java"
|
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-19 20:13:35 +02:00
|
|
|
|
2020-08-19 12:44:47 +02:00
|
|
|
# Upgrade the file of tdlight-java
|
|
|
|
cd $TRAVIS_BUILD_DIR
|
2020-08-19 16:19:38 +02:00
|
|
|
[ -d tdlight-java ] && sudo rm -rf --interactive=never tdlight-java
|
2020-08-19 13:07:21 +02:00
|
|
|
git clone --depth=1 -b master --single-branch git@ssh.git.ignuranza.net:tdlight-team/tdlight-java.git
|
2020-08-19 12:54:45 +02:00
|
|
|
cd $TRAVIS_BUILD_DIR/tdlight-java
|
|
|
|
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
|
2020-08-19 00:57:20 +02:00
|
|
|
|
|
|
|
# IF TdApi.java IS CHANGED
|
2020-08-20 02:01:54 +02:00
|
|
|
if [[ ! -z "$(git status --porcelain | grep "$JAVA_SRC_DIR/it/tdlight/tdlib/TdApi.java")" ]]; then
|
2020-08-19 00:57:20 +02:00
|
|
|
# Upgrade TdApi.java in repository master
|
2020-08-19 12:54:45 +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
|
2020-08-19 00:57:20 +02:00
|
|
|
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
|