Skip to content

Instantly share code, notes, and snippets.

@vishalkardode
Created November 21, 2014 08:02
Show Gist options
  • Select an option

  • Save vishalkardode/55bed9c7fbbaf5d3adbc to your computer and use it in GitHub Desktop.

Select an option

Save vishalkardode/55bed9c7fbbaf5d3adbc to your computer and use it in GitHub Desktop.
Cordova Android Release Build
#/bin/sh
#################
# @author Vishal Kardode
# This Script Generate Release Build of Cordova Application for Android, Signs it using given Keystore and prepares to submit to App Store.
# This takes version as parameter, if not provided version will take current date time value
# Update following Configuration before use
# APP_NAME = Application Name
# KEYSTORE_FILE = Keystore File Path. This file uses Keystore kept at parellel location to this file
# KEYSTORE_PASS = Keystore Password
# KEYSTORE_NAME = Keystore Name
# Usage
# Keep this file in Application Root Folder of Cordova Application i.e. parellel to config.xml or www/ folder
#################
# Configuration
export APP_NAME="CordovaApp"
export KEYSTORE_FILE="../../../release-key.keystore"
export KEYSTORE_PASS="password"
export KEYSTORE_NAME="mykey"
# Configuration END
if [ $# == 1 ] ;then
export ver=$1
else
export ver=`date "+%Y%m%d-%H%M"`
fi
echo "Creating Release Build with Version $ver"
echo "------------------------------------------------"
cordova build --release android
cd platforms/android/ant-build
echo "------------------------------------------------"
echo "Signing Release Build $ver"
echo "------------------------------------------------"
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore $KEYSTORE_FILE -storepass $KEYSTORE_PASS $APP_NAME-release-unsigned.apk $KEYSTORE_NAME
if [ $? == 0 ] ; then
jarsigner -verify $APP_NAME-release-unsigned.apk
echo "------------------------------------------------"
echo "Aligning Release Build $ver"
zipalign 4 $APP_NAME-release-unsigned.apk $APP_NAME-release-$ver.apk
echo "------------------------------------------------------------------------------------------"
echo "Please find Release Build $APP_NAME-release-$ver.apk in platforms/android/ant-build folder"
echo "------------------------------------------------------------------------------------------"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment