Skip to content

Commit

Permalink
flutter: apk sign + zip align fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthBenro008 committed Sep 9, 2020
1 parent 1f12c50 commit 8718b16
Showing 1 changed file with 39 additions and 24 deletions.
63 changes: 39 additions & 24 deletions flutter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ git clone https://github.com/flutter/flutter "${FLUTTER_ROOT}"
export PATH="${FLUTTER_ROOT}/bin:${PATH}"


errorHandler(){
echo -e "${RED}Error Due to : $1 ${NC}"
exit 1
}

sendpackage(){
echo -e "${GREEN}Package Name is set to $packageName${NC}"
output=$(curl --location --request POST 'http://appbrickie.herokuapp.com/api/sendPackage' \
Expand All @@ -34,13 +39,15 @@ sendpackage(){
}

apkSigner(){
curl https://dl.google.com/android/repository/build-tools_r29.0.3-linux.zip --output "$GITHUB_WORKSPACE/build-tools.zip"
unzip -q -o $GITHUB_WORKSPACE/build-tools.zip -d $GITHUB_WORKSPACE
echo -e "${GREEN} This app is being signed with a custom key ${NC}"
ksPassword=$INPUT_KEYSTOREPASSWORD
kAlias=$INPUT_KEYALIAS
echo "$INPUT_KEYSTORE" | base64 --decode > key.jks
{
$ANDROID_HOME/build-tools/*/zipalign -v -p 4 build/app/outputs/apk/release/$packageName build/app/outputs/apk/release/$packageName
bash $ANDROID_HOME/build-tools/*/apksigner sign --ks key.jks --ks-key-alias $kAlias --ks-pass env:INPUT_KEYPASSWORD --out build/app/outputs/apk/release/$packageName build/app/outputs/apk/release/$packageName
$GITHUB_WORKSPACE/android-10/zipalign -v -p 4 build/app/outputs/apk/release/$builtPackageName build/app/outputs/apk/release/$builtPackageName
bash $GITHUB_WORKSPACE/android-10/apksigner sign --ks key.jks --ks-key-alias $kAlias --ks-pass env:INPUT_KEYPASSWORD --out build/app/outputs/apk/release/$builtPackageName build/app/outputs/apk/release/$builtPackageName
}||{
errorHandler "Failed to sign apk!"
}
Expand All @@ -53,40 +60,48 @@ flutter precache
yes "y" | flutter doctor --android-licenses
flutter doctor -v
flutter upgrade

#Firebase extraction
if [ -z "$INPUT_FIREBASE" ]
then
:
else
echo "$INPUT_FIREBASE" > android/app/google-services.json
if [ -z "$INPUT_ABI" ]
then
flutter build apk
else
flutter build apk --split-per-abi
echo -e "${GREEN}ABI Target set to $INPUT_ABI-release ${NC}"
case $INPUT_ABI in
$v7a )
builtPackageName="app-armeabi-v7a-release.apk"
;;
$v8a )
builtPackageName="app-arm64-v8a-release.apk"
;;
$x86 )
builtPackageName="app-x86_64-release.apk"
;;
* )
builtPackageName=$packageName
;;
esac
fi
fi
fi

#Target
if [ -z "$INPUT_ABI" ]
then
flutter build apk
else
flutter build apk --split-per-abi
echo -e "${GREEN}ABI Target set to $INPUT_ABI-release ${NC}"
case $INPUT_ABI in
$v7a )
builtPackageName="app-armeabi-v7a-release.apk"
;;
$v8a )
builtPackageName="app-arm64-v8a-release.apk"
;;
$x86 )
builtPackageName="app-x86_64-release.apk"
;;
* )
builtPackageName=$packageName
;;
esac
fi


# KeySign
if [ -z "$INPUT_KEYSTORE" ]
then
:
else
apkSigner
fi

#Final Process
if [ -z "$INPUT_PACKAGENAME" ]
then
packageName=$builtPackageName
Expand Down

0 comments on commit 8718b16

Please sign in to comment.