From ff4deb33189633fe60005e0531f1767d7b804973 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sat, 27 Nov 2021 21:02:01 +0100 Subject: saving some lines of code by compressing if statements a little bit --- scripts/prepareForDistribution.sh | 88 +++++++++++++-------------------------- 1 file changed, 29 insertions(+), 59 deletions(-) diff --git a/scripts/prepareForDistribution.sh b/scripts/prepareForDistribution.sh index c81ca2fc..f1e1e044 100755 --- a/scripts/prepareForDistribution.sh +++ b/scripts/prepareForDistribution.sh @@ -23,12 +23,10 @@ function quit { } function cleanUp { - if [[ -f ${ALIGNED_UNSIGNED_APK} ]] - then + if [[ -f ${ALIGNED_UNSIGNED_APK} ]]; then rm ${ALIGNED_UNSIGNED_APK} fi - if [[ -f ${ALIGNED_SIGNED_APK} ]] - then + if [[ -f ${ALIGNED_SIGNED_APK} ]]; then rm ${ALIGNED_SIGNED_APK} fi } @@ -59,14 +57,12 @@ function sign { cleanUp #---- GPG SIGNING ---- - if [[ -z ${GPG_KEY} && -z ${GPG_KEY_USER} ]] - then + if [[ -z ${GPG_KEY} && -z ${GPG_KEY_USER} ]]; then echo -e "${ORANGE}WARNING: Could not do gpg signing!${NC}" exit fi - if [[ ${GPG_KEY} ]] - then + if [[ ${GPG_KEY} ]]; then echo -e "${GREEN} -> gpg sign using key ${GPG_KEY}${NC}" gpg --default-key ${GPG_KEY} --armor --output "${FINAL_APK}.sig" --detach-sign ${FINAL_APK} || quit else @@ -114,36 +110,29 @@ export -f cleanUp # init parameters for ((i=1;i<=$#;i++)); do - if [[ ${!i} = "b" || ${!i} = "build" ]] - then + if [[ ${!i} = "b" || ${!i} = "build" ]]; then DO_BUILD=true - elif [[ ${!i} = "s" || ${!i} = "sign" ]] - then + elif [[ ${!i} = "s" || ${!i} = "sign" ]]; then DO_SIGN=true - elif [[ ${!i} = "-f" || ${!i} = "-file" ]] - then + elif [[ ${!i} = "-f" || ${!i} = "-file" ]]; then ((i++)) FILE_NAME_STRING=${!i} FILE_NAME=${FILE_NAME_STRING##*/} #remove everything till the last '/' FILE_DIR=${FILE_NAME_STRING%/*} #remove everything after the last '/' - elif [[ ${!i} = "-d" || ${!i} = "-dir" ]] - then + elif [[ ${!i} = "-d" || ${!i} = "-dir" ]]; then ((i++)) FILE_DIR=${!i} MULTIPLE_APKS=true - elif [[ ${!i} = "-ks" || ${!i} = "-keystore" ]] - then + elif [[ ${!i} = "-ks" || ${!i} = "-keystore" ]]; then ((i++)) KEY_STORE_STRING=${!i}; KEY_STORE_NAME=${KEY_STORE_STRING##*/} KEY_STORE_DIR=${KEY_STORE_STRING%/*} export KEY_STORE_STRING=${KEY_STORE_STRING} - - elif [[ ${!i} = "-v" || ${!i} = "-version" ]] - then + elif [[ ${!i} = "-v" || ${!i} = "-version" ]]; then ((i++)) VERSION_NAME=${!i}; if [[ -z $(git tag --list | grep -w ${VERSION_NAME}) ]] @@ -151,32 +140,25 @@ do echo -e "${RED}ERROR: Version name has to be a git tag!${NC}" exit fi - elif [[ ${!i} = "-k" || ${!i} = "-key" ]] - then + elif [[ ${!i} = "-k" || ${!i} = "-key" ]]; then ((i++)) GPG_KEY=${!i} export GPG_KEY=${GPG_KEY} - elif [[ ${!i} = "-u" || ${!i} = "-user" ]] - then + elif [[ ${!i} = "-u" || ${!i} = "-user" ]]; then ((i++)) GPG_KEY_USER=${!i} export GPG_KEY_USER=${GPG_KEY_USER} - elif [[ ${!i} = "-b" || ${!i} = "-beta" ]] - then + elif [[ ${!i} = "-b" || ${!i} = "-beta" ]]; then BETA=true - elif [[ ${!i} = "-no-tag" ]]; - then + elif [[ ${!i} = "-no-tag" ]]; then NO_TAG=true - elif [[ ${!i} = "-s" || ${!i} = "-stacktrace" ]] - then + elif [[ ${!i} = "-s" || ${!i} = "-stacktrace" ]]; then STACKTRACE="--stacktrace" - elif [[ ${!i} = "-c" || ${!i} = "-custom" ]] - then + elif [[ ${!i} = "-c" || ${!i} = "-custom" ]]; then ((i++)) FLAVOR="Custom" FLAVOR_LOWERCASE="custom" - elif [[ ${!i} = "-h" || ${!i} = "-help" ]] - then + elif [[ ${!i} = "-h" || ${!i} = "-help" ]]; then echo -e " sign [-ks -fp -f -u -k] sign a given apk (both app signing and GPG signing) -ks / -keystore [path] -------------- define path to keystore for signing (required) @@ -242,21 +224,17 @@ done; # check what to do -if [[ ${DO_BUILD} == false && ${DO_SIGN} == false ]] -then +if [[ ${DO_BUILD} == false && ${DO_SIGN} == false ]]; then echo -e "${RED}ERROR: No action set. Please check ./prepareForDistribution -help!${NC}" exit fi -if [[ ${DO_BUILD} == true ]] -then - if [[ ${NO_TAG} == false && -z ${VERSION_NAME} ]] - then +if [[ ${DO_BUILD} == true ]]; then + if [[ ${NO_TAG} == false && -z ${VERSION_NAME} ]]; then echo -e "${RED}ERROR: You didn't enter the version (git tag) to be built. If you really want to force building the current checked out commit, use -no-tag.${NC}" quit fi - if [[ ${NO_TAG} == false ]] - then + if [[ ${NO_TAG} == false ]]; then #---- COMPARE TAG COMMIT WITH CURRENT COMMIT AND CHECK OUT TAG COMMIT IF NECESSARY ---- TAG_COMMIT=$(git log -n 1 ${VERSION_NAME} --format="%H") CURRENT_COMMIT=$(git log -n 1 --format="%H") @@ -274,14 +252,12 @@ then cd $(base_dir) BASE_OUTPUT_DIR="./app/build/outputs/apk" RELEASES_FILE_DIR="./currentReleases" - if [[ ! -d $RELEASES_FILE_DIR ]] - then + if [[ ! -d $RELEASES_FILE_DIR ]]; then mkdir $RELEASES_FILE_DIR fi rm -rf $RELEASES_FILE_DIR/* - if [[ ${BETA} == true ]] - then + if [[ ${BETA} == true ]]; then echo "${GREEN} -> build beta releases for flavor ${FLAVOR}${NC}" ./gradlew clean assemble${FLAVOR}ProductionFatBeta $STACKTRACE || quit # echo "copy file: $(ls $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFat/beta/*.apk)" @@ -338,36 +314,30 @@ if [[ ${DO_SIGN} == true ]] then cd $(base_dir) # check global vars - if [[ -z ${ANDROID_BUILD_TOOLS} ]] - then + if [[ -z ${ANDROID_BUILD_TOOLS} ]]; then echo -e "${RED}ERROR: Environment variable ANDROID_BUILD_TOOLS not set! Please add it to your environment variables. Exiting.${NC}" exit fi - if [[ -z ${FILE_NAME} && -z ${FILE_DIR} && ${DO_BUILD} == false ]] - then + if [[ -z ${FILE_NAME} && -z ${FILE_DIR} && ${DO_BUILD} == false ]]; then echo -e "${RED}ERROR: Sign only needs a file name or a directory. Please check ./prepareForDistribution -help!${NC}" exit fi - if [[ -z ${KEY_STORE_NAME} ]] - then + if [[ -z ${KEY_STORE_NAME} ]]; then echo -e "${RED}ERROR: Key store not set. Please check ./prepareForDistribution -help${NC}" exit fi - if [[ -n ${FILE_NAME_STRING} && ${DO_BUILD} == true ]] - then + if [[ -n ${FILE_NAME_STRING} && ${DO_BUILD} == true ]]; then echo -e "${ORANGE}WARNING: Ignoring parameter -file. Built APK will be used instead.${NC}" fi #---- OPT: SELECT APK FROM LAST BUILD ---- - if [[ ${DO_BUILD} == true ]] - then + if [[ ${DO_BUILD} == true ]]; then FILE_DIR=$RELEASES_FILE_DIR echo -e "${GREEN} -> sign apks:${NC}" ls -w 1 $FILE_DIR/*\.apk | xargs -I {} echo {} xargs -I _ -ra <(ls -w 1 $FILE_DIR/*\.apk) bash -c 'sign _' - elif [[ ${MULTIPLE_APKS} == true ]] - then + elif [[ ${MULTIPLE_APKS} == true ]]; then echo -e "${GREEN} -> sign apks:${NC}" ls -w 1 $FILE_DIR/*\.apk | xargs -I {} echo {} xargs -I _ -ra <(ls -w 1 $FILE_DIR/*\.apk) bash -c 'sign _' -- cgit v1.2.3 From 7e7758474765f449914f36915937402f7ce25099 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 28 Nov 2021 11:02:24 +0100 Subject: sign bundles from command line --- scripts/prepareForDistribution.sh | 58 +++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/scripts/prepareForDistribution.sh b/scripts/prepareForDistribution.sh index f1e1e044..a25b350b 100755 --- a/scripts/prepareForDistribution.sh +++ b/scripts/prepareForDistribution.sh @@ -40,28 +40,65 @@ function sign { FILE_DIR=${FILE_NAME_STRING%/*} #remove everything after the last '/' fi + if [[ $FILE_NAME == *.aab ]]; then + sign_bundle $FILE_NAME $FILE_DIR + else + sign_apk $FILE_NAME $FILE_DIR + fi + + cleanUp + + gpg_sign $FILE_NAME_STRING +} + +function sign_apk { + FILE_NAME=$1 + FILE_DIR=$2 FINAL_APK="${FILE_DIR}/${FILE_NAME}" echo -e "${GREEN} -> apksign ${FINAL_APK}${NC}" ${ANDROID_BUILD_TOOLS}/apksigner sign --ks "${KEY_STORE_STRING}" --out ${FINAL_APK} ${FINAL_APK} || quit + verifySigned $FINAL_APK +} - FINGERPRINT=$(unzip -p ${FINAL_APK} META-INF/*.RSA | keytool -printcert | grep "SHA256" | tr -d '[:space:]') || quit - - if [[ ${FINGERPRINT} == ${EXPECTED_FINGERPRINT} ]] - then +function sign_bundle { + FILENAME=$1 + FILE_DIR=$2 + FINAL_AAB="${FILE_DIR}/${FILE_NAME}" + echo -e "${GREEN} -> jarsign ${FINAL_AAB}${NC}" + if [[ -z $(which jarsigner) ]]; then + echo -e "${RED}ERROR: jarsigner not in path. Please add it to your path variable. jarsigner is part of your JDK installation. Exiting.${NC}" + exit + fi; + + if [[ -z $KEYSTORE_ALIAS ]]; then + echo -e "${RED}ERROR: keystore alias is missing. Please add flag -ka . Exiting.${NC}" + exit + fi; + echo "jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore "KEY_STORE_STRING" $FINAL_AAB $KEYSTORE_ALIAS +" + jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore "${KEY_STORE_STRING}" $FINAL_AAB $KEYSTORE_ALIAS || quit + verifySigned $FINAL_AAB +} + +function verifySigned { + FINAL_FILE=$1 + FINGERPRINT=$(unzip -p ${FINAL_FILE} META-INF/*.RSA | keytool -printcert | grep "SHA256" | tr -d '[:space:]') || quit + + if [[ ${FINGERPRINT} == ${EXPECTED_FINGERPRINT} ]]; then echo "Certificate fingerprint matches: ${FINGERPRINT}" - else + else echo -e "${RED}Certificate fingerprint \n${FINGERPRINT} \ndid not match expected fingerprint \n\t${EXPECTED_FINGERPRINT}${NC}" quit fi +} - cleanUp - - #---- GPG SIGNING ---- +function gpg_sign { + FINAL_APK=$1 if [[ -z ${GPG_KEY} && -z ${GPG_KEY_USER} ]]; then echo -e "${ORANGE}WARNING: Could not do gpg signing!${NC}" exit fi - + if [[ ${GPG_KEY} ]]; then echo -e "${GREEN} -> gpg sign using key ${GPG_KEY}${NC}" gpg --default-key ${GPG_KEY} --armor --output "${FINAL_APK}.sig" --detach-sign ${FINAL_APK} || quit @@ -132,6 +169,9 @@ do KEY_STORE_NAME=${KEY_STORE_STRING##*/} KEY_STORE_DIR=${KEY_STORE_STRING%/*} export KEY_STORE_STRING=${KEY_STORE_STRING} + elif [[ ${!i} = "-ka" || ${!i} = "-keystorealias" ]]; then + ((i++)) + export KEYSTORE_ALIAS=${!i}; elif [[ ${!i} = "-v" || ${!i} = "-version" ]]; then ((i++)) VERSION_NAME=${!i}; -- cgit v1.2.3 From 79658de3868cc8935b1d8a130c57ea36dd09db1c Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 28 Nov 2021 13:03:41 +0100 Subject: use snake_case instead of camelCase for functions in bash --- scripts/prepareForDistribution.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/prepareForDistribution.sh b/scripts/prepareForDistribution.sh index a25b350b..060ecf9f 100755 --- a/scripts/prepareForDistribution.sh +++ b/scripts/prepareForDistribution.sh @@ -18,11 +18,11 @@ function quit { echo -e "${RED}Task failed. Exit value: $?.${NC}" - cleanUp + clean_up exit 1 } -function cleanUp { +function clean_up { if [[ -f ${ALIGNED_UNSIGNED_APK} ]]; then rm ${ALIGNED_UNSIGNED_APK} fi @@ -46,7 +46,7 @@ function sign { sign_apk $FILE_NAME $FILE_DIR fi - cleanUp + clean_up gpg_sign $FILE_NAME_STRING } @@ -57,7 +57,7 @@ function sign_apk { FINAL_APK="${FILE_DIR}/${FILE_NAME}" echo -e "${GREEN} -> apksign ${FINAL_APK}${NC}" ${ANDROID_BUILD_TOOLS}/apksigner sign --ks "${KEY_STORE_STRING}" --out ${FINAL_APK} ${FINAL_APK} || quit - verifySigned $FINAL_APK + verify_signed $FINAL_APK } function sign_bundle { @@ -77,10 +77,10 @@ function sign_bundle { echo "jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore "KEY_STORE_STRING" $FINAL_AAB $KEYSTORE_ALIAS " jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore "${KEY_STORE_STRING}" $FINAL_AAB $KEYSTORE_ALIAS || quit - verifySigned $FINAL_AAB + verify_signed $FINAL_AAB } -function verifySigned { +function verify_signed { FINAL_FILE=$1 FINGERPRINT=$(unzip -p ${FINAL_FILE} META-INF/*.RSA | keytool -printcert | grep "SHA256" | tr -d '[:space:]') || quit @@ -141,7 +141,7 @@ export NC=${NC} export EXPECTED_FINGERPRINT=${EXPECTED_FINGERPRINT} export -f sign export -f quit -export -f cleanUp +export -f clean_up # init parameters -- cgit v1.2.3 From 61325e824c9d792a0fafb638abca73f68be07125 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 28 Nov 2021 13:07:49 +0100 Subject: build aabs, introduce new mutual exclusive flags to either build and sign apks or aab, don't them if you want to build apk and aab at the same time --- scripts/prepareForDistribution.sh | 134 +++++++++++++++++++++++++------------- 1 file changed, 88 insertions(+), 46 deletions(-) diff --git a/scripts/prepareForDistribution.sh b/scripts/prepareForDistribution.sh index 060ecf9f..8814644e 100755 --- a/scripts/prepareForDistribution.sh +++ b/scripts/prepareForDistribution.sh @@ -142,6 +142,10 @@ export EXPECTED_FINGERPRINT=${EXPECTED_FINGERPRINT} export -f sign export -f quit export -f clean_up +export -f sign_apk +export -f sign_bundle +export -f verify_signed +export -f gpg_sign # init parameters @@ -198,6 +202,10 @@ do ((i++)) FLAVOR="Custom" FLAVOR_LOWERCASE="custom" + elif [[ ${!i} = "-aab" ]]; then + BUILD_BUNDLE=true + elif [[ ${!i} = "-apk" ]]; then + BUILD_APK=true elif [[ ${!i} = "-h" || ${!i} = "-help" ]]; then echo -e " sign [-ks -fp -f -u -k] sign a given apk (both app signing and GPG signing) @@ -219,6 +227,8 @@ do -c / -custom ------------------------ build custom Bitmask client instead of main Bitmask client (optional) -b / -beta -------------------------- build beta version with .beta appended to applicationId (optional) + -apk -------------------------------- build only apk(s) + -aab -------------------------------- build only android app bundle -no-tag ----------------------------- force to build current checked out git commit instead of an official release version -s / -stacktrace -------------------- show verbose debug output @@ -274,6 +284,19 @@ if [[ ${DO_BUILD} == true ]]; then echo -e "${RED}ERROR: You didn't enter the version (git tag) to be built. If you really want to force building the current checked out commit, use -no-tag.${NC}" quit fi + if [[ ${BUILD_APK} == true && ${BUILD_AAB} == true ]]; then + echo -e "${RED}ERROR: the flags -apk and -aab are mutually exclusive. To build apks and aab, please remove both flags.${NC}" + quit + fi + if [[ ${DO_SIGN} == true && -z ${BUILD_APK} && -z ${BUILD_AAB} && -z ${KEYSTORE_ALIAS} ]]; then + echo -e "${RED}ERROR: keystore alias is missing. Please add flag -ka . Exiting.${NC}" + quit + fi + if [[ ${DO_SIGN} == true && ${BUILD_AAB} && -z ${KEYSTORE_ALIAS} ]]; then + echo -e "${RED}ERROR: keystore alias is missing. Please add flag -ka . Exiting.${NC}" + quit + fi + if [[ ${NO_TAG} == false ]]; then #---- COMPARE TAG COMMIT WITH CURRENT COMMIT AND CHECK OUT TAG COMMIT IF NECESSARY ---- TAG_COMMIT=$(git log -n 1 ${VERSION_NAME} --format="%H") @@ -290,7 +313,8 @@ if [[ ${DO_BUILD} == true ]]; then $(script_dir)/fix_gradle_lock.sh || quit cd $(base_dir) - BASE_OUTPUT_DIR="./app/build/outputs/apk" + BASE_APK_OUTPUT_DIR="./app/build/outputs/apk" + BASE_BUNDLE_OUTPUT_DIR="./app/build/outputs/bundle" RELEASES_FILE_DIR="./currentReleases" if [[ ! -d $RELEASES_FILE_DIR ]]; then mkdir $RELEASES_FILE_DIR @@ -298,52 +322,64 @@ if [[ ${DO_BUILD} == true ]]; then rm -rf $RELEASES_FILE_DIR/* if [[ ${BETA} == true ]]; then - echo "${GREEN} -> build beta releases for flavor ${FLAVOR}${NC}" - ./gradlew clean assemble${FLAVOR}ProductionFatBeta $STACKTRACE || quit - # echo "copy file: $(ls $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFat/beta/*.apk)" - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFat/beta/*.apk $RELEASES_FILE_DIR/. - - # custom builds might have disabled split apks -> check if build task exist - if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionX86Beta) ]]; then - ./gradlew clean assemble${FLAVOR}ProductionX86Beta $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionX86/beta/*.apk $RELEASES_FILE_DIR/. - fi - if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionX86_64Beta) ]]; then - ./gradlew clean assemble${FLAVOR}ProductionX86_64Beta $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionX86_64/beta/*.apk $RELEASES_FILE_DIR/. - fi - if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionArmv7Beta) ]]; then - ./gradlew clean assemble${FLAVOR}ProductionArmv7Beta $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArmv7/beta/*.apk $RELEASES_FILE_DIR/. - fi - if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionArmv7Beta) ]]; then - ./gradlew clean assemble${FLAVOR}ProductionArm64Beta $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArm64/beta/*.apk $RELEASES_FILE_DIR/. + if [[ -z ${BUILD_BUNDLE} ]]; then + echo "${GREEN} -> build beta releases (.apk) for flavor ${FLAVOR}${NC}" + ./gradlew clean assemble${FLAVOR}ProductionFatBeta $STACKTRACE || quit + # echo "copy file: $(ls $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFat/beta/*.apk)" + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFat/beta/*.apk $RELEASES_FILE_DIR/. + + # custom builds might have disabled split apks -> check if build task exist + if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionX86Beta) ]]; then + ./gradlew clean assemble${FLAVOR}ProductionX86Beta $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionX86/beta/*.apk $RELEASES_FILE_DIR/. + fi + if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionX86_64Beta) ]]; then + ./gradlew clean assemble${FLAVOR}ProductionX86_64Beta $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionX86_64/beta/*.apk $RELEASES_FILE_DIR/. + fi + if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionArmv7Beta) ]]; then + ./gradlew clean assemble${FLAVOR}ProductionArmv7Beta $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArmv7/beta/*.apk $RELEASES_FILE_DIR/. + fi + if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionArmv7Beta) ]]; then + ./gradlew clean assemble${FLAVOR}ProductionArm64Beta $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArm64/beta/*.apk $RELEASES_FILE_DIR/. + fi + elif [[ -z ${BUILD_APK} ]]; then + echo "${GREEN} -> build beta release (.aab) for flavor ${FLAVOR}${NC}" + ./gradlew clean bundle${FLAVOR}ProductionFatBeta $STACKTRACE || quit + cp $BASE_BUNDLE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFatBeta/*.aab $RELEASES_FILE_DIR/. fi else - echo -e "${GREEN} -> build stable releases for flavor ${FLAVOR}${NC}" - ./gradlew clean assemble${FLAVOR}ProductionFatRelease $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFat/release/*.apk $RELEASES_FILE_DIR/. - - ./gradlew clean assemble${FLAVOR}ProductionFatwebRelease $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFatweb/release/*.apk $RELEASES_FILE_DIR/. - - # custom builds might have disabled split apks -> check if build task exist - if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionX86Release) ]]; then - ./gradlew clean assemble${FLAVOR}ProductionX86Release $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionX86/release/*.apk $RELEASES_FILE_DIR/. - fi - if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionX86_64Release) ]]; then - ./gradlew clean assemble${FLAVOR}ProductionX86_64Release $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionX86_64/release/*.apk $RELEASES_FILE_DIR/. - fi - if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionArmv7Release) ]]; then - ./gradlew clean assemble${FLAVOR}ProductionArmv7Release $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArmv7/release/*.apk $RELEASES_FILE_DIR/. - fi - if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionArm64Release) ]]; then - ./gradlew clean assemble${FLAVOR}ProductionArm64Release $STACKTRACE || quit - cp $BASE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArm64/release/*.apk $RELEASES_FILE_DIR/. + if [[ -z ${BUILD_BUNDLE} ]]; then + echo -e "${GREEN} -> build stable releases (.apk) for flavor ${FLAVOR}${NC}" + ./gradlew clean assemble${FLAVOR}ProductionFatRelease $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFat/release/*.apk $RELEASES_FILE_DIR/. + + ./gradlew clean assemble${FLAVOR}ProductionFatwebRelease $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFatweb/release/*.apk $RELEASES_FILE_DIR/. + + # custom builds might have disabled split apks -> check if build task exist + if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionX86Release) ]]; then + ./gradlew clean assemble${FLAVOR}ProductionX86Release $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionX86/release/*.apk $RELEASES_FILE_DIR/. + fi + if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionX86_64Release) ]]; then + ./gradlew clean assemble${FLAVOR}ProductionX86_64Release $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionX86_64/release/*.apk $RELEASES_FILE_DIR/. + fi + if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionArmv7Release) ]]; then + ./gradlew clean assemble${FLAVOR}ProductionArmv7Release $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArmv7/release/*.apk $RELEASES_FILE_DIR/. + fi + if [[ $(./gradlew tasks --console plain | grep ${FLAVOR}ProductionArm64Release) ]]; then + ./gradlew clean assemble${FLAVOR}ProductionArm64Release $STACKTRACE || quit + cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArm64/release/*.apk $RELEASES_FILE_DIR/. + fi + elif [[ -z ${BUILD_APK} ]]; then + echo -e "${GREEN} -> build stable release (.aab) for flavor ${FLAVOR}${NC}" + ./gradlew clean bundle${FLAVOR}ProductionFatRelease $STACKTRACE || quit + cp $BASE_BUNDLE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFatRelease/*.aab $RELEASES_FILE_DIR/. fi fi @@ -377,12 +413,18 @@ then echo -e "${GREEN} -> sign apks:${NC}" ls -w 1 $FILE_DIR/*\.apk | xargs -I {} echo {} xargs -I _ -ra <(ls -w 1 $FILE_DIR/*\.apk) bash -c 'sign _' + echo -e "${GREEN} -> sign aab:${NC}" + ls -w 1 $FILE_DIR/*\.aab | xargs -I {} echo {} + xargs -I _ -ra <(ls -w 1 $FILE_DIR/*\.aab) bash -c 'sign _' elif [[ ${MULTIPLE_APKS} == true ]]; then echo -e "${GREEN} -> sign apks:${NC}" ls -w 1 $FILE_DIR/*\.apk | xargs -I {} echo {} xargs -I _ -ra <(ls -w 1 $FILE_DIR/*\.apk) bash -c 'sign _' + echo -e "${GREEN} -> sign aab:${NC}" + ls -w 1 $FILE_DIR/*\.aab | xargs -I {} echo {} + xargs -I _ -ra <(ls -w 1 $FILE_DIR/*\.aab) bash -c 'sign _' else - echo -e "${GREEN} -> sign apk: ${FILE_NAME_STRING}${NC}" + echo -e "${GREEN} -> sign apk/aab: ${FILE_NAME_STRING}${NC}" sign $FILE_NAME_STRING fi cd - -- cgit v1.2.3 From 424f63b41089e9ecc9b1afffd4017bc8be1c3a99 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 28 Nov 2021 13:11:25 +0100 Subject: fix -c flag parsing --- scripts/prepareForDistribution.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/prepareForDistribution.sh b/scripts/prepareForDistribution.sh index 8814644e..207c2983 100755 --- a/scripts/prepareForDistribution.sh +++ b/scripts/prepareForDistribution.sh @@ -199,7 +199,6 @@ do elif [[ ${!i} = "-s" || ${!i} = "-stacktrace" ]]; then STACKTRACE="--stacktrace" elif [[ ${!i} = "-c" || ${!i} = "-custom" ]]; then - ((i++)) FLAVOR="Custom" FLAVOR_LOWERCASE="custom" elif [[ ${!i} = "-aab" ]]; then -- cgit v1.2.3 From 525ed47b890dc061b9ba473465b961f28bd5ea50 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 28 Nov 2021 13:12:10 +0100 Subject: adapt help --- scripts/prepareForDistribution.sh | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/scripts/prepareForDistribution.sh b/scripts/prepareForDistribution.sh index 207c2983..bbb99740 100755 --- a/scripts/prepareForDistribution.sh +++ b/scripts/prepareForDistribution.sh @@ -207,8 +207,9 @@ do BUILD_APK=true elif [[ ${!i} = "-h" || ${!i} = "-help" ]]; then echo -e " - sign [-ks -fp -f -u -k] sign a given apk (both app signing and GPG signing) + sign [-ks -ka -fp -f -u -k] sign a given apk (both app signing and GPG signing) -ks / -keystore [path] -------------- define path to keystore for signing (required) + -ka / -keystorealias ---------------- keystore alias (required if aab is signed) -fp / -fingerprint [fingerprint] ---- define the fingerprint for the app (required for non-LEAP signed apps) -f / -file [inputfile] -------------- define path to apk going to be signed @@ -219,7 +220,7 @@ do -u will be ignored (optional) - build [-v, -c, -b, -no-tag, -s] + build [-v, -c, -b, -no-tag, -apk, -aab, -s] -v / -version [gittag] -------------- define the git version tag that needs to be checked out for building. It's also part of the resulting apk file name. (required if you don't use -no-tag) @@ -239,29 +240,24 @@ do example Usages: --------------- - * jarsign only: + ${GREEN}* jarsign only:${NC} ./prepareForDistribution.sh sign -f app/build/outputs/apk/app-production-beta.apk -ks ~/path/to/bitmask-android.keystore - - * jarsign and gpg sign only: + ${GREEN}* jarsign and gpg sign only:${NC} ./prepareForDistribution.sh sign -f app/build/outputs/apk/app-production-beta.apk -ks ~/path/to/bitmask-android.keystore -u GPG_USER - - * jarsign and gpg sign all apks in directory: + ${GREEN}* jarsign and gpg sign all apks in directory:${NC} ./prepareForDistribution.sh sign -d currentReleases/ -ks ~/path/to/bitmask-android.keystore -u GPG_USER - - * build custom stable + ${GREEN}* build custom stable:${NC} ./prepareForDistribution.sh build -v 0.9.7 -c - - * build and sign custom stable: + ${GREEN}* build and sign custom stable (apks and aab):${NC} ./prepareForDistribution.sh build sign -ks ~/path/to/bitmask-android.keystore -u GPG_USER -c -v 0.9.7 - - * build and sign custom beta: + ${GREEN}* build and sign custom beta (apks and aab):${NC} ./prepareForDistribution.sh build sign -ks ~/path/to/bitmask-android.keystore -u GPG_USER -c -b -v 0.9.7RC2 - - * build and sign stable: + ${GREEN}* build and sign stable (apks and aab):${NC} ./prepareForDistribution.sh build sign -ks ~/path/to/bitmask-android.keystore -u GPG_USER -v 0.9.7 - - * build and sign current git HEAD - ./prepareForDistribution.sh build sign -ks ~/path/to/bitmask-android.keystore -u GPG_USER -no-tag" + ${GREEN}* build and sign apks and bundle for current git HEAD:${NC} + ./prepareForDistribution.sh build sign -ks ~/path/to/bitmask-android.keystore -u GPG_USER -no-tag + ${GREEN}* build and sign bundle only for current git HEAD:${NC} + ./prepareForDistribution.sh build -aab sign -ks ~/path/to/bitmask-android.keystore -ka exampleAlias -u GPG_USER -no-tag" exit else @@ -307,9 +303,9 @@ if [[ ${DO_BUILD} == true ]]; then fi fi - $(script_dir)/cleanProject.sh || quit - $(script_dir)/build_deps.sh || quit - $(script_dir)/fix_gradle_lock.sh || quit + # $(script_dir)/cleanProject.sh || quit + # $(script_dir)/build_deps.sh || quit + # $(script_dir)/fix_gradle_lock.sh || quit cd $(base_dir) BASE_APK_OUTPUT_DIR="./app/build/outputs/apk" -- cgit v1.2.3 From 6079004c29c50190933aece99bd6d880a0733837 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 28 Nov 2021 13:38:20 +0100 Subject: ensure that both apk and aab is build if neither -apk nor -aab is set --- scripts/prepareForDistribution.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/prepareForDistribution.sh b/scripts/prepareForDistribution.sh index bbb99740..59b578cf 100755 --- a/scripts/prepareForDistribution.sh +++ b/scripts/prepareForDistribution.sh @@ -340,7 +340,8 @@ if [[ ${DO_BUILD} == true ]]; then ./gradlew clean assemble${FLAVOR}ProductionArm64Beta $STACKTRACE || quit cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArm64/beta/*.apk $RELEASES_FILE_DIR/. fi - elif [[ -z ${BUILD_APK} ]]; then + fi + if [[ -z ${BUILD_APK} ]]; then echo "${GREEN} -> build beta release (.aab) for flavor ${FLAVOR}${NC}" ./gradlew clean bundle${FLAVOR}ProductionFatBeta $STACKTRACE || quit cp $BASE_BUNDLE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFatBeta/*.aab $RELEASES_FILE_DIR/. @@ -371,7 +372,8 @@ if [[ ${DO_BUILD} == true ]]; then ./gradlew clean assemble${FLAVOR}ProductionArm64Release $STACKTRACE || quit cp $BASE_APK_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionArm64/release/*.apk $RELEASES_FILE_DIR/. fi - elif [[ -z ${BUILD_APK} ]]; then + fi + if [[ -z ${BUILD_APK} ]]; then echo -e "${GREEN} -> build stable release (.aab) for flavor ${FLAVOR}${NC}" ./gradlew clean bundle${FLAVOR}ProductionFatRelease $STACKTRACE || quit cp $BASE_BUNDLE_OUTPUT_DIR/${FLAVOR_LOWERCASE}ProductionFatRelease/*.aab $RELEASES_FILE_DIR/. -- cgit v1.2.3 From 6f9c952cf3163292f74bddf35b43edc9e2ae8893 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Sun, 28 Nov 2021 13:47:52 +0100 Subject: revert commenting out sub-scripts --- scripts/prepareForDistribution.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/prepareForDistribution.sh b/scripts/prepareForDistribution.sh index 59b578cf..817e4cc2 100755 --- a/scripts/prepareForDistribution.sh +++ b/scripts/prepareForDistribution.sh @@ -303,9 +303,9 @@ if [[ ${DO_BUILD} == true ]]; then fi fi - # $(script_dir)/cleanProject.sh || quit - # $(script_dir)/build_deps.sh || quit - # $(script_dir)/fix_gradle_lock.sh || quit + $(script_dir)/cleanProject.sh || quit + $(script_dir)/build_deps.sh || quit + $(script_dir)/fix_gradle_lock.sh || quit cd $(base_dir) BASE_APK_OUTPUT_DIR="./app/build/outputs/apk" -- cgit v1.2.3