Skip to content

Instantly share code, notes, and snippets.

@bluescreen
Created February 12, 2015 12:47
Show Gist options
  • Save bluescreen/96f4bcf8ee4d28369ff3 to your computer and use it in GitHub Desktop.
Save bluescreen/96f4bcf8ee4d28369ff3 to your computer and use it in GitHub Desktop.
Ionic Android Sign
#!/bin/bash
textReset=$(tput sgr0)
textRed=$(tput setaf 1)
textYellow=$(tput setaf 3)
textGreen=$(tput setaf 2)
message_info () {
echo "$textGreen[deploy]$textReset $1"
}
message_error () {
echo "$textRed[project]$textReset $1"
}
if [ -z $1 ]
then
message_error "Usage ./deploy PROJECT_NAME";
exit;
fi
projectName=$1;
keystore=$1".keystore";
unsigned=$1"-unsigned.apk"
release=$1".apk"
if [ ! -f $keystore ]
then
message_info "Generate new keystore $keystore...";
keytool -genkey -v -keystore $projectName.keystore -alias $projectName -keyalg RSA -keysize 2048 -validity 10000
else
message_info "Keystore $keystore exists";
fi
if [ -f $unsigned ]
then
message_info "Delete old unsigned apk ...";
rm $unsigned;
fi
if [ -f $release ]
then
message_info "Delete old release ...";
rm $release;
fi
#cordova build --release android
cp platforms/android/ant-build/CordovaApp-release-unsigned.apk $unsigned
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore $keystore $unsigned $projectName
/Applications/eclipse-mobile/sdk/build-tools/android-4.4W/zipalign -v 4 $unsigned $release
rm $unsigned;
message_info "Done";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment