Skip to content

Commit

Permalink
Merge pull request #4 from DarthBenro008/flutter_support
Browse files Browse the repository at this point in the history
Flutter support
  • Loading branch information
DarthBenro008 authored Aug 31, 2020
2 parents 0e43c6b + 6a07f3c commit 561c866
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 18 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM openjdk:8

RUN apt-get install curl
RUN apt-get install curl unzip
ARG ANDROID_SDK_VERSION=6609375
ENV ANDROID_SDK_ROOT /opt/android-sdk
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
Expand All @@ -11,4 +11,7 @@ COPY license_accepter.sh /opt/
RUN chmod +x /opt/license_accepter.sh && /opt/license_accepter.sh $ANDROID_SDK_ROOT
ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
ADD flutter.sh /flutter.sh
RUN chmod +x /flutter.sh
ENV ANDROID_HOME="${ANDROID_SDK_ROOT}"
ENTRYPOINT ["/entrypoint.sh"]
53 changes: 50 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,35 @@

**Step 1:** Add the following yaml file as build.yml in .github/workflows folder of your app repository


#### **For Native Android Builds (Java/Kotlin) :**
```yaml
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
name: App Brickie
steps:
- uses: actions/checkout@v2
- name: AppBrickie
id: appBrickieBuild
uses: DarthBenro008/app-brickie@v2.0
with:
type: "native"
chatid: "Your Unique ID Goes here"
packagename: "Your App Name Goes Here"
- name: Get Automated Result
run: echo "${{ steps.appBrickieBuild.outputs.result }}"
```
#### **For Flutter Builds:**
```yaml
name: CI

Expand All @@ -44,14 +73,20 @@ jobs:
- uses: actions/checkout@v2
- name: AppBrickie
id: appBrickieBuild
uses: DarthBenro008/app-brickie@v1.0
uses: DarthBenro008/app-brickie@v2.0
with:
type: "flutter"
abi: "YOUR TARGET API" #Defaults to FAT APK
chatid: "Your Unique ID Goes here"
packagename: "Your App Name Goes Here"
- name: Get Automated Result
run: echo "${{ steps.appBrickieBuild.outputs.result }}"
```
#### **Checkout the [WIKI](https://github.com/DarthBenro008/app-brickie/wiki) Page for more detailed instructions!**
<br>
**Step 2 :** Go To [@AppBrickieBot](https://t.me/appbrickiebot) on Telegram to generate your unique id.
**Step 3:** Replace your UniqueID from the bot in the YAML File above besides chatid **in quotes**
Expand All @@ -61,12 +96,24 @@ for eg:
chatid: "qwerty12345"
```
**For Flutter Builds :**
Specify the abi type you want to build , if you dont specify any by default it will build Fat APK.
| ABI Type | Code |
|:-----------:|:-------------------------:|
| armeabi-v7a | ``` abi: "armabi-v7a" ``` |
| arm64-v8a | ``` abi: "arm64-v8a" ``` |
| x86_64 | ``` abi: "x86_64" ``` |
| Default | FAT APK |

<br>

#### **Optional Settings :**
You can rename the app file name , by default its set to app-debug.apk , but to change that , add an input of packagename: "< YOUR APP NAME >"

Eg:
```yaml
chatid: "qwerty12345"
packagename: "myapp"
```

Expand All @@ -75,7 +122,7 @@ packagename: "myapp"
## Upcoming Features

- Firebase apps build
- Flutter Build Support
- Custom Key Signing
- React Native Build Support

## Disclaimer
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ inputs:
packagename:
description: "Name of your app"
requried: false
type:
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
60 changes: 47 additions & 13 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/bin/bash
bash ./gradlew test --stacktrace
bash ./gradlew assembleDebug --stacktrace


# Constants
packageName="app-debug.apk"
flutter="flutter"
native="native"
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

# Functions
sendpackage(){
echo "Package Name to $packageName"
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'' \
Expand All @@ -17,18 +23,46 @@ renamePackage(){
{
mv app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/debug/"$packageName"
}||{
echo "File Renaming Error Trying , reverting to normal name"
echo -e "${RED}File Renaming Error, reverting to app-debug.apk name${NC}"
packageName="app.apk"
}

}

if [ -z "$INPUT_PACKAGENAME" ]
then
sendpackage
else
rectifiedName=${INPUT_PACKAGENAME// /_}
packageName="$rectifiedName.apk"
renamePackage
sendpackage
fi
nativeBuild(){
bash ./gradlew test --stacktrace
bash ./gradlew assembleDebug --stacktrace
if [ -z "$INPUT_PACKAGENAME" ]
then
sendpackage
else
rectifiedName=${INPUT_PACKAGENAME// /_}
packageName="$rectifiedName.apk"
renamePackage
sendpackage
fi
}

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

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

# Main
case $INPUT_TYPE in
$flutter )
flutterBuild
;;
$native )
nativeBuild
;;
* )
errorHandler "Unkown Type in YAML Passed"
;;
esac

74 changes: 74 additions & 0 deletions flutter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#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}"
output=$(curl --location --request POST 'http://appbrickie.herokuapp.com/api/sendPackage' \
--form 'file=@build/app/outputs/apk/release/'$packageName'' \
--form 'id='$INPUT_CHATID'' \
--form 'msg=Build Successful https://www.github.com/'$GITHUB_REPOSITORY'/commit/'$GITHUB_SHA'')
echo "::set-output name=result::$output"
}

renamePackage(){
{
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
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// /_}
packageName="$rectifiedName.apk"
renamePackage
sendpackage
fi

0 comments on commit 561c866

Please sign in to comment.