How to generate a release .apk file from a Cordova project

The following batch file takes a Cordova project and builds, signs, and deploys a .apk file. I had found this script to be helpful for myself, so hopefully it will help others as well. Just replace keystore_file and alias_name with your own keystore information.

cordova build --release android

for /f "delims=" %%x in ('dir /od /a-d /b platforms\android\ant-build\*.apk') do set recent=%%x

set recentShort=%recent:-release-unsigned.apk=.apk%

ECHO Y | DEL %recentShort%

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -storepass transitKey -keystore keystore_file platforms\android\ant-build\%recent% alias_name

zipalign -v 4 platforms\android\ant-build\%recent% %recentShort%

adb install -r %recentShort%