From 238acf40fddee3d8333f5313a4286a8b3936be27 Mon Sep 17 00:00:00 2001 From: Override-6 Date: Sun, 4 Dec 2022 18:20:26 +0100 Subject: [PATCH] adding drone supports --- drone/.drone.yml | 25 ++++++++++++++++++++++++ drone/android-sign.sh | 13 +++++++++++++ drone/deliver.sh | 45 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 drone/.drone.yml create mode 100755 drone/android-sign.sh create mode 100755 drone/deliver.sh diff --git a/drone/.drone.yml b/drone/.drone.yml new file mode 100644 index 0000000..e1ddf2e --- /dev/null +++ b/drone/.drone.yml @@ -0,0 +1,25 @@ +kind: pipeline +type: docker +name: Deliver + +environment: + SSH_PRIVATE_KEY: + from_secret: SSH_PRIVATE + SSH_PUBLIC_KEY: + from_secret: SSH_PUBLIC + +steps: + - name: Android + image: mingc/android-build-box + commands: + - drone/deliver.sh android + - drone/android-sign.sh + - name: Electron + image: ubuntu:latest + commands: + - drone/deliver.sh electron + - name: Web + image: ubuntu:latest + commands: + - drone/deliver.sh electron + diff --git a/drone/android-sign.sh b/drone/android-sign.sh new file mode 100755 index 0000000..21501f8 --- /dev/null +++ b/drone/android-sign.sh @@ -0,0 +1,13 @@ +#!/usr/bin/bash + +apt install apksigner > /dev/null + +if [ $DRONE_BRANCH = "dev" ]; then + ARTIFACT_TYPE="debug" +elif [ $DRONE_BRANCH = "production" ]; then + ARTIFACT_TYPE="release" +fi + +mv app-$ARTIFACT_TYPE-unsigned.apk tbasket-$ARTIFACT_TYPE.apk +apksigner sign --ks /home/maxime/server/TBasket/application/android/tbasket.keystore tbasket-$ARTIFACT_TYPE.apk +echo "apk has been signed." \ No newline at end of file diff --git a/drone/deliver.sh b/drone/deliver.sh new file mode 100755 index 0000000..878a9f8 --- /dev/null +++ b/drone/deliver.sh @@ -0,0 +1,45 @@ +#!/usr/bin/bash + +TYPE="$1" +case "$DRONE_BRANCH" in + "production") + OPTIONS="--release" + ;; + "") + echo '$DRONE_BRANCH not set' >&2 + exit 1 + ;; + *) + OPTIONS="--debug" + ;; +esac + +APP_DIR="/home/maxime/server/TBasket/application" + +case "$TYPE" in + "android") + OPTIONS="$OPTIONS -- --packageType=apk" + OUT_DIR="platforms/android/app/build/outputs/apk" + ;; + "browser") + OUT_DIR="platforms/browser/www" + ;; + "electron") + OUT_DIR="platforms/electron/build" + ;; + *) + echo "unrecognized platform $TYPE." >&2 + ;; +esac + +SERV_DIR="$APP_DIR/$TYPE" + +cordova build "$TYPE" $OPTIONS +echo "delivering outputs on server" + +#prepare ssh / scp commands +curl https://codefirst.iut.uca.fr/git/Tactique-basket/Backend/raw/branch/dev/drone/prepare-deliver.sh > /tmp/prepare-deliver.sh +source /tmp/prepare-deliver.sh + +echo "making delivery onto '$USER@$IP:$DIR'" +scp -o "StrictHostKeyChecking no" "$OUT_DIR" "$USER@$IP:$SERV_DIR" \ No newline at end of file