From e4aac462c8c3234e03cfcbe59c767dba20fc61af Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 12 Feb 2021 19:56:38 -0500 Subject: [PATCH] [SKIP CI] Parallelize APK signing step --- .github/scripts/sign-apks.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/scripts/sign-apks.sh b/.github/scripts/sign-apks.sh index 491219f2f..9c475c363 100755 --- a/.github/scripts/sign-apks.sh +++ b/.github/scripts/sign-apks.sh @@ -24,18 +24,29 @@ export KEY_PASSWORD=$4 DEST=$PWD/apk rm -rf $DEST && mkdir -p $DEST +MAX_PARALLEL=4 + # Sign all of the APKs for APK in ${APKS[@]}; do - BASENAME=$(basename $APK) - APKNAME="${BASENAME%%+(-release*)}.apk" - APKDEST="$DEST/$APKNAME" + ( + BASENAME=$(basename $APK) + APKNAME="${BASENAME%%+(-release*)}.apk" + APKDEST="$DEST/$APKNAME" - ${TOOLS}/zipalign -c -v -p 4 $APK + ${TOOLS}/zipalign -c -v -p 4 $APK - cp $APK $APKDEST - ${TOOLS}/apksigner sign --ks $STORE_PATH --ks-key-alias $STORE_ALIAS --ks-pass env:KEY_STORE_PASSWORD --key-pass env:KEY_PASSWORD $APKDEST + cp $APK $APKDEST + ${TOOLS}/apksigner sign --ks $STORE_PATH --ks-key-alias $STORE_ALIAS --ks-pass env:KEY_STORE_PASSWORD --key-pass env:KEY_PASSWORD $APKDEST + ) & + + # Allow to execute up to $MAX_PARALLEL jobs in parallel + if [[ $(jobs -r -p | wc -l) -ge $MAX_PARALLEL ]]; then + wait -n + fi done +wait + rm $STORE_PATH unset KEY_STORE_PASSWORD unset KEY_PASSWORD