Last active
March 11, 2019 20:27
-
-
Save hamidzr/df5f26b52575c908dd806d41482dd3a4 to your computer and use it in GitHub Desktop.
a utility script to help create signed and aligned APKs ready for publishing on app stores.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: scriptname keystore_path key_alias | |
keystore=$1 | |
alias=$2 | |
version=$(cat config.xml| grep widget | grep -Eo 'version="(.{2,6})"' | grep -Eo '".*"' | sed 's/"//g') | |
app_name=roboscape | |
apk_dir=platforms/android/app/build/outputs/apk/release | |
final_name="$app_name-release-$version.apk" | |
unsigned_name="$app_name-release-unsigned-$version.apk" | |
# check if args are passed in | |
if [ -z "$alias" ]; then | |
echo pass in keystore and alias | |
exit 1 | |
fi | |
set -e | |
function safe_deletion() { | |
echo version $version already exists. Do you wanna overwrite it? | |
read -p "Are you sure? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
rm -i $apk_dir/$final_name | |
else | |
exit 1 | |
fi | |
} | |
function check_version() { | |
echo "You are about to publish version $version (major, minor, patch)" | |
read -p "Are you sure? " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
echo ok | |
else | |
echo bump the version in config.xml | |
exit 1 | |
fi | |
} | |
check_version | |
[ -f $apk_dir/$final_name ] && safe_deletion | |
cordova build android --prod --release | |
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore $keystore $apk_dir/app-release-unsigned.apk $alias | |
zipalign -v 4 $apk_dir/app-release-unsigned.apk $apk_dir/app-release.apk | |
mv $apk_dir/app-release.apk $apk_dir/$final_name | |
# keep notes | |
notes_file=$apk_dir/$version-notes.txt | |
echo "#############=====###########" > $notes_file | |
git log > $notes_file | |
echo "#############" > $notes_file | |
git status > $notes_file | |
echo published $app_name $version to $apk_dir/$final_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
requires zipalign software.