deploy.sh (2557B)
1 #!/bin/bash 2 set -exuo pipefail 3 4 ARTIFACT_PATH="/artifacts/taler-android/${CI_COMMIT_REF}/donau-verificator" 5 APK_PATH="donau-verificator/build/outputs/apk/nightly/release/donau-verificator-nightly-release-unsigned.apk" 6 LINT_PATH="donau-verificator/build/reports/lint-results-fdroidDebug.html" 7 8 9 function build_apk { 10 [[ ! -f "${NIGHTLY_KEYSTORE_PATH}" ]] && return 1 11 echo "Building APK ..." 12 13 # Test and build the APK 14 ./gradlew :donau-verificator:check :donau-verificator:assembleNightlyRelease 15 16 # Sign the APK 17 apksigner sign \ 18 --ks "${NIGHTLY_KEYSTORE_PATH}" \ 19 --ks-key-alias "${NIGHTLY_KEYSTORE_ALIAS}" \ 20 --ks-pass env:NIGHTLY_KEYSTORE_PASS \ 21 "${APK_PATH}" 22 23 # Copy the APK and lint report to artifacts folder 24 mkdir -p "${ARTIFACT_PATH}" 25 cp "${APK_PATH}" "${ARTIFACT_PATH}"/donau-verificator-nightly-debug.apk 26 cp "${LINT_PATH}" "${ARTIFACT_PATH}" 27 } 28 29 30 function deploy_apk { 31 [[ ! -f "${SCP_SSH_KEY}" ]] && return 0 32 echo "Deploying APK to taler.net/files ..." 33 34 apk_dest="${SCP_SSH_PATH}"/donau-verificator/donau-verificator-nightly-debug-$(date -u +%s).apk 35 latest_dest="${SCP_SSH_PATH}"/donau-verificator/donau-verificator-nightly-debug-latest.apk 36 37 # Deploy APK to taler.net/files/donau-verificator 38 scp -i "${SCP_SSH_KEY}" \ 39 -o StrictHostKeyChecking=no \ 40 -o UserKnownHostsFile=/dev/null \ 41 "${APK_PATH}" \ 42 "${SCP_SSH_HOST}":"${apk_dest}" 43 44 # Create symbolic link to the latest version 45 ssh -i "${SCP_SSH_KEY}" \ 46 -o StrictHostKeyChecking=no \ 47 -o UserKnownHostsFile=/dev/null \ 48 "${SCP_SSH_HOST}" \ 49 ln -sfr "${apk_dest}" "${latest_dest}" 50 } 51 52 53 function deploy_fdroid { 54 [[ ! -f "${FDROID_REPO_KEY}" ]] && return 0 55 echo "Deploying APK to F-droid nightly ..." 56 57 # Copy keystore where SDK can find it 58 cp "${NIGHTLY_KEYSTORE_PATH}" /root/.android/debug.keystore 59 60 # Rename APK, so fdroid nightly accepts it (looks for *-debug.apk) 61 cp "${APK_PATH}" donau-verificator-debug.apk 62 63 fdroid --version 64 65 set +x 66 export DEBUG_KEYSTORE=$(cat "$FDROID_REPO_KEY") 67 set -x 68 69 # Deploy APK to nightly repository 70 export CI= 71 export CI_PROJECT_URL="https://gitlab.com/gnu-taler/fdroid-repo" 72 export CI_PROJECT_PATH="gnu-taler/fdroid-repo" 73 export GITLAB_USER_NAME="$(git log -1 --pretty=format:'%an')" 74 export GITLAB_USER_EMAIL="$(git log -1 --pretty=format:'%ae')" 75 76 fdroid nightly -v --archive-older 6 77 } 78 79 80 build_apk 81 deploy_apk 82 deploy_fdroid