forked from systers/malaria-app-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-apk.sh
48 lines (39 loc) · 1.36 KB
/
generate-apk.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
# Travis build triggered on a forked repository
if [ "$TRAVIS_REPO_SLUG" != "systers/malaria-app-android" ]; then
echo "Not the original repo."
exit 0
fi
# Travis build triggered by a PR
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Just a PR."
exit 0
fi
# Get commit author name
COMMITTER_NAME=$(git log -1 --pretty=format:'%an')
# Code pushed to develop branch
if [ "$TRAVIS_BRANCH" == "master" ]; then
echo "Code pushed to master branch. Updating apk."
# Set username and email
git config --global user.name "m-murad"
git config --global user.email "[email protected]"
# Create a new git repo to save apk
cd $HOME
mkdir apk
cd apk
git init
# Copy generated apk into the new repo
cp $HOME/build/systers/malaria-app-android/malaria-app-android/build/outputs/apk/debug/malaria-app-android-debug.apk $HOME/apk/
# Add and commit the new apk
git add malaria-app-android-debug.apk
git commit -m "Apk update: Travis build $TRAVIS_BUILD_NUMBER by $COMMITTER_NAME"
# Rename the current branch
git branch -m apk
# Pushing the apk branch to the original repo
git push https://m-murad:[email protected]/systers/malaria-app-android apk -fq > /dev/null
if [ $? -eq 0 ]; then
echo "Apk push successful."
else
echo "Apk push failed."
fi
fi