Skip to content

Commit

Permalink
feat: firebase support
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthBenro008 committed Sep 5, 2020
1 parent 4d10aee commit ca3dea1
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 18 deletions.
16 changes: 15 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ inputs:
abi:
description: "Target ABI for flutter builds"
requried: false

firebase:
description: "Contents of your google-services.json file"
requried: false
keystore:
description: "The text dump you generated of your keystore"
requried: false
keystorePassword:
description: "Password of your keystore file"
requried: false
keyAlias:
description: "Key alias of your key that needs to be signed"
requried: false
keyPassword:
description: "Password of the key in your keystore file"
requried: false
outputs:
result:
description: "Result of automated send"
Expand Down
66 changes: 49 additions & 17 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,63 @@ GREEN='\033[0;32m'
NC='\033[0m'

# Functions

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' \
--form 'file=@app/build/outputs/apk/debug/'$packageName'' \
--form 'id='$INPUT_CHATID'' \
--form 'msg=Build Successful https://www.github.com/'$GITHUB_REPOSITORY'/commit/'$GITHUB_SHA'')
echo "::set-output name=result::$output"
}
echo "::set-output name=result::$output"
}

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

}
}

apkSigner(){
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
{
zipalign -v -p 4 app/build/outputs/apk/debug/$packageName app/build/outputs/apk/debug/$packageName
apksigner sign --ks key.jks --ks-key-alias kAlias --ks-pass env:INPUT_KEYPASSWORD --out app/build/outputs/apk/debug/$packageName app/build/outputs/apk/debug/$packageName
}||{
errorHandler "Failed to sign apk!"
}
echo -e "${GREEN} Apk signed successfully ! ${NC}"
}

nativeBuild(){
bash ./gradlew test --stacktrace
bash ./gradlew assembleDebug --stacktrace
if [ -z "$INPUT_FIREBASE" ]
then
:
else
echo -e "${GREEN} This app uses firebase, extracting info ${NC}"
echo "$INPUT_FIREBASE" > app/google-services.json
fi
{
bash ./gradlew test --stacktrace
bash ./gradlew assembleDebug --stacktrace
}||{
errorHandler "Failed to compile android app!"
}
if [ -z "$INPUT_KEYSTORE" ]
then
apkSigner
else
if [ -z "$INPUT_PACKAGENAME" ]
then
sendpackage
Expand All @@ -40,18 +75,15 @@ nativeBuild(){
packageName="$rectifiedName.apk"
renamePackage
sendpackage
fi
fi
fi
}

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

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

# Main
case $INPUT_TYPE in
Expand Down
5 changes: 5 additions & 0 deletions flutter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ flutter precache
yes "y" | flutter doctor --android-licenses
flutter doctor -v
flutter upgrade
if [ -z "$INPUT_FIREBASE" ]
then
continue
else
echo "$INPUT_FIREBASE" > android/app/google-services.json
if [ -z "$INPUT_ABI" ]
then
flutter build apk
Expand Down

0 comments on commit ca3dea1

Please sign in to comment.