From 04a5d7a9e0ede376ffcd33d66f45b8d891087de5 Mon Sep 17 00:00:00 2001 From: adityastic Date: Mon, 1 Jul 2019 18:52:18 +0530 Subject: [PATCH] enhancement: improved APK Names --- scripts/prep-key.sh | 7 ++++--- scripts/upload-apk.sh | 38 ++++++++++++++++---------------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/scripts/prep-key.sh b/scripts/prep-key.sh index de8b1147d..8565f125d 100644 --- a/scripts/prep-key.sh +++ b/scripts/prep-key.sh @@ -1,10 +1,11 @@ #!/bin/sh set -e -export DEPLOY_BRANCH=${DEPLOY_BRANCH:-master} +export DEPLOY_BRANCH=${DEPLOY_BRANCH:-development} +export PUBLISH_BRANCH=${PUBLISH_BRANCH:-master} -if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/badge-magic-android" -o "$TRAVIS_BRANCH" != "$DEPLOY_BRANCH" ]; then - echo "We decrypt key only for pushes to the master branch and not PRs. So, skip." +if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/badge-magic-android" ] || ! [ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" -o "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]; then + echo "We decrypt key only for pushes to the master or development branch and not PRs. So, skip." exit 0 fi diff --git a/scripts/upload-apk.sh b/scripts/upload-apk.sh index c748876b6..74b1ebfb0 100644 --- a/scripts/upload-apk.sh +++ b/scripts/upload-apk.sh @@ -22,30 +22,24 @@ else fi \cp -r ../app/build/outputs/apk/*/**.apk . -\cp -r ../app/build/outputs/apk/debug/output.json debug-output.json -\cp -r ../app/build/outputs/apk/release/output.json release-output.json -\cp -r ../README.md . # Signing Apps - -if [[ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]]; then - echo "Push to master branch detected, signing the app..." - cp app-release-unsigned.apk app-release-unaligned.apk - jarsigner -verbose -tsa http://timestamp.comodoca.com/rfc3161 -sigalg SHA1withRSA -digestalg SHA1 -keystore ../scripts/key.jks -storepass $STORE_PASS -keypass $KEY_PASS app-release-unaligned.apk $ALIAS - ${ANDROID_HOME}/build-tools/28.0.3/zipalign -v -p 4 app-release-unaligned.apk app-release.apk -fi - -if [[ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]]; then - for file in app*; do - mv ${file} badge-magic-master-${file%%} - done -fi - -if [[ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" ]]; then - for file in app*; do - mv ${file} badge-magic-dev-${file%%} - done -fi +cp app-release-unsigned.apk app-release-unaligned.apk +jarsigner -verbose -tsa http://timestamp.comodoca.com/rfc3161 -sigalg SHA1withRSA -digestalg SHA1 -keystore ../scripts/key.jks -storepass $STORE_PASS -keypass $KEY_PASS app-release-unaligned.apk $ALIAS +${ANDROID_HOME}/build-tools/28.0.3/zipalign -v -p 4 app-release-unaligned.apk app-release.apk + +#removing unused apps +for file in app*; do + if [[ ${file} =~ "unsigned" || ${file} =~ "unaligned" ]]; then + rm ${file} + else + if [[ "$TRAVIS_BRANCH" == "$PUBLISH_BRANCH" ]]; then + mv ${file} badge-magic-master-${file:4} + elif [[ "$TRAVIS_BRANCH" == "$DEPLOY_BRANCH" ]]; then + mv ${file} badge-magic-dev-${file:4} + fi + fi +done # Create a new branch that will contains only latest apk git checkout --orphan temporary