From 31723008ed6867ed352b81c2159bbe2c918a787f Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Wed, 15 Apr 2020 16:09:29 +0000 Subject: [PATCH] [CI] publish signed builds from master to nextcloud (#416) publish builds from master Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/416 Reviewed-by: M M Arif --- .drone.yml | 26 ++++++++++++++++++++++++++ scripts/sign-build.sh | 16 ++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 scripts/sign-build.sh diff --git a/.drone.yml b/.drone.yml index 7172c084..0f0fa5d3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -24,6 +24,32 @@ steps: commands: - ./gradlew build + - name: sign + image: nextcloudci/android:android-49 + environment: + TOKEN: + from_secret: BOT_TOKEN + KS_PASS: + from_secret: KS_PASS + KEY_PASS: + from_secret: KEY_PASS + OUTPUT: signed.apk + GITEA: https://gitea.com + KS_FILE: ci_keystore.jks + KS_REPO: + from_secret: KS_REPO + commands: + - ./scripts/sign-build.sh + + - name: publish + image: vividboarder/drone-webdav + environment: + WEBDAV_USERNAME: GitNexBot + WEBDAV_PASSWORD: + from_secret: NC_TOKEN + PLUGIN_FILE: signed.apk + PLUGIN_DESTINATION: https://cloud.swatian.com/remote.php/dav/files/GitNexBot/GitNex-Builds/latest.apk + trigger: event: - push diff --git a/scripts/sign-build.sh b/scripts/sign-build.sh new file mode 100755 index 00000000..03903f31 --- /dev/null +++ b/scripts/sign-build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +#make sure needed var's are here +[ -z "${TOKEN}" ] && { echo "missing TOKEN"; exit 1; } +[ -z "${KS_PASS}" ] && { echo "missing KS_PASS"; exit 1; } +[ -z "${KEY_PASS}" ] && { echo "missing KEY_PASS"; exit 1; } +[ -z "${GITEA}" ] && { echo "missing GITEA"; exit 1; } +[ -z "${KS_REPO}" ] && { echo "missing KS_REPO"; exit 1; } +[ -z "${KS_FILE}" ] && { echo "missing KS_FILE"; exit 1; } +[ -z "${OUTPUT}" ] && { echo "missing OUTPUT"; exit 1; } + + +KEYFILE=$(mktemp) +curl -X GET "${GITEA}/api/v1/repos/${KS_REPO}/contents/${KS_FILE}?token=${TOKEN}" -H "accept: application/json" | sed 's|"content":"|#|g' | cut -d '#' -f 2 | cut -d '"' -f 1 | base64 -d > ${KEYFILE} + +/opt/android-sdk-linux/build-tools/*/apksigner sign -v --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias GitNexBot --ks ${KEYFILE} --out signed.apk $(find . -name "*release*.apk")