Skip to content

Commit

Permalink
feat: ABI specific build for flutter builds
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthBenro008 committed Aug 31, 2020
1 parent ced203b commit 501d6ae
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ inputs:
description: "The Framework that you are using to build your app"
requried: true
default: "native"
abi:
description: "Target ABI for flutter builds"
requried: false

outputs:
result:
Expand Down
3 changes: 1 addition & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ nativeBuild(){
}

flutterBuild(){
echo "Flutter Build"
ls
echo "Flutter Build"
bash /flutter.sh
}

Expand Down
49 changes: 39 additions & 10 deletions flutter.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Get Flutter
export FLUTTER_ROOT="/opt/flutter"
git clone https://github.com/flutter/flutter "${FLUTTER_ROOT}"
export PATH="${FLUTTER_ROOT}/bin:${PATH}"
#Constants
packageName="app-release.apk"
builtPackageName=$packageName
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
v7a='armabi-v7a'
v8a='arm64-v8a'
x86='x86_64'


# Get Flutter
export FLUTTER_ROOT="/opt/flutter"
git clone https://github.com/flutter/flutter "${FLUTTER_ROOT}"
export PATH="${FLUTTER_ROOT}/bin:${PATH}"


sendpackage(){
echo -e "${GREEN}Package Name is set to $packageName${NC}"
Expand All @@ -14,27 +22,48 @@ sendpackage(){
--form 'id='$INPUT_CHATID'' \
--form 'msg=Build Successful https://www.github.com/'$GITHUB_REPOSITORY'/commit/'$GITHUB_SHA'')
echo "::set-output name=result::$output"
}
}

renamePackage(){
renamePackage(){
{
mv build/app/outputs/apk/release/app-release.apk build/app/outputs/apk/release/"$packageName"
mv build/app/outputs/apk/release/"$builtPackageName" build/app/outputs/apk/release/"$packageName"
}||{
echo -e "${RED}File Renaming Error, reverting to app-debug.apk name${NC}"
packageName="app.apk"
}

}
}

# Run Flutter
flutter config --no-analytics
flutter precache
yes "y" | flutter doctor --android-licenses
flutter doctor -v
flutter upgrade
flutter build apk
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

if [ -z "$INPUT_PACKAGENAME" ]
then
packageName=$builtPackageName
sendpackage
else
rectifiedName=${INPUT_PACKAGENAME// /_}
Expand Down

0 comments on commit 501d6ae

Please sign in to comment.