diff --git a/action.yml b/action.yml index 74a7214..d566b7d 100644 --- a/action.yml +++ b/action.yml @@ -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: diff --git a/entrypoint.sh b/entrypoint.sh index 9d17615..b4702a9 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -44,8 +44,7 @@ nativeBuild(){ } flutterBuild(){ - echo "Flutter Build" - ls + echo "Flutter Build" bash /flutter.sh } diff --git a/flutter.sh b/flutter.sh index d62f6d0..25ddd83 100755 --- a/flutter.sh +++ b/flutter.sh @@ -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}" @@ -14,17 +22,16 @@ 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 @@ -32,9 +39,31 @@ 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// /_}