Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

Commit 0e48d19

Browse files
iamareebjamalharshithdwivedi
authored andcommittedDec 17, 2017
chore: Fix travis apk generation (#2021)
1 parent c9164ee commit 0e48d19

7 files changed

+97
-166
lines changed
 

‎.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ install:
2525
before_script:
2626
- cd android
2727
script:
28-
- chmod +x configedit.sh
29-
- bash generate_apks.sh
28+
- bash ../scripts/generate_apks.sh
3029
notifications:
3130
webhooks:
3231
urls:
@@ -35,4 +34,4 @@ notifications:
3534
on_failure: always
3635
on_start: false
3736
after_success:
38-
- bash ../upload-apk.sh
37+
- bash ../scripts/upload-apk.sh

‎android/codestyle.sh

-89
This file was deleted.

‎android/configedit.sh

-11
This file was deleted.

‎android/generate_apks.sh

-61
This file was deleted.

‎scripts/configedit.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
VAR=0
4+
STRING1=$1
5+
6+
while read line
7+
do
8+
((VAR+=1))
9+
if [ "$VAR" = 4 ]; then
10+
echo "$STRING1"
11+
else
12+
echo "$line"
13+
fi
14+
done < $srcdir/src/main/assets/config.json

‎scripts/generate_apks.sh

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/bash
2+
3+
echo "Build for FOSSASIA17 Started"
4+
5+
gradle=./gradlew
6+
7+
$gradle build
8+
9+
if [ $? != 0 ]; then
10+
echo "Gradle build failed"
11+
exit 1
12+
fi
13+
14+
#Prevent further builds if a PR
15+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
16+
echo "Just a PR. Skip apk upload."
17+
cd ..
18+
echo "Returned to root directory"
19+
exit 0
20+
fi
21+
22+
#Generate a folder to store apks of different sample
23+
mkdir -p $HOME/apps
24+
25+
export srcdir=./app
26+
export builddir=$srcdir/build/outputs/apk/fdroid/debug
27+
export apkdir=$HOME/apps
28+
29+
#Backup config.json to config.txt
30+
cp $srcdir/src/main/assets/config.json $srcdir/src/main/assets/config.txt
31+
32+
#Initial Build Using FOSSASIA17 Sample
33+
cp -R $builddir/app-fdroid-debug.apk $apkdir/fossasia17-fdroid.apk
34+
35+
#BASE_URLS for Samples
36+
GOOGLEIO17="\"Api_Link\":\"https://raw.githubusercontent.com/fossasia/open-event/master/sample/GoogleIO17\"}"
37+
MozillaAllHands17="\"Api_Link\":\"https://raw.githubusercontent.com/fossasia/open-event/master/sample/MozillaAllHands17\"}"
38+
FBF817="\"Api_Link\":\"https://raw.githubusercontent.com/mahikaw/open-event/fbf8/sample/F8\"}"
39+
40+
#ApkNames
41+
GOOGLEIO17Apk=googleio17-fdroid.apk
42+
MozillaAllHands17Apk=mozillaAllHands17-fdroid.apk
43+
FBF817Apk=fbf817-fdroid.apk
44+
45+
COUNTER=0
46+
47+
declare -a arr=($GOOGLEIO17 $MozillaAllHands17 $FBF817)
48+
declare -a apkname=($GOOGLEIO17Apk $MozillaAllHands17Apk $FBF817Apk)
49+
50+
while [ $COUNTER -le 2 ];
51+
do
52+
echo "Generating ${apkname[$COUNTER]}"
53+
bash ../scripts/configedit.sh "${arr[$COUNTER]}" $ANDROID > config.json
54+
55+
#Reconfigure BASE_URL
56+
mv config.json $srcdir/src/main/assets/
57+
58+
#Remove all pre-exsiting APKs
59+
rm -R $builddir/*
60+
61+
#Start Build
62+
$gradle assembleDebug
63+
64+
#Move built apk to $HOME/daily/
65+
cp -R $builddir/app-fdroid-debug.apk $apkdir/"${apkname[$COUNTER]}"
66+
67+
((COUNTER+=1))
68+
done
69+
70+
echo "Completed Generating Files..."
71+
72+
#Cleanup
73+
mv $srcdir/src/main/assets/config.txt $srcdir/src/main/assets/config.json
74+
echo "Restored original JSON"
75+
76+
cd ..
77+
echo "Returned to root directory"

‎upload-apk.sh ‎scripts/upload-apk.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
#!/usr/bin/env bash
1+
#!/bin/bash
22

33
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_REPO_SLUG" != "fossasia/open-event-android" ]; then
44
echo "Just a PR. Skip apk upload."
55
exit 0
66
fi
77

8+
export appdir=$HOME/apps
9+
810
# go to home and setup git
911
cd $HOME
1012
git config --global user.email "noreply@travis.com"
@@ -13,7 +15,7 @@ git config --global user.name "Travis-CI"
1315
git clone --quiet --branch=apk https://the-dagger:$GITHUB_API_KEY@github.com/fossasia/open-event-android apk > /dev/null
1416
cd apk
1517
rm -rf *.apk
16-
cp -Rf $HOME/daily/* ./
18+
cp -Rf $appdir/* ./
1719

1820
mv fossasia17-fdroid.apk sample-apk-fossasia17-${TRAVIS_BRANCH}.apk
1921
mv fbf817-fdroid.apk sample-apk-fbf817-${TRAVIS_BRANCH}.apk

0 commit comments

Comments
 (0)
This repository has been archived.