Skip to content

Commit 7b7e45f

Browse files
Merge pull request #6 from DarthBenro008/firebase_support
Firebase support
2 parents 4d10aee + 9040340 commit 7b7e45f

File tree

5 files changed

+113
-19
lines changed

5 files changed

+113
-19
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
FROM openjdk:8
22

3-
RUN apt-get install curl unzip
3+
RUN apt-get update
4+
RUN apt-get -y install curl unzip openssl
45
ARG ANDROID_SDK_VERSION=6609375
56
ENV ANDROID_SDK_ROOT /opt/android-sdk
67
RUN mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \
78
wget -q https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \
89
unzip *tools*linux*.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools && \
910
rm *tools*linux*.zip
1011
COPY license_accepter.sh /opt/
11-
RUN chmod +x /opt/license_accepter.sh && /opt/license_accepter.sh $ANDROID_SDK_ROOT
12+
RUN chmod +x /opt/license_accepter.sh && /opt/license_accepter.sh $ANDROID_SDK_ROOT
1213
ADD entrypoint.sh /entrypoint.sh
1314
RUN chmod +x /entrypoint.sh
1415
ADD flutter.sh /flutter.sh
1516
RUN chmod +x /flutter.sh
1617
ENV ANDROID_HOME="${ANDROID_SDK_ROOT}"
18+
RUN chmod +x $ANDROID_HOME/*
1719
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
- Get your APK delivered to you on telegram with just a push of commit!
2222
- Automated Android APK Builds.
2323
- Unit Tests on Android Builds.
24+
- Supports Firebase based apps and signed builds with your custom key!
2425
- Forget wires, patches and building pull requests manually!
2526

2627
## Installation
2728

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

31+
**Note:** _If your project uses any services of firebase, please refer to the [WIKI](https://github.com/DarthBenro008/app-brickie/wiki) for instructions. The below instructions are only for **vanilla builds.**_
32+
3033

3134
#### **For Native Android Builds (Java/Kotlin) :**
3235
```yaml
@@ -121,8 +124,9 @@ packagename: "myapp"
121124

122125
## Upcoming Features
123126

124-
- Firebase apps build
125-
- Custom Key Signing
127+
- ~~Firebase apps build~~ (v3.0 supports Firebase Builds!)
128+
- ~~Custom Key Signing~~ (v3.0 supports custom key signing support!)
129+
- Slack integration
126130
- React Native Build Support
127131

128132
## Disclaimer

action.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@ inputs:
1616
abi:
1717
description: "Target ABI for flutter builds"
1818
requried: false
19-
19+
firebase:
20+
description: "Contents of your google-services.json file"
21+
requried: false
22+
keystore:
23+
description: "The text dump you generated of your keystore"
24+
requried: false
25+
keystorePassword:
26+
description: "Password of your keystore file"
27+
requried: false
28+
keyAlias:
29+
description: "Key alias of your key that needs to be signed"
30+
requried: false
31+
keyPassword:
32+
description: "Password of the key in your keystore file"
33+
requried: false
2034
outputs:
2135
result:
2236
description: "Result of automated send"

entrypoint.sh

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,64 @@ GREEN='\033[0;32m'
1010
NC='\033[0m'
1111

1212
# Functions
13+
14+
errorHandler(){
15+
echo -e "${RED}Error Due to : $1 ${NC}"
16+
exit 1
17+
}
18+
1319
sendpackage(){
1420
echo -e "${GREEN}Package Name is set to $packageName${NC}"
1521
output=$(curl --location --request POST 'http://appbrickie.herokuapp.com/api/sendPackage' \
1622
--form 'file=@app/build/outputs/apk/debug/'$packageName'' \
1723
--form 'id='$INPUT_CHATID'' \
1824
--form 'msg=Build Successful https://www.github.com/'$GITHUB_REPOSITORY'/commit/'$GITHUB_SHA'')
19-
echo "::set-output name=result::$output"
20-
}
25+
echo "::set-output name=result::$output"
26+
}
27+
28+
renamePackage(){
29+
{
30+
mv app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/debug/"$packageName"
31+
}||{
32+
echo -e "${RED}File Renaming Error, reverting to app-debug.apk name${NC}"
33+
packageName="app.apk"
34+
}
2135

22-
renamePackage(){
23-
{
24-
mv app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/debug/"$packageName"
25-
}||{
26-
echo -e "${RED}File Renaming Error, reverting to app-debug.apk name${NC}"
27-
packageName="app.apk"
28-
}
36+
}
2937

38+
apkSigner(){
39+
echo -e "${GREEN} This app is being signed with a custom key ${NC}"
40+
ksPassword=$INPUT_KEYSTOREPASSWORD
41+
kAlias=$INPUT_KEYALIAS
42+
echo "$INPUT_KEYSTORE" | base64 --decode > key.jks
43+
{
44+
$ANDROID_HOME/build-tools/*/zipalign -v -p 4 app/build/outputs/apk/debug/$packageName app/build/outputs/apk/debug/$packageName
45+
bash $ANDROID_HOME/build-tools/*/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
46+
}||{
47+
errorHandler "Failed to sign apk!"
48+
}
49+
echo -e "${GREEN} Apk signed successfully ! ${NC}"
3050
}
3151

3252
nativeBuild(){
53+
if [ -z "$INPUT_FIREBASE" ]
54+
then
55+
:
56+
else
57+
echo -e "${GREEN} This app uses firebase, extracting info ${NC}"
58+
echo "$INPUT_FIREBASE" > app/google-services.json
59+
fi
60+
3361
bash ./gradlew test --stacktrace
3462
bash ./gradlew assembleDebug --stacktrace
63+
64+
if [ -z "$INPUT_KEYSTORE" ]
65+
then
66+
:
67+
else
68+
apkSigner
69+
fi
70+
3571
if [ -z "$INPUT_PACKAGENAME" ]
3672
then
3773
sendpackage
@@ -40,18 +76,15 @@ nativeBuild(){
4076
packageName="$rectifiedName.apk"
4177
renamePackage
4278
sendpackage
43-
fi
79+
fi
80+
4481
}
4582

4683
flutterBuild(){
4784
echo "Flutter Build"
4885
bash /flutter.sh
4986
}
5087

51-
errorHandler(){
52-
echo -e "${RED}Error Due to : $1 ${NC}"
53-
exit 1
54-
}
5588

5689
# Main
5790
case $INPUT_TYPE in

flutter.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ git clone https://github.com/flutter/flutter "${FLUTTER_ROOT}"
1515
export PATH="${FLUTTER_ROOT}/bin:${PATH}"
1616

1717

18+
errorHandler(){
19+
echo -e "${RED}Error Due to : $1 ${NC}"
20+
exit 1
21+
}
22+
1823
sendpackage(){
1924
echo -e "${GREEN}Package Name is set to $packageName${NC}"
2025
output=$(curl --location --request POST 'http://appbrickie.herokuapp.com/api/sendPackage' \
@@ -33,12 +38,38 @@ sendpackage(){
3338
}
3439
}
3540

41+
apkSigner(){
42+
curl https://dl.google.com/android/repository/build-tools_r29.0.3-linux.zip --output "$GITHUB_WORKSPACE/build-tools.zip"
43+
unzip -q -o $GITHUB_WORKSPACE/build-tools.zip -d $GITHUB_WORKSPACE
44+
echo -e "${GREEN} This app is being signed with a custom key ${NC}"
45+
ksPassword=$INPUT_KEYSTOREPASSWORD
46+
kAlias=$INPUT_KEYALIAS
47+
echo "$INPUT_KEYSTORE" | base64 --decode > key.jks
48+
{
49+
$GITHUB_WORKSPACE/android-10/zipalign -v -p 4 build/app/outputs/apk/release/$builtPackageName build/app/outputs/apk/release/$builtPackageName
50+
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
51+
}||{
52+
errorHandler "Failed to sign apk!"
53+
}
54+
echo -e "${GREEN} Apk signed successfully ! ${NC}"
55+
}
56+
3657
# Run Flutter
3758
flutter config --no-analytics
3859
flutter precache
3960
yes "y" | flutter doctor --android-licenses
4061
flutter doctor -v
4162
flutter upgrade
63+
64+
#Firebase extraction
65+
if [ -z "$INPUT_FIREBASE" ]
66+
then
67+
:
68+
else
69+
echo "$INPUT_FIREBASE" > android/app/google-services.json
70+
fi
71+
72+
#Target
4273
if [ -z "$INPUT_ABI" ]
4374
then
4475
flutter build apk
@@ -61,6 +92,16 @@ else
6192
esac
6293
fi
6394

95+
96+
# KeySign
97+
if [ -z "$INPUT_KEYSTORE" ]
98+
then
99+
:
100+
else
101+
apkSigner
102+
fi
103+
104+
#Final Process
64105
if [ -z "$INPUT_PACKAGENAME" ]
65106
then
66107
packageName=$builtPackageName

0 commit comments

Comments
 (0)